Documentation ¶
Overview ¶
Package outputparser provides utilities for parsing and processing the output generated by LLMs and other tools.
Index ¶
- type CommaSeparatedList
- func (p *CommaSeparatedList) GetFormatInstructions() string
- func (p *CommaSeparatedList) Parse(text string) (any, error)
- func (p *CommaSeparatedList) ParseResult(result schema.Generation) (any, error)
- func (p *CommaSeparatedList) ParseWithPrompt(text string, prompt schema.PromptValue) (any, error)
- func (p *CommaSeparatedList) Type() string
- type FencedCodeBlock
- func (p *FencedCodeBlock) GetFormatInstructions() string
- func (p *FencedCodeBlock) Parse(text string) (any, error)
- func (p *FencedCodeBlock) ParseResult(result schema.Generation) (any, error)
- func (p *FencedCodeBlock) ParseWithPrompt(text string, prompt schema.PromptValue) (any, error)
- func (p *FencedCodeBlock) Type() string
- type NoOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommaSeparatedList ¶ added in v0.0.48
type CommaSeparatedList struct{}
CommaSeparatedList is an implementation of the OutputParser interface that parses a comma-separated list of values from the output text.
func NewCommaSeparatedList ¶ added in v0.0.48
func NewCommaSeparatedList() CommaSeparatedList
NewCommaSeparatedList creates a new instance of the CommaSeparatedList parser.
func (*CommaSeparatedList) GetFormatInstructions ¶ added in v0.0.48
func (p *CommaSeparatedList) GetFormatInstructions() string
GetFormatInstructions returns the format instructions for using the CommaSeparatedList parser. It implements the GetFormatInstructions method of the OutputParser interface.
func (*CommaSeparatedList) Parse ¶ added in v0.0.48
func (p *CommaSeparatedList) Parse(text string) (any, error)
Parse parses the input text as a comma-separated list of values and returns them as a slice of strings. The input text is expected to be in the format of a comma-separated list, e.g., "foo, bar, baz". Leading and trailing spaces in each value will be removed during parsing.
If the input text is empty or contains only spaces, it will return an error with the message "no value to parse".
It implements the Parse method of the OutputParser interface.
func (*CommaSeparatedList) ParseResult ¶ added in v0.0.48
func (p *CommaSeparatedList) ParseResult(result schema.Generation) (any, error)
ParseResult parses the result from code generation into a comma-separated list of values. It implements the ParseResult method of the OutputParser interface.
func (*CommaSeparatedList) ParseWithPrompt ¶ added in v0.0.48
func (p *CommaSeparatedList) ParseWithPrompt(text string, prompt schema.PromptValue) (any, error)
ParseWithPrompt parses a comma-separated list of values from the provided text and prompt. It implements the ParseWithPrompt method of the OutputParser interface.
func (*CommaSeparatedList) Type ¶ added in v0.0.48
func (p *CommaSeparatedList) Type() string
Type returns the type of the output parser, which is "comma_separated_list".
type FencedCodeBlock ¶ added in v0.0.11
type FencedCodeBlock struct {
// contains filtered or unexported fields
}
FencedCodeBlock represents a parser for extracting fenced code blocks from the output text.
func NewFencedCodeBlock ¶ added in v0.0.11
func NewFencedCodeBlock(fence string) *FencedCodeBlock
NewFencedCodeBlock creates a new instance of FencedCodeBlock with the specified fence.
func (*FencedCodeBlock) GetFormatInstructions ¶ added in v0.0.11
func (p *FencedCodeBlock) GetFormatInstructions() string
GetFormatInstructions returns a formatted string describing the expected format of the output. It instructs the user to enclose their response in a fenced code block using the specified fence.
func (*FencedCodeBlock) Parse ¶ added in v0.0.11
func (p *FencedCodeBlock) Parse(text string) (any, error)
Parse extracts fenced code blocks from the input text and returns them as a slice of strings. The fence used to enclose the code blocks is specified when creating the FencedCodeBlock instance.
func (*FencedCodeBlock) ParseResult ¶ added in v0.0.22
func (p *FencedCodeBlock) ParseResult(result schema.Generation) (any, error)
ParseResult parses the result of generation and returns the extracted fenced code blocks as a slice of strings.
func (*FencedCodeBlock) ParseWithPrompt ¶ added in v0.0.11
func (p *FencedCodeBlock) ParseWithPrompt(text string, prompt schema.PromptValue) (any, error)
ParseWithPrompt is not used for this parser, so it simply calls Parse.
func (*FencedCodeBlock) Type ¶ added in v0.0.11
func (p *FencedCodeBlock) Type() string
Type returns the type identifier of the parser, which is "fenced_code_block".
type NoOpt ¶ added in v0.0.22
type NoOpt struct{}
NoOpt represents a simple parser that returns the output text without any additional processing.
func NewNoOpt ¶ added in v0.0.22
func NewNoOpt() *NoOpt
NewNoOpt creates a new instance of NoOpt parser.
func (*NoOpt) GetFormatInstructions ¶ added in v0.0.22
GetFormatInstructions returns an empty string as there are no specific format instructions for this parser.
func (*NoOpt) Parse ¶ added in v0.0.22
Parse simply returns the input text as the parsed result without any modifications.
func (*NoOpt) ParseResult ¶ added in v0.0.22
func (p *NoOpt) ParseResult(result schema.Generation) (any, error)
ParseResult returns the generation text as the parsed result without any modifications.
func (*NoOpt) ParseWithPrompt ¶ added in v0.0.22
ParseWithPrompt is not used for this parser, so it simply calls Parse.