Documentation
¶
Index ¶
- type Config
- type EmbedModel
- type GenModel
- type Generator
- func (g *Generator) AddTools(tool ...tools.Tool) *Generator
- func (b *Generator) MaxTokens(maxTokens int) *Generator
- func (b *Generator) Model(model GenModel) *Generator
- func (b *Generator) Prompt(prompts ...prompt.Prompt) (Response, error)
- func (b *Generator) SetConfig(config Config) *Generator
- func (b *Generator) SetLogger(log *slog.Logger) *Generator
- func (b *Generator) SetOutputSchema(element any) *Generator
- func (b *Generator) SetToolConfig(tool tools.Tool) *Generator
- func (b *Generator) SetTools(tool ...tools.Tool) *Generator
- func (b *Generator) StopAt(stop ...string) *Generator
- func (b *Generator) System(prompt string) *Generator
- func (b *Generator) Temperature(temperature float64) *Generator
- func (g *Generator) Tools() []tools.Tool
- func (b *Generator) TopP(topP float64) *Generator
- type GeneratorOption
- func WithConfig(config Config) GeneratorOption
- func WithMaxTokens(maxTokens int) GeneratorOption
- func WithModel(model GenModel) GeneratorOption
- func WithOutput(element any) GeneratorOption
- func WithStopAt(stop ...string) GeneratorOption
- func WithSystem(prompt string) GeneratorOption
- func WithTemperature(temperature float64) GeneratorOption
- func WithToolConfig(tool tools.Tool) GeneratorOption
- func WithTools(tools ...tools.Tool) GeneratorOption
- func WithTopP(topP float64) GeneratorOption
- type LLM
- type Prompter
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.2.0
type Config struct {
Model GenModel
SystemPrompt string `json:"system_prompt"`
StopSequences []string `json:"stop_sequences"`
TopP float64 `json:"top_p"`
Temperature float64 `json:"temperature"`
MaxTokens int `json:"max_tokens"`
OutputSchema *schema.JSON `json:"output_schema"`
Tools []tools.Tool `json:"tools"`
ToolConfig *tools.Tool `json:"tool"`
Log *slog.Logger `json:"-"`
}
type EmbedModel ¶
type GenModel ¶
type GenModel struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
InputContentTypes []string `json:"input_content_types,omitempty"`
InputMaxToken int `json:"input_max_token,omitempty"`
OutputMaxToken int `json:"output_max_token,omitempty"`
SupportTools bool `json:"support_tools,omitempty"`
SupportStructuredOutput bool `json:"support_structured_output,omitempty"`
}
type Generator ¶
func (*Generator) SetOutputSchema ¶ added in v0.2.0
func (*Generator) SetToolConfig ¶ added in v0.1.0
func (*Generator) Temperature ¶
type GeneratorOption ¶
func WithConfig ¶ added in v0.2.0
func WithConfig(config Config) GeneratorOption
func WithMaxTokens ¶
func WithMaxTokens(maxTokens int) GeneratorOption
func WithModel ¶
func WithModel(model GenModel) GeneratorOption
func WithOutput ¶
func WithOutput(element any) GeneratorOption
func WithStopAt ¶
func WithStopAt(stop ...string) GeneratorOption
func WithSystem ¶
func WithSystem(prompt string) GeneratorOption
func WithTemperature ¶
func WithTemperature(temperature float64) GeneratorOption
func WithToolConfig ¶ added in v0.1.0
func WithToolConfig(tool tools.Tool) GeneratorOption
func WithTools ¶
func WithTools(tools ...tools.Tool) GeneratorOption
func WithTopP ¶
func WithTopP(topP float64) GeneratorOption
type LLM ¶
type LLM interface {
Generator(options ...GeneratorOption) Generator
}
type Response ¶
type Response interface {
IsText() bool
IsTools() bool
// AsText will return the response as a string and an error if no response exist
// is the response is json, it will be present in this string
AsText() (string, error)
// AsTools will return the name of the tool to use, the argument to pass to the tool, in json format form specified schema, and an error if the response is not a tool
AsTools() ([]tools.Call, error)
// Eval will run the callback associated with a tool response, otherwise it will return an error
Eval() (err error)
// Unmarshal will unmarshal the response into the provided reference
Unmarshal(ref any) error
}
Click to show internal directories.
Click to hide internal directories.