steps

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNoChoices is an error when there are no choices in chat completion.
	ErrNoChoices = errors.New("no choices in chat completion")
)
View Source
var ErrPromptRequired = errors.New("prompt is required")

ErrPromptRequired is exported and uses CamelCase.

Functions

func GetDiffSize

func GetDiffSize(leftText, rightText string) (bool, int, int)

GetDiffSize returns a boolean indicating if there are any differences and the number of characters added and removed.

func GetInputText

func GetInputText(inputFilePath string) (string, error)

GetInputText reads text from a file specified by inputFilePath or from stdin if the path is "-".

func GetPromptText

func GetPromptText(prompt, promptPath string) (string, error)

GetPromptText retrieves the prompt text from the specified source.

func Print

func Print(outputText, inputText string, useDiff bool)

Print outputs the provided outputText to the console. If useDiff is true, it also prints the differences between inputText and outputText.

func WriteResult

func WriteResult(outputText, outpath string) error

WriteResult writes the outputText to the given outpath. If an error occurs, it wraps it with additional context.

Types

type ShapePrompt

type ShapePrompt string

type ShapeResult

type ShapeResult struct {
	Prompt         string
	ChatCompletion *openai.ChatCompletion
	RawResult      string
	Result         string
}

ShapeResult represents the result of a text shaping operation.

func NewShapeResult

func NewShapeResult(prompt string, chatCompletion *openai.ChatCompletion, rawResult, result string) *ShapeResult

NewShapeResult creates a new ShapeResult.

type Shaper

type Shaper struct {
	// contains filtered or unexported fields
}

Shaper is responsible for shaping the text by interacting with GenerativeAIClient.

func NewShaper

func NewShaper(gai openai.GenerativeAIClient, maxCompletionRepeatCount int, useFirstCodeBlock, promptOptimize bool) *Shaper

NewShaper creates a new Shaper.

func (*Shaper) MakeShapePrompt

func (s *Shaper) MakeShapePrompt(inputFilePath, promptOrg, inputOrg string) ShapePrompt

MakeShapePrompt generates a ShapePrompt based on input parameters.

func (*Shaper) Shape

func (s *Shaper) Shape(ctx context.Context, prompt ShapePrompt) (*ShapeResult, error)

Shape shapes the text based on the given prompts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL