Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent interface {
// Return the name of the agent
Name() string
// Return the models
Models(context.Context) ([]Model, error)
// Generate a response from a prompt
Generate(context.Context, Model, []Context, ...Opt) (*Response, error)
// Create user message context
UserPrompt(string) Context
}
An LLM Agent is a client for the LLM service
type Context ¶
type Context interface {
Role() string
}
Context is fed to the agent to generate a response. Role can be assistant, user, tool, tool_result, ...
type Model ¶
type Model interface {
// Return the name of the model
Name() string
}
An LLM Agent is a client for the LLM service
type Opt ¶
type Response ¶
type Response struct {
Agent string `json:"agent,omitempty"` // The agent name
Model string `json:"model,omitempty"` // The model name
Context []Context `json:"context,omitempty"` // The context for the response
Text string `json:"text,omitempty"` // The response text
*ToolCall `json:"tool,omitempty"` // The tool call, if not nil
Tokens uint `json:"tokens,omitempty"` // The number of tokens
Duration time.Duration `json:"duration,omitempty"` // The response duration
}
type Tool ¶
type Tool interface {
// Return the provider of the tool
Provider() string
// Return the name of the tool
Name() string
// Return the description of the tool
Description() string
// Tool parameters
Params() []ToolParameter
// Execute the tool with a specific tool
Run(context.Context, *ToolCall) (*ToolResult, error)
}
A tool can be called from an LLM
type ToolCall ¶
type ToolCall struct {
Id string `json:"id"`
Name string `json:"name"`
Args map[string]any `json:"args"`
}
A call to a tool
type ToolParameter ¶
type ToolParameter struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
}
A tool parameter
type ToolResult ¶
The result of a tool call
Click to show internal directories.
Click to hide internal directories.