Documentation
¶
Index ¶
- type ParseResult
- type Parser
- func (p *Parser) ExtractAction(text string) (map[string]interface{}, error)
- func (p *Parser) ExtractCode(text string) string
- func (p *Parser) ExtractError(text string) string
- func (p *Parser) ExtractThought(text string) string
- func (p *Parser) GetCodeBlockTags() [2]string
- func (p *Parser) IsFinalAnswer(result *ParseResult) bool
- func (p *Parser) Parse(response string) *ParseResult
- func (p *Parser) ParseStructuredOutput(text string) (map[string]interface{}, error)
- type StreamParser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ParseResult ¶
type ParseResult struct {
Type string // "code", "action", "structured", "final_answer", "error"
Thought string // The reasoning/thought if present
Content string // The main content (code or action)
Action map[string]interface{} // Parsed action for tool calling
Error error // Any parsing error
IsStreaming bool // Whether this is a streaming response
}
ParseResult represents the result of parsing an LLM response
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser handles parsing of LLM responses
func NewParserWithTags ¶
NewParserWithTags creates a new parser with custom code block tags
func (*Parser) ExtractAction ¶
ExtractAction extracts action JSON from text
func (*Parser) ExtractCode ¶
ExtractCode extracts code from between code block tags
func (*Parser) ExtractError ¶
ExtractError extracts error message from text
func (*Parser) ExtractThought ¶
ExtractThought extracts the thought/reasoning from text
func (*Parser) GetCodeBlockTags ¶
GetCodeBlockTags returns the current code block tags
func (*Parser) IsFinalAnswer ¶
func (p *Parser) IsFinalAnswer(result *ParseResult) bool
IsFinalAnswer checks if the parsed result is a final answer
func (*Parser) Parse ¶
func (p *Parser) Parse(response string) *ParseResult
type StreamParser ¶
type StreamParser struct {
// contains filtered or unexported fields
}
StreamParser handles parsing of streaming responses
func NewStreamParser ¶
func NewStreamParser(parser *Parser) *StreamParser
NewStreamParser creates a new streaming parser
func (*StreamParser) ParseChunk ¶
func (sp *StreamParser) ParseChunk(chunk string) *ParseResult
ParseChunk parses a streaming chunk
Click to show internal directories.
Click to hide internal directories.