Documentation
¶
Index ¶
- Constants
- func Close(llm LLM) error
- func GenerateStrictJSONSchema(t reflect.Type) map[string]interface{}
- func Label(llm LLM) string
- func Model(llm LLM) string
- func ParseFunctionArguments(jsonArguments string) (map[string]any, error)
- func Prewarm(llm LLM)
- func Provider(llm LLM) string
- func RealtimeLabel(model RealtimeModel) string
- func RealtimeModelName(model RealtimeModel) string
- func RealtimeProvider(model RealtimeModel) string
- func StripThinkingTokens(content string, thinking *bool) (string, bool)
- func ToXML(tagName string, content string, attrs map[string]any) string
- func ToolHasFlag(tool Tool, flag ToolFlag) bool
- func ToolParameters(tool Tool) map[string]any
- type APIConnectOptions
- type APIConnectionError
- type APIError
- type APIStatusError
- func CreateAPIErrorFromHTTP(message string, statusCode int, requestID string, body any) *APIStatusError
- func NewAPIStatusError(message string, statusCode int, requestID string, body any) *APIStatusError
- func NewAPIStatusErrorWithRetryable(message string, statusCode int, requestID string, body any, retryable bool) *APIStatusError
- type APITimeoutError
- type AgentConfigUpdate
- type AgentHandoff
- type AudioContent
- type ChatChunk
- type ChatContent
- type ChatContext
- func (c *ChatContext) AddMessage(args ChatMessageArgs) *ChatMessage
- func (c *ChatContext) Append(item ChatItem)
- func (c *ChatContext) Copy(options ...ChatContextCopyOptions) *ChatContext
- func (*ChatContext) Empty() *ChatContext
- func (c *ChatContext) FindInsertionIndex(createdAt time.Time) int
- func (c *ChatContext) FromDict(data map[string]any) error
- func (c *ChatContext) GetByID(itemID string) ChatItem
- func (c *ChatContext) GetToolNames(tools []interface{}) []string
- func (c *ChatContext) IndexByID(itemID string) *int
- func (c *ChatContext) Insert(items ...ChatItem)
- func (c *ChatContext) IsEquivalent(other *ChatContext) bool
- func (c *ChatContext) MarshalJSON() ([]byte, error)
- func (c *ChatContext) Merge(other *ChatContext, options ...ChatContextMergeOptions) *ChatContext
- func (c *ChatContext) Messages() []*ChatMessage
- func (c *ChatContext) ReadOnly() *ChatContext
- func (c *ChatContext) Readonly() bool
- func (c *ChatContext) Summarize(ctx context.Context, llm LLM, options ...ChatContextSummarizeOptions) (*ChatContext, error)
- func (c *ChatContext) ToDict(options ...ChatContextDictOptions) map[string]any
- func (c *ChatContext) ToProviderFormat(format string, options ...ChatContextProviderFormatOptions) ([]map[string]any, any)
- func (c *ChatContext) ToProviderFormatE(format string, options ...ChatContextProviderFormatOptions) ([]map[string]any, any, error)
- func (c *ChatContext) Truncate(maxItems int) *ChatContext
- func (c *ChatContext) UnmarshalJSON(data []byte) error
- func (c *ChatContext) UpsertItem(item ChatItem, options ...ChatContextUpsertOptions) error
- type ChatContextCopyOptions
- type ChatContextDictOptions
- type ChatContextMergeOptions
- type ChatContextProviderFormatOptions
- type ChatContextSummarizeOptions
- type ChatContextUpsertOptions
- type ChatItem
- type ChatMessage
- type ChatMessageArgs
- type ChatOption
- func WithConnectOptions(options APIConnectOptions) ChatOption
- func WithExtraParams(params map[string]any) ChatOption
- func WithParallelToolCalls(parallel bool) ChatOption
- func WithResponseFormat(format map[string]any) ChatOption
- func WithToolChoice(choice ToolChoice) ChatOption
- func WithTools(tools []Tool) ChatOption
- type ChatOptions
- type ChatRole
- type ChoiceDelta
- type CollectedResponse
- type CompletionUsage
- type DiffOps
- type ErrorEmitter
- type FallbackAdapter
- func (f *FallbackAdapter) AvailabilityChangedCh() <-chan FallbackAvailabilityChangedEvent
- func (f *FallbackAdapter) Chat(ctx context.Context, chatCtx *ChatContext, opts ...ChatOption) (LLMStream, error)
- func (f *FallbackAdapter) Close() error
- func (f *FallbackAdapter) Label() string
- func (f *FallbackAdapter) Model() string
- func (f *FallbackAdapter) OnAvailabilityChanged(handler FallbackAvailabilityChangedHandler) func()
- func (f *FallbackAdapter) OnError(handler LLMErrorHandler) func()
- func (f *FallbackAdapter) OnMetricsCollected(handler LLMMetricsHandler) func()
- func (f *FallbackAdapter) Prewarm()
- func (f *FallbackAdapter) Provider() string
- type FallbackAdapterOptions
- type FallbackAllFailedError
- type FallbackAvailabilityChangedEvent
- type FallbackAvailabilityChangedHandler
- type FunctionCall
- type FunctionCallOutput
- type FunctionCallResult
- func ExecuteFunctionCall(ctx context.Context, toolCall *FunctionToolCall, toolCtx *ToolContext) FunctionCallResult
- func MakeFunctionCallOutput(fncCall FunctionCall, output any, exception error) FunctionCallResult
- func MakeToolOutput(fncCall FunctionCall, output any, exception error) FunctionCallResult
- type FunctionToolCall
- type GenerationCreatedEvent
- type ImageContent
- type InputSpeechStoppedEvent
- type InputTranscriptionCompleted
- type Instructions
- func (i *Instructions) AppendString(suffix string) *Instructions
- func (i *Instructions) AsModality(modality string) *Instructions
- func (i *Instructions) Concat(other *Instructions) *Instructions
- func (i *Instructions) Format(args ...any) *Instructions
- func (i *Instructions) MarshalJSON() ([]byte, error)
- func (i *Instructions) PrependString(prefix string) *Instructions
- func (i *Instructions) String() string
- type LLM
- type LLMError
- type LLMErrorHandler
- type LLMMetricsHandler
- type LLMStream
- type MCPServer
- type MCPServerHTTP
- func (s *MCPServerHTTP) Close() error
- func (s *MCPServerHTTP) Initialize(ctx context.Context) error
- func (s *MCPServerHTTP) Initialized() bool
- func (s *MCPServerHTTP) InvalidateCache()
- func (s *MCPServerHTTP) ListTools(ctx context.Context) ([]Tool, error)
- func (s *MCPServerHTTP) SetHTTPClient(client *http.Client)
- func (s *MCPServerHTTP) SetHeaders(headers map[string]string)
- type MCPServerStdio
- type MCPToolset
- type MessageGeneration
- type MetricsEmitter
- type MetricsReport
- type ProviderTool
- type RealtimeCapabilities
- type RealtimeError
- type RealtimeEvent
- type RealtimeEventType
- type RealtimeGenerateReplyOptions
- type RealtimeModel
- type RealtimeModelError
- type RealtimeSession
- type RealtimeSessionOptions
- type RealtimeSessionReconnectedEvent
- type RealtimeTimedText
- type RealtimeTruncateOptions
- type RemoteChatContext
- type RemoteItemAddedEvent
- type SerializedImage
- type StopResponse
- type TextStream
- type Tool
- type ToolChoice
- type ToolContext
- func (c *ToolContext) AddTool(tool interface{}) error
- func (c *ToolContext) Close() error
- func (c *ToolContext) Copy() *ToolContext
- func (*ToolContext) Empty() *ToolContext
- func (c *ToolContext) Equal(other *ToolContext) bool
- func (c *ToolContext) Flatten() []Tool
- func (c *ToolContext) FunctionTools() map[string]Tool
- func (c *ToolContext) GetFunctionTool(name string) Tool
- func (c *ToolContext) ProviderTools() []ProviderTool
- func (c *ToolContext) SyncFlattened(tools []Tool) error
- func (c *ToolContext) Toolsets() []Toolset
- func (c *ToolContext) UpdateTools(tools []interface{}) error
- type ToolDuplicateMode
- type ToolDuplicateModer
- type ToolError
- type ToolFlag
- type ToolFlagger
- type Toolset
Constants ¶
View Source
const ConfirmDuplicateParam = "lk_agents_confirm_duplicate"
Variables ¶
This section is empty.
Functions ¶
func GenerateStrictJSONSchema ¶
GenerateStrictJSONSchema inspects a Go function or struct to generate an OpenAI-compatible "strict" JSON schema. It enforces additionalProperties: false and makes all fields required. Optional tags are represented by adding null to the field's type.
func ParseFunctionArguments ¶ added in v0.0.15
func RealtimeLabel ¶ added in v0.0.15
func RealtimeLabel(model RealtimeModel) string
func RealtimeModelName ¶ added in v0.0.15
func RealtimeModelName(model RealtimeModel) string
func RealtimeProvider ¶ added in v0.0.15
func RealtimeProvider(model RealtimeModel) string
func StripThinkingTokens ¶ added in v0.0.15
func ToolHasFlag ¶ added in v0.0.18
func ToolParameters ¶ added in v0.0.52
ToolParameters returns the JSON schema advertised for a tool, including reference-compatible runtime parameters that are stripped before execution.
Types ¶
type APIConnectOptions ¶ added in v0.0.15
func DefaultAPIConnectOptions ¶ added in v0.0.15
func DefaultAPIConnectOptions() APIConnectOptions
func (APIConnectOptions) IntervalForRetry ¶ added in v0.0.15
func (o APIConnectOptions) IntervalForRetry(numRetries int) time.Duration
func (APIConnectOptions) Validate ¶ added in v0.0.15
func (o APIConnectOptions) Validate() error
type APIConnectionError ¶ added in v0.0.15
type APIConnectionError struct {
*APIError
}
func NewAPIConnectionError ¶ added in v0.0.15
func NewAPIConnectionError(message string) *APIConnectionError
func NewAPIConnectionErrorWithRetryable ¶ added in v0.0.15
func NewAPIConnectionErrorWithRetryable(message string, retryable bool) *APIConnectionError
func (*APIConnectionError) Unwrap ¶ added in v0.0.15
func (e *APIConnectionError) Unwrap() error
type APIError ¶ added in v0.0.15
func NewAPIError ¶ added in v0.0.15
type APIStatusError ¶ added in v0.0.15
func CreateAPIErrorFromHTTP ¶ added in v0.0.15
func CreateAPIErrorFromHTTP(message string, statusCode int, requestID string, body any) *APIStatusError
func NewAPIStatusError ¶ added in v0.0.15
func NewAPIStatusError(message string, statusCode int, requestID string, body any) *APIStatusError
func NewAPIStatusErrorWithRetryable ¶ added in v0.0.15
func (*APIStatusError) Error ¶ added in v0.0.52
func (e *APIStatusError) Error() string
func (*APIStatusError) Unwrap ¶ added in v0.0.15
func (e *APIStatusError) Unwrap() error
type APITimeoutError ¶ added in v0.0.15
type APITimeoutError struct {
*APIConnectionError
}
func NewAPITimeoutError ¶ added in v0.0.15
func NewAPITimeoutError(message string) *APITimeoutError
func NewAPITimeoutErrorWithRetryable ¶ added in v0.0.15
func NewAPITimeoutErrorWithRetryable(message string, retryable bool) *APITimeoutError
func (*APITimeoutError) Unwrap ¶ added in v0.0.15
func (e *APITimeoutError) Unwrap() error
type AgentConfigUpdate ¶
type AgentConfigUpdate struct {
ID string
Instructions *string
InstructionVariants *Instructions
ToolsAdded []string
ToolsRemoved []string
CreatedAt time.Time
}
func (*AgentConfigUpdate) GetCreatedAt ¶
func (a *AgentConfigUpdate) GetCreatedAt() time.Time
func (*AgentConfigUpdate) GetID ¶
func (a *AgentConfigUpdate) GetID() string
func (*AgentConfigUpdate) GetType ¶
func (a *AgentConfigUpdate) GetType() string
func (*AgentConfigUpdate) MarshalJSON ¶ added in v0.0.52
func (a *AgentConfigUpdate) MarshalJSON() ([]byte, error)
type AgentHandoff ¶
func (*AgentHandoff) GetCreatedAt ¶
func (a *AgentHandoff) GetCreatedAt() time.Time
func (*AgentHandoff) GetID ¶
func (a *AgentHandoff) GetID() string
func (*AgentHandoff) GetType ¶
func (a *AgentHandoff) GetType() string
func (*AgentHandoff) MarshalJSON ¶ added in v0.0.52
func (a *AgentHandoff) MarshalJSON() ([]byte, error)
type AudioContent ¶
func (*AudioContent) MarshalJSON ¶ added in v0.0.52
func (a *AudioContent) MarshalJSON() ([]byte, error)
type ChatChunk ¶
type ChatChunk struct {
ID string
Delta *ChoiceDelta
Usage *CompletionUsage
}
func (ChatChunk) MarshalJSON ¶ added in v0.0.52
func (*ChatChunk) UnmarshalJSON ¶ added in v0.0.52
type ChatContent ¶
type ChatContent struct {
Text string
Image *ImageContent
Audio *AudioContent
Instructions *Instructions
}
type ChatContext ¶
type ChatContext struct {
Items []ChatItem
// contains filtered or unexported fields
}
func ChatContextFromDict ¶ added in v0.0.15
func ChatContextFromDict(data map[string]any) (*ChatContext, error)
func EmptyChatContext ¶ added in v0.0.15
func EmptyChatContext() *ChatContext
func NewChatContext ¶
func NewChatContext() *ChatContext
func (*ChatContext) AddMessage ¶ added in v0.0.15
func (c *ChatContext) AddMessage(args ChatMessageArgs) *ChatMessage
func (*ChatContext) Append ¶
func (c *ChatContext) Append(item ChatItem)
func (*ChatContext) Copy ¶
func (c *ChatContext) Copy(options ...ChatContextCopyOptions) *ChatContext
func (*ChatContext) Empty ¶ added in v0.0.15
func (*ChatContext) Empty() *ChatContext
func (*ChatContext) FindInsertionIndex ¶
func (c *ChatContext) FindInsertionIndex(createdAt time.Time) int
func (*ChatContext) FromDict ¶ added in v0.0.15
func (c *ChatContext) FromDict(data map[string]any) error
func (*ChatContext) GetByID ¶ added in v0.0.15
func (c *ChatContext) GetByID(itemID string) ChatItem
func (*ChatContext) GetToolNames ¶ added in v0.0.15
func (c *ChatContext) GetToolNames(tools []interface{}) []string
func (*ChatContext) IndexByID ¶ added in v0.0.15
func (c *ChatContext) IndexByID(itemID string) *int
func (*ChatContext) Insert ¶ added in v0.0.15
func (c *ChatContext) Insert(items ...ChatItem)
func (*ChatContext) IsEquivalent ¶ added in v0.0.15
func (c *ChatContext) IsEquivalent(other *ChatContext) bool
func (*ChatContext) MarshalJSON ¶ added in v0.0.15
func (c *ChatContext) MarshalJSON() ([]byte, error)
func (*ChatContext) Merge ¶
func (c *ChatContext) Merge(other *ChatContext, options ...ChatContextMergeOptions) *ChatContext
func (*ChatContext) Messages ¶
func (c *ChatContext) Messages() []*ChatMessage
func (*ChatContext) ReadOnly ¶ added in v0.0.15
func (c *ChatContext) ReadOnly() *ChatContext
func (*ChatContext) Readonly ¶ added in v0.0.15
func (c *ChatContext) Readonly() bool
func (*ChatContext) Summarize ¶ added in v0.0.15
func (c *ChatContext) Summarize(ctx context.Context, llm LLM, options ...ChatContextSummarizeOptions) (*ChatContext, error)
func (*ChatContext) ToDict ¶ added in v0.0.5
func (c *ChatContext) ToDict(options ...ChatContextDictOptions) map[string]any
func (*ChatContext) ToProviderFormat ¶
func (c *ChatContext) ToProviderFormat(format string, options ...ChatContextProviderFormatOptions) ([]map[string]any, any)
func (*ChatContext) ToProviderFormatE ¶ added in v0.0.15
func (c *ChatContext) ToProviderFormatE(format string, options ...ChatContextProviderFormatOptions) ([]map[string]any, any, error)
func (*ChatContext) Truncate ¶
func (c *ChatContext) Truncate(maxItems int) *ChatContext
func (*ChatContext) UnmarshalJSON ¶ added in v0.0.15
func (c *ChatContext) UnmarshalJSON(data []byte) error
func (*ChatContext) UpsertItem ¶ added in v0.0.15
func (c *ChatContext) UpsertItem(item ChatItem, options ...ChatContextUpsertOptions) error
type ChatContextCopyOptions ¶ added in v0.0.15
type ChatContextDictOptions ¶ added in v0.0.15
type ChatContextMergeOptions ¶ added in v0.0.15
type ChatContextProviderFormatOptions ¶ added in v0.0.15
type ChatContextSummarizeOptions ¶ added in v0.0.15
type ChatContextSummarizeOptions struct {
KeepLastTurns int
}
type ChatContextUpsertOptions ¶ added in v0.0.15
type ChatContextUpsertOptions struct {
AllowTypeMismatch bool
}
type ChatMessage ¶
type ChatMessage struct {
ID string
Role ChatRole
Content []ChatContent
Interrupted bool
TranscriptConfidence *float64
Extra map[string]any
Metrics map[string]any
CreatedAt time.Time
}
func FunctionCallItemToMessage ¶ added in v0.0.15
func FunctionCallItemToMessage(item ChatItem) *ChatMessage
func (*ChatMessage) GetCreatedAt ¶
func (m *ChatMessage) GetCreatedAt() time.Time
func (*ChatMessage) GetID ¶
func (m *ChatMessage) GetID() string
func (*ChatMessage) GetType ¶
func (m *ChatMessage) GetType() string
func (*ChatMessage) MarshalJSON ¶ added in v0.0.52
func (m *ChatMessage) MarshalJSON() ([]byte, error)
func (*ChatMessage) TextContent ¶
func (m *ChatMessage) TextContent() string
type ChatMessageArgs ¶ added in v0.0.15
type ChatOption ¶
type ChatOption func(*ChatOptions)
func WithConnectOptions ¶ added in v0.0.15
func WithConnectOptions(options APIConnectOptions) ChatOption
func WithExtraParams ¶ added in v0.0.15
func WithExtraParams(params map[string]any) ChatOption
func WithParallelToolCalls ¶
func WithParallelToolCalls(parallel bool) ChatOption
func WithResponseFormat ¶ added in v0.0.15
func WithResponseFormat(format map[string]any) ChatOption
func WithToolChoice ¶
func WithToolChoice(choice ToolChoice) ChatOption
func WithTools ¶
func WithTools(tools []Tool) ChatOption
type ChatOptions ¶
type ChatOptions struct {
Tools []Tool
ToolChoice ToolChoice
ParallelToolCalls bool
ParallelToolCallsSet bool
ConnectOptions *APIConnectOptions
ExtraParams map[string]any
ResponseFormat map[string]any
}
func (*ChatOptions) EffectiveConnectOptions ¶ added in v0.0.15
func (o *ChatOptions) EffectiveConnectOptions() (APIConnectOptions, error)
type ChoiceDelta ¶
type ChoiceDelta struct {
Role ChatRole
Content string
Flush bool
ToolCalls []FunctionToolCall
Extra map[string]any
}
func (ChoiceDelta) MarshalJSON ¶ added in v0.0.52
func (d ChoiceDelta) MarshalJSON() ([]byte, error)
func (*ChoiceDelta) UnmarshalJSON ¶ added in v0.0.52
func (d *ChoiceDelta) UnmarshalJSON(data []byte) error
type CollectedResponse ¶ added in v0.0.15
type CollectedResponse struct {
Text string
ToolCalls []FunctionToolCall
Usage *CompletionUsage
Extra map[string]any
}
func CollectStream ¶ added in v0.0.15
func CollectStream(stream LLMStream) (*CollectedResponse, error)
func (CollectedResponse) MarshalJSON ¶ added in v0.0.52
func (r CollectedResponse) MarshalJSON() ([]byte, error)
func (*CollectedResponse) UnmarshalJSON ¶ added in v0.0.52
func (r *CollectedResponse) UnmarshalJSON(data []byte) error
type CompletionUsage ¶
type CompletionUsage struct {
CompletionTokens int
PromptTokens int
PromptCachedTokens int
CacheCreationTokens int
CacheReadTokens int
TotalTokens int
ServiceTier string
}
func (CompletionUsage) MarshalJSON ¶ added in v0.0.52
func (u CompletionUsage) MarshalJSON() ([]byte, error)
func (*CompletionUsage) UnmarshalJSON ¶ added in v0.0.52
func (u *CompletionUsage) UnmarshalJSON(data []byte) error
type DiffOps ¶
type DiffOps struct {
ToRemove []string
ToCreate [][2]*string // [previous_item_id, id]
ToUpdate [][2]*string // [previous_item_id, id]
}
func ComputeChatCtxDiff ¶
func ComputeChatCtxDiff(oldCtx, newCtx *ChatContext) *DiffOps
type ErrorEmitter ¶ added in v0.0.15
type ErrorEmitter struct {
// contains filtered or unexported fields
}
func (*ErrorEmitter) EmitError ¶ added in v0.0.15
func (e *ErrorEmitter) EmitError(err *LLMError)
func (*ErrorEmitter) OnError ¶ added in v0.0.15
func (e *ErrorEmitter) OnError(handler LLMErrorHandler) func()
type FallbackAdapter ¶
type FallbackAdapter struct {
MetricsEmitter
ErrorEmitter
// contains filtered or unexported fields
}
func NewFallbackAdapter ¶
func NewFallbackAdapter(llms []LLM) *FallbackAdapter
func NewFallbackAdapterWithOptions ¶ added in v0.0.15
func NewFallbackAdapterWithOptions(llms []LLM, options FallbackAdapterOptions) *FallbackAdapter
func (*FallbackAdapter) AvailabilityChangedCh ¶ added in v0.0.15
func (f *FallbackAdapter) AvailabilityChangedCh() <-chan FallbackAvailabilityChangedEvent
func (*FallbackAdapter) Chat ¶
func (f *FallbackAdapter) Chat(ctx context.Context, chatCtx *ChatContext, opts ...ChatOption) (LLMStream, error)
func (*FallbackAdapter) Close ¶ added in v0.1.0
func (f *FallbackAdapter) Close() error
func (*FallbackAdapter) Label ¶ added in v0.0.15
func (f *FallbackAdapter) Label() string
func (*FallbackAdapter) Model ¶ added in v0.0.15
func (f *FallbackAdapter) Model() string
func (*FallbackAdapter) OnAvailabilityChanged ¶ added in v0.0.15
func (f *FallbackAdapter) OnAvailabilityChanged(handler FallbackAvailabilityChangedHandler) func()
func (*FallbackAdapter) OnError ¶ added in v0.0.15
func (f *FallbackAdapter) OnError(handler LLMErrorHandler) func()
func (*FallbackAdapter) OnMetricsCollected ¶ added in v0.0.15
func (f *FallbackAdapter) OnMetricsCollected(handler LLMMetricsHandler) func()
func (*FallbackAdapter) Prewarm ¶ added in v0.0.15
func (f *FallbackAdapter) Prewarm()
func (*FallbackAdapter) Provider ¶ added in v0.0.15
func (f *FallbackAdapter) Provider() string
type FallbackAdapterOptions ¶ added in v0.0.15
type FallbackAllFailedError ¶ added in v0.0.15
type FallbackAllFailedError struct {
Count int
Labels []string
Duration time.Duration
Err error
APIError *APIConnectionError
}
func (*FallbackAllFailedError) Error ¶ added in v0.0.15
func (e *FallbackAllFailedError) Error() string
func (*FallbackAllFailedError) Unwrap ¶ added in v0.0.15
func (e *FallbackAllFailedError) Unwrap() error
type FallbackAvailabilityChangedEvent ¶ added in v0.0.15
type FallbackAvailabilityChangedHandler ¶ added in v0.0.15
type FallbackAvailabilityChangedHandler func(FallbackAvailabilityChangedEvent)
type FunctionCall ¶
type FunctionCall struct {
ID string
CallID string
Name string
Arguments string
Extra map[string]any
GroupID *string
CreatedAt time.Time
}
func (*FunctionCall) GetCreatedAt ¶
func (f *FunctionCall) GetCreatedAt() time.Time
func (*FunctionCall) GetID ¶
func (f *FunctionCall) GetID() string
func (*FunctionCall) GetType ¶
func (f *FunctionCall) GetType() string
func (*FunctionCall) MarshalJSON ¶ added in v0.0.52
func (f *FunctionCall) MarshalJSON() ([]byte, error)
type FunctionCallOutput ¶
type FunctionCallOutput struct {
ID string
CallID string
Name string
Output string
IsError bool
CreatedAt time.Time
}
func (*FunctionCallOutput) GetCreatedAt ¶
func (f *FunctionCallOutput) GetCreatedAt() time.Time
func (*FunctionCallOutput) GetID ¶
func (f *FunctionCallOutput) GetID() string
func (*FunctionCallOutput) GetType ¶
func (f *FunctionCallOutput) GetType() string
func (*FunctionCallOutput) MarshalJSON ¶ added in v0.0.52
func (f *FunctionCallOutput) MarshalJSON() ([]byte, error)
type FunctionCallResult ¶ added in v0.0.15
type FunctionCallResult struct {
FncCall FunctionCall
FncCallOut *FunctionCallOutput
RawOutput any
RawError error
}
func ExecuteFunctionCall ¶ added in v0.0.15
func ExecuteFunctionCall(ctx context.Context, toolCall *FunctionToolCall, toolCtx *ToolContext) FunctionCallResult
func MakeFunctionCallOutput ¶ added in v0.0.15
func MakeFunctionCallOutput(fncCall FunctionCall, output any, exception error) FunctionCallResult
func MakeToolOutput ¶ added in v0.0.15
func MakeToolOutput(fncCall FunctionCall, output any, exception error) FunctionCallResult
type FunctionToolCall ¶
type FunctionToolCall struct {
ID string `json:"-"`
Type string
Name string
Arguments string
CallID string
Extra map[string]any
}
func (FunctionToolCall) MarshalJSON ¶ added in v0.0.52
func (c FunctionToolCall) MarshalJSON() ([]byte, error)
func (*FunctionToolCall) UnmarshalJSON ¶ added in v0.0.52
func (c *FunctionToolCall) UnmarshalJSON(data []byte) error
type GenerationCreatedEvent ¶ added in v0.0.15
type GenerationCreatedEvent struct {
MessageCh <-chan MessageGeneration
FunctionCh <-chan *FunctionCall
ResponseID string
UserInitiated bool
}
type ImageContent ¶
type ImageContent struct {
ID string
Image any
InferenceWidth *int
InferenceHeight *int
InferenceDetail string
MimeType string
}
func (*ImageContent) MarshalJSON ¶ added in v0.0.52
func (i *ImageContent) MarshalJSON() ([]byte, error)
type InputSpeechStoppedEvent ¶ added in v0.0.15
type InputSpeechStoppedEvent struct {
UserTranscriptionEnabled bool
}
type InputTranscriptionCompleted ¶ added in v0.0.15
type Instructions ¶ added in v0.0.15
func NewInstructions ¶ added in v0.0.15
func NewInstructions(audio string, text ...string) *Instructions
func (*Instructions) AppendString ¶ added in v0.0.15
func (i *Instructions) AppendString(suffix string) *Instructions
func (*Instructions) AsModality ¶ added in v0.0.15
func (i *Instructions) AsModality(modality string) *Instructions
func (*Instructions) Concat ¶ added in v0.0.15
func (i *Instructions) Concat(other *Instructions) *Instructions
func (*Instructions) Format ¶ added in v0.0.15
func (i *Instructions) Format(args ...any) *Instructions
func (*Instructions) MarshalJSON ¶ added in v0.0.52
func (i *Instructions) MarshalJSON() ([]byte, error)
func (*Instructions) PrependString ¶ added in v0.0.15
func (i *Instructions) PrependString(prefix string) *Instructions
func (*Instructions) String ¶ added in v0.0.15
func (i *Instructions) String() string
type LLM ¶
type LLM interface {
Chat(ctx context.Context, chatCtx *ChatContext, opts ...ChatOption) (LLMStream, error)
}
type LLMError ¶ added in v0.0.15
func NewLLMError ¶ added in v0.0.15
func (*LLMError) MarshalJSON ¶ added in v0.0.52
func (*LLMError) UnmarshalJSON ¶ added in v0.0.52
type LLMErrorHandler ¶ added in v0.0.15
type LLMErrorHandler func(*LLMError)
type LLMMetricsHandler ¶ added in v0.0.15
type LLMMetricsHandler func(*telemetry.LLMMetrics)
type MCPServerHTTP ¶
type MCPServerHTTP struct {
URL string
TransportType string
AllowedTools []string
Headers map[string]string
// contains filtered or unexported fields
}
func NewMCPServerHTTP ¶
func NewMCPServerHTTP(url string) *MCPServerHTTP
func (*MCPServerHTTP) Close ¶
func (s *MCPServerHTTP) Close() error
func (*MCPServerHTTP) Initialize ¶
func (s *MCPServerHTTP) Initialize(ctx context.Context) error
func (*MCPServerHTTP) Initialized ¶ added in v0.0.15
func (s *MCPServerHTTP) Initialized() bool
func (*MCPServerHTTP) InvalidateCache ¶ added in v0.0.15
func (s *MCPServerHTTP) InvalidateCache()
func (*MCPServerHTTP) ListTools ¶
func (s *MCPServerHTTP) ListTools(ctx context.Context) ([]Tool, error)
func (*MCPServerHTTP) SetHTTPClient ¶ added in v0.0.15
func (s *MCPServerHTTP) SetHTTPClient(client *http.Client)
func (*MCPServerHTTP) SetHeaders ¶ added in v0.0.15
func (s *MCPServerHTTP) SetHeaders(headers map[string]string)
type MCPServerStdio ¶
type MCPServerStdio struct {
Command string
Args []string
Env map[string]string
Cwd string
// contains filtered or unexported fields
}
func NewMCPServerStdio ¶
func NewMCPServerStdio(command string, args []string) *MCPServerStdio
func (*MCPServerStdio) Close ¶
func (s *MCPServerStdio) Close() error
func (*MCPServerStdio) Initialize ¶
func (s *MCPServerStdio) Initialize(ctx context.Context) error
func (*MCPServerStdio) Initialized ¶ added in v0.0.15
func (s *MCPServerStdio) Initialized() bool
func (*MCPServerStdio) InvalidateCache ¶ added in v0.0.15
func (s *MCPServerStdio) InvalidateCache()
type MCPToolset ¶ added in v0.0.15
type MCPToolset struct {
// contains filtered or unexported fields
}
func NewMCPToolset ¶ added in v0.0.15
func NewMCPToolset(id string, server MCPServer) *MCPToolset
func (*MCPToolset) Close ¶ added in v0.0.16
func (t *MCPToolset) Close() error
func (*MCPToolset) FilterTools ¶ added in v0.0.15
func (t *MCPToolset) FilterTools(filter func(Tool) bool) *MCPToolset
func (*MCPToolset) ID ¶ added in v0.0.15
func (t *MCPToolset) ID() string
func (*MCPToolset) Setup ¶ added in v0.0.15
func (t *MCPToolset) Setup(ctx context.Context, reload bool) (*MCPToolset, error)
func (*MCPToolset) Tools ¶ added in v0.0.15
func (t *MCPToolset) Tools() []Tool
type MessageGeneration ¶ added in v0.0.15
type MessageGeneration struct {
MessageID string
TextCh <-chan string
TimedTextCh <-chan RealtimeTimedText
AudioCh <-chan *model.AudioFrame
ModalitiesCh <-chan []string
}
type MetricsEmitter ¶ added in v0.0.15
type MetricsEmitter struct {
// contains filtered or unexported fields
}
func (*MetricsEmitter) EmitMetricsCollected ¶ added in v0.0.15
func (e *MetricsEmitter) EmitMetricsCollected(metrics *telemetry.LLMMetrics)
func (*MetricsEmitter) OnMetricsCollected ¶ added in v0.0.15
func (e *MetricsEmitter) OnMetricsCollected(handler LLMMetricsHandler) func()
type MetricsReport ¶
type MetricsReport struct {
Usage telemetry.UsageSummary
CreatedAt time.Time
}
func (*MetricsReport) GetCreatedAt ¶
func (m *MetricsReport) GetCreatedAt() time.Time
func (*MetricsReport) GetID ¶
func (m *MetricsReport) GetID() string
func (*MetricsReport) GetType ¶
func (m *MetricsReport) GetType() string
type ProviderTool ¶ added in v0.0.5
type RealtimeCapabilities ¶
type RealtimeCapabilities struct {
MessageTruncation bool
TurnDetection bool
UserTranscription bool
AutoToolReplyGeneration bool
AudioOutput bool
ManualFunctionCalls bool
MutableChatContext bool
MutableInstructions bool
MutableTools bool
PerResponseToolChoice bool
SupportsSay bool
}
func (RealtimeCapabilities) MarshalJSON ¶ added in v0.0.52
func (c RealtimeCapabilities) MarshalJSON() ([]byte, error)
func (*RealtimeCapabilities) UnmarshalJSON ¶ added in v0.0.52
func (c *RealtimeCapabilities) UnmarshalJSON(data []byte) error
type RealtimeError ¶ added in v0.0.15
func NewRealtimeError ¶ added in v0.0.15
func NewRealtimeError(message string, err error) RealtimeError
func (RealtimeError) Error ¶ added in v0.0.15
func (e RealtimeError) Error() string
func (RealtimeError) Unwrap ¶ added in v0.0.15
func (e RealtimeError) Unwrap() error
type RealtimeEvent ¶
type RealtimeEvent struct {
Type RealtimeEventType
ItemID string
ContentIndex int
Data []byte // For audio frames
Text string // For text deltas
TimedText *RealtimeTimedText
Function *FunctionToolCall
Generation *GenerationCreatedEvent
RemoteItem *RemoteItemAddedEvent
Reconnect *RealtimeSessionReconnectedEvent
InputTranscription *InputTranscriptionCompleted
SpeechStopped *InputSpeechStoppedEvent
Metrics *telemetry.RealtimeModelMetrics
Error error
}
type RealtimeEventType ¶
type RealtimeEventType string
const ( RealtimeEventTypeAudio RealtimeEventType = "audio" RealtimeEventTypeText RealtimeEventType = "text" RealtimeEventTypeFunctionCall RealtimeEventType = "function_call" RealtimeEventTypeSpeechStarted RealtimeEventType = "speech_started" RealtimeEventTypeSpeechStopped RealtimeEventType = "speech_stopped" RealtimeEventTypeInputAudioTranscriptionCompleted RealtimeEventType = "input_audio_transcription_completed" RealtimeEventTypeGenerationCreated RealtimeEventType = "generation_created" RealtimeEventTypeSessionReconnected RealtimeEventType = "session_reconnected" RealtimeEventTypeRemoteItemAdded RealtimeEventType = "remote_item_added" RealtimeEventTypeMetricsCollected RealtimeEventType = "metrics_collected" RealtimeEventTypeError RealtimeEventType = "error" )
type RealtimeGenerateReplyOptions ¶ added in v0.0.15
type RealtimeGenerateReplyOptions struct {
Instructions string
InstructionsSet bool
ToolChoice ToolChoice
Tools []Tool
}
type RealtimeModel ¶
type RealtimeModel interface {
Capabilities() RealtimeCapabilities
Session() (RealtimeSession, error)
Close() error
}
type RealtimeModelError ¶ added in v0.0.15
type RealtimeModelError struct {
Type string
Timestamp time.Time
Label string
Err error
Recoverable bool
}
func NewRealtimeModelError ¶ added in v0.0.15
func NewRealtimeModelError(label string, err error, recoverable bool) *RealtimeModelError
func (*RealtimeModelError) Error ¶ added in v0.0.15
func (e *RealtimeModelError) Error() string
func (*RealtimeModelError) MarshalJSON ¶ added in v0.0.52
func (e *RealtimeModelError) MarshalJSON() ([]byte, error)
func (*RealtimeModelError) UnmarshalJSON ¶ added in v0.0.52
func (e *RealtimeModelError) UnmarshalJSON(data []byte) error
func (*RealtimeModelError) Unwrap ¶ added in v0.0.15
func (e *RealtimeModelError) Unwrap() error
type RealtimeSession ¶
type RealtimeSession interface {
UpdateInstructions(instructions string) error
UpdateChatContext(chatCtx *ChatContext) error
UpdateTools(tools []Tool) error
UpdateOptions(options RealtimeSessionOptions) error
GenerateReply(options RealtimeGenerateReplyOptions) error
Say(text string) error
Truncate(options RealtimeTruncateOptions) error
Interrupt() error
Close() error
EventCh() <-chan RealtimeEvent
PushAudio(frame *model.AudioFrame) error
PushVideo(frame *images.VideoFrame) error
CommitAudio() error
ClearAudio() error
}
type RealtimeSessionOptions ¶ added in v0.0.15
type RealtimeSessionOptions struct {
ToolChoice ToolChoice
ToolChoiceSet bool
Voice string
VoiceSet bool
OutputMedium string
OutputMediumSet bool
Speed float64
SpeedSet bool
MaxResponseOutputTokens any
MaxResponseOutputTokensSet bool
Truncation any
TruncationSet bool
Tracing any
TracingSet bool
Reasoning any
ReasoningSet bool
TurnDetection any
TurnDetectionSet bool
InputAudioTranscription any
InputAudioTranscriptionSet bool
InputAudioNoiseReduction any
InputAudioNoiseReductionSet bool
}
type RealtimeSessionReconnectedEvent ¶ added in v0.0.15
type RealtimeSessionReconnectedEvent struct{}
type RealtimeTimedText ¶ added in v0.1.3
type RealtimeTruncateOptions ¶ added in v0.0.15
type RemoteChatContext ¶
type RemoteChatContext struct {
// contains filtered or unexported fields
}
func NewRemoteChatContext ¶
func NewRemoteChatContext() *RemoteChatContext
func (*RemoteChatContext) Delete ¶
func (c *RemoteChatContext) Delete(itemID string) error
func (*RemoteChatContext) Get ¶
func (c *RemoteChatContext) Get(itemID string) ChatItem
func (*RemoteChatContext) Insert ¶
func (c *RemoteChatContext) Insert(previousItemID *string, message ChatItem) error
func (*RemoteChatContext) ToChatCtx ¶
func (c *RemoteChatContext) ToChatCtx() *ChatContext
type RemoteItemAddedEvent ¶ added in v0.0.15
type SerializedImage ¶ added in v0.0.15
type SerializedImage struct {
InferenceDetail string
MIMEType string
DataBytes []byte
ExternalURL string
}
func SerializeImage ¶ added in v0.0.15
func SerializeImage(image *ImageContent) (*SerializedImage, error)
type StopResponse ¶ added in v0.0.15
type StopResponse struct{}
func (StopResponse) Error ¶ added in v0.0.15
func (s StopResponse) Error() string
type TextStream ¶ added in v0.0.15
type TextStream struct {
// contains filtered or unexported fields
}
func NewTextStream ¶ added in v0.0.15
func NewTextStream(stream LLMStream) (*TextStream, error)
func (*TextStream) Close ¶ added in v0.0.15
func (s *TextStream) Close() error
func (*TextStream) Next ¶ added in v0.0.15
func (s *TextStream) Next() (string, error)
type ToolChoice ¶
type ToolChoice any
type ToolContext ¶
type ToolContext struct {
// contains filtered or unexported fields
}
func EmptyToolContext ¶
func EmptyToolContext() *ToolContext
func NewToolContext ¶
func NewToolContext(tools []interface{}) *ToolContext
func (*ToolContext) AddTool ¶ added in v0.0.15
func (c *ToolContext) AddTool(tool interface{}) error
func (*ToolContext) Close ¶ added in v0.0.16
func (c *ToolContext) Close() error
func (*ToolContext) Copy ¶
func (c *ToolContext) Copy() *ToolContext
func (*ToolContext) Empty ¶ added in v0.0.15
func (*ToolContext) Empty() *ToolContext
func (*ToolContext) Equal ¶ added in v0.0.5
func (c *ToolContext) Equal(other *ToolContext) bool
func (*ToolContext) Flatten ¶
func (c *ToolContext) Flatten() []Tool
func (*ToolContext) FunctionTools ¶
func (c *ToolContext) FunctionTools() map[string]Tool
func (*ToolContext) GetFunctionTool ¶
func (c *ToolContext) GetFunctionTool(name string) Tool
func (*ToolContext) ProviderTools ¶
func (c *ToolContext) ProviderTools() []ProviderTool
func (*ToolContext) SyncFlattened ¶ added in v0.0.52
func (c *ToolContext) SyncFlattened(tools []Tool) error
func (*ToolContext) Toolsets ¶
func (c *ToolContext) Toolsets() []Toolset
func (*ToolContext) UpdateTools ¶
func (c *ToolContext) UpdateTools(tools []interface{}) error
type ToolDuplicateMode ¶ added in v0.0.52
type ToolDuplicateMode string
const ( ToolDuplicateModeAllow ToolDuplicateMode = "allow" ToolDuplicateModeReject ToolDuplicateMode = "reject" ToolDuplicateModeReplace ToolDuplicateMode = "replace" ToolDuplicateModeConfirm ToolDuplicateMode = "confirm" )
func ToolDuplicateModeFor ¶ added in v0.0.52
func ToolDuplicateModeFor(tool Tool) ToolDuplicateMode
type ToolDuplicateModer ¶ added in v0.0.52
type ToolDuplicateModer interface {
ToolDuplicateMode() ToolDuplicateMode
}
type ToolError ¶ added in v0.0.15
type ToolError struct {
Message string
}
func NewToolError ¶ added in v0.0.15
type ToolFlagger ¶ added in v0.0.18
type ToolFlagger interface {
ToolFlags() ToolFlag
}
Click to show internal directories.
Click to hide internal directories.