Documentation
¶
Index ¶
- type ErrorUpdate
- type LLM
- func (l *LLM) AddTool(t tools.Tool)
- func (l *LLM) Chat(message string) <-chan Update
- func (l *LLM) ChatUsingContent(ctx context.Context, message content.Content) <-chan Update
- func (l *LLM) ChatWithContext(ctx context.Context, message string) <-chan Update
- func (l *LLM) SetDebug(enabled bool)
- func (l *LLM) TotalCost() float64
- type Message
- type Provider
- type ProviderStream
- type StreamStatus
- type TextUpdate
- type ToolCall
- type ToolDoneUpdate
- type ToolStartUpdate
- type ToolStatusUpdate
- type Update
- type UpdateType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorUpdate ¶
type ErrorUpdate struct {
Error error
}
func (ErrorUpdate) Type ¶
func (u ErrorUpdate) Type() UpdateType
type LLM ¶
type LLM struct { // SystemPrompt should return the system prompt for the LLM. It's a function // to allow the system prompt to dynamically change throughout a single // conversation. SystemPrompt func() content.Content // contains filtered or unexported fields }
func (*LLM) Chat ¶
Chat sends a text message to the LLM and immediately returns a channel over which updates will come in. The LLM will use the tools available and keep generating more messages until it's done using tools.
func (*LLM) ChatUsingContent ¶
ChatUsingContent sends a message (which can contain images) to the LLM and immediately returns a channel over which updates will come in. The LLM will use the tools available and keep generating more messages until it's done using tools. The provided context can be used to pass values to tools, set deadlines, cancel, etc.
func (*LLM) ChatWithContext ¶
ChatWithContext sends a text message to the LLM and immediately returns a channel over which updates will come in. The LLM will use the tools available and keep generating more messages until it's done using tools. The provided context can be used to pass values to tools, set deadlines, cancel, etc.
type Message ¶
type Message struct { // Role can be "system", "user", "assistant", or "tool". Role string // Name can be used to identify different identities within the same role. Name string // Content is the message content. Content content.Content // ToolCalls is the list of tool calls that this message is part of. ToolCalls []ToolCall // ToolCallID is the ID of the tool call that this message is part of. ToolCallID string }
type ProviderStream ¶
type StreamStatus ¶
type StreamStatus int
const ( // StreamStatusNone means either the stream hasn't started, or it has finished. StreamStatusNone StreamStatus = iota // StreamStatusText means the stream produced more text content. StreamStatusText // StreamStatusToolCallBegin means the stream started a tool call. The name of the function is available, but not the arguments. StreamStatusToolCallBegin // StreamStatusToolCallData means the stream is streaming the arguments for a tool call. StreamStatusToolCallData // StreamStatusToolCallReady means the stream finished streaming the arguments for a tool call. StreamStatusToolCallReady )
type TextUpdate ¶
type TextUpdate struct {
Text string
}
func (TextUpdate) Type ¶
func (u TextUpdate) Type() UpdateType
type ToolDoneUpdate ¶
func (ToolDoneUpdate) Type ¶
func (u ToolDoneUpdate) Type() UpdateType
type ToolStartUpdate ¶
func (ToolStartUpdate) Type ¶
func (u ToolStartUpdate) Type() UpdateType
type ToolStatusUpdate ¶
func (ToolStatusUpdate) Type ¶
func (u ToolStatusUpdate) Type() UpdateType
type Update ¶
type Update interface {
Type() UpdateType
}
type UpdateType ¶
type UpdateType string
const ( UpdateTypeToolStart UpdateType = "tool_start" UpdateTypeToolStatus UpdateType = "tool_status" UpdateTypeToolDone UpdateType = "tool_done" UpdateTypeError UpdateType = "error" UpdateTypeText UpdateType = "text" )