Documentation
¶
Index ¶
- type BaseChain
- func (bc *BaseChain) CreatePromptTemplate() *prompts.PromptTemplate
- func (bc *BaseChain) GetChainType() ChainType
- func (bc *BaseChain) GetFormatInstructions() string
- func (bc *BaseChain) GetMaxTokens() int
- func (bc *BaseChain) GetModel() llms.Model
- func (bc *BaseChain) GetOptimalTemperature() float64
- func (bc *BaseChain) GetOutputParser() schema.OutputParser[any]
- func (bc *BaseChain) GetParamDefinition() []string
- func (bc *BaseChain) GetResponseSchemas() []outputparser.ResponseSchema
- func (bc *BaseChain) GetTemperature() float64
- func (bc *BaseChain) GetTemplateText() string
- func (bc *BaseChain) IsStructured() bool
- func (bc *BaseChain) NewLLMChain(llm llms.Model, memory schema.Memory) chains.LLMChain
- func (bc *BaseChain) SetChainType(chainType ChainType)
- func (bc *BaseChain) ValidateStructuredResponse(response map[string]any) error
- type BaseOutputParser
- type ChainBuilder
- func (cb *ChainBuilder) Build() (*BaseChain, error)
- func (cb *ChainBuilder) WithCustomJSONFormat() *ChainBuilder
- func (cb *ChainBuilder) WithJSON(isJson bool) *ChainBuilder
- func (cb *ChainBuilder) WithMaxTokens(tokens int) *ChainBuilder
- func (cb *ChainBuilder) WithModel(provider llmmodels.Provider, model string) *ChainBuilder
- func (cb *ChainBuilder) WithParams(params []string) *ChainBuilder
- func (cb *ChainBuilder) WithStructuredOutput(schemas []outputparser.ResponseSchema) *ChainBuilder
- func (cb *ChainBuilder) WithTemperature(temp float64) *ChainBuilder
- func (cb *ChainBuilder) WithTemplate(template string) *ChainBuilder
- type ChainFactory
- type ChainType
- type OutputParserConfig
- type RawStringParser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseChain ¶
type BaseChain struct {
// contains filtered or unexported fields
}
BaseChain provides common functionality for all chains.
func NewBaseChain ¶
func NewBaseChain(templateText string, paramDefinition []string, formatInstructions string, maxTokens int, temperature float64, provider llmmodels.Provider, model string) (*BaseChain, error)
NewBaseChain creates a standard BaseChain.
func NewStructuredChain ¶
func NewStructuredChain( templateText string, paramDefinition []string, responseSchemas []outputparser.ResponseSchema, formatInstrLLMWithNoJSONSupport string, maxTokens int, temperature float64, provider llmmodels.Provider, model string, ) (*BaseChain, error)
NewStructuredChain creates a BaseChain with structured or custom JSON output parsing.
func (*BaseChain) CreatePromptTemplate ¶
func (bc *BaseChain) CreatePromptTemplate() *prompts.PromptTemplate
CreatePromptTemplate creates the appropriate prompt template based on chain type.
func (*BaseChain) GetChainType ¶
func (*BaseChain) GetFormatInstructions ¶
GetFormatInstructions returns the format instructions for the chain.
func (*BaseChain) GetMaxTokens ¶
func (*BaseChain) GetOptimalTemperature ¶
GetOptimalTemperature returns the optimal temperature for the chain type.
func (*BaseChain) GetOutputParser ¶
func (bc *BaseChain) GetOutputParser() schema.OutputParser[any]
func (*BaseChain) GetParamDefinition ¶
func (*BaseChain) GetResponseSchemas ¶
func (bc *BaseChain) GetResponseSchemas() []outputparser.ResponseSchema
func (*BaseChain) GetTemperature ¶
func (*BaseChain) IsStructured ¶
func (*BaseChain) NewLLMChain ¶
NewLLMChain creates a new LLMChain with common configuration.
func (*BaseChain) SetChainType ¶
type BaseOutputParser ¶
type BaseOutputParser struct {
// contains filtered or unexported fields
}
BaseOutputParser provides common functionality for all parsers
func (*BaseOutputParser) GetFormat ¶
func (p *BaseOutputParser) GetFormat() string
func (*BaseOutputParser) GetFormatInstructions ¶
func (p *BaseOutputParser) GetFormatInstructions() string
func (*BaseOutputParser) ParseWithPrompt ¶
func (p *BaseOutputParser) ParseWithPrompt(text string, _ llms.PromptValue) (any, error)
func (*BaseOutputParser) Type ¶
func (p *BaseOutputParser) Type() string
type ChainBuilder ¶
type ChainBuilder struct {
// contains filtered or unexported fields
}
ChainBuilder provides a fluent interface for building chains.
func NewChainBuilder ¶
func NewChainBuilder() *ChainBuilder
NewChainBuilder creates a new chain builder.
func (*ChainBuilder) Build ¶
func (cb *ChainBuilder) Build() (*BaseChain, error)
func (*ChainBuilder) WithCustomJSONFormat ¶
func (cb *ChainBuilder) WithCustomJSONFormat() *ChainBuilder
func (*ChainBuilder) WithJSON ¶
func (cb *ChainBuilder) WithJSON(isJson bool) *ChainBuilder
func (*ChainBuilder) WithMaxTokens ¶
func (cb *ChainBuilder) WithMaxTokens(tokens int) *ChainBuilder
func (*ChainBuilder) WithModel ¶
func (cb *ChainBuilder) WithModel(provider llmmodels.Provider, model string) *ChainBuilder
func (*ChainBuilder) WithParams ¶
func (cb *ChainBuilder) WithParams(params []string) *ChainBuilder
func (*ChainBuilder) WithStructuredOutput ¶
func (cb *ChainBuilder) WithStructuredOutput(schemas []outputparser.ResponseSchema) *ChainBuilder
func (*ChainBuilder) WithTemperature ¶
func (cb *ChainBuilder) WithTemperature(temp float64) *ChainBuilder
func (*ChainBuilder) WithTemplate ¶
func (cb *ChainBuilder) WithTemplate(template string) *ChainBuilder
type ChainFactory ¶
type ChainFactory struct {
// contains filtered or unexported fields
}
ChainFactory creates different types of chains
func NewChainFactory ¶
func NewChainFactory(memory schema.Memory) *ChainFactory
type OutputParserConfig ¶
type OutputParserConfig struct {
FormatInstructions string
}
type RawStringParser ¶
type RawStringParser struct{}
RawStringParser is an output parser that returns the input text as-is.
func NewRawStringParser ¶
func NewRawStringParser() *RawStringParser
NewRawStringParser creates a new RawStringParser.
func (*RawStringParser) GetFormatInstructions ¶
func (p *RawStringParser) GetFormatInstructions() string
GetFormatInstructions returns an empty string.
func (*RawStringParser) Parse ¶
func (p *RawStringParser) Parse(text string) (any, error)
Parse returns the input text.
func (*RawStringParser) ParseWithPrompt ¶
func (p *RawStringParser) ParseWithPrompt(text string, prompt llms.PromptValue) (any, error)
ParseWithPrompt returns the input text.
func (*RawStringParser) Type ¶
func (p *RawStringParser) Type() string
Type returns the type of the parser.