llm

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultConfig

func SetDefaultConfig(cfg Config)

SetDefaultConfig sets the instance-wide LLM settings (the `llm` block of the configuration). Fields an agent leaves empty fall back to them.

Types

type Client

type Client interface {
	Chat(ctx context.Context, messages []Message, opts ...Option) (*Response, error)
}

Client is the interface that all LLM providers must implement.

func NewAdapter

func NewAdapter(cfg Config) (Client, error)

NewAdapter creates a new `Client` by wrapping the specified LLM provider. Empty fields are filled from SetDefaultConfig.

type Config

type Config = config.LLMConfig

Config represents the LLM configuration, likely from your agent model.

type Message

type Message struct {
	Role       Role           `json:"role"`
	Content    string         `json:"content"`
	ToolCallID string         `json:"tool_call_id,omitempty"`
	ToolCall   *llms.ToolCall `json:"tool_call,omitempty"`
}

Message represents a single message in a conversation.

type Option

type Option func(*options)

Option is a functional option for the Chat method.

func WithToolChoice

func WithToolChoice(choice any) Option

WithToolChoice sets the tool choice option for the LLM call.

func WithTools

func WithTools(tools []llms.Tool) Option

type Provider

type Provider string

Provider represents the LLM provider.

const (
	ProviderOpenAI    Provider = "openai"
	ProviderAnthropic Provider = "anthropic"
	ProviderOllama    Provider = "ollama"
)

type Response

type Response struct {
	Type     ResponseType
	Content  string
	ToolCall *llms.ToolCall
}

Response represents the output from an LLM chat call.

type ResponseType

type ResponseType string

ResponseType indicates the type of the LLM's response.

const (
	ResponseTypeText     ResponseType = "text"
	ResponseTypeToolCall ResponseType = "tool_call"
)

type Role

type Role string

Role represents the role of a message sender.

const (
	RoleSystem    Role = "system"
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
	RoleTool      Role = "tool"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL