Documentation
¶
Index ¶
- Variables
- func GetDiffSize(leftText, rightText string) (bool, int, int)
- func GetInputText(inputFilePath string) (string, error)
- func GetPromptText(prompt, promptPath string) (string, error)
- func Print(outputText, inputText string, useDiff bool)
- func WriteResult(outputText, outpath string) error
- type ShapePrompt
- type ShapeResult
- type Shaper
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoChoices is an error when there are no choices in chat completion. ErrNoChoices = errors.New("no choices in chat completion") )
var ErrPromptRequired = errors.New("prompt is required")
ErrPromptRequired is exported and uses CamelCase.
Functions ¶
func GetDiffSize ¶
GetDiffSize returns a boolean indicating if there are any differences and the number of characters added and removed.
func GetInputText ¶
GetInputText reads text from a file specified by inputFilePath or from stdin if the path is "-".
func GetPromptText ¶
GetPromptText retrieves the prompt text from the specified source.
func Print ¶
Print outputs the provided outputText to the console. If useDiff is true, it also prints the differences between inputText and outputText.
func WriteResult ¶
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.