Documentation
¶
Index ¶
- Variables
- func IsContextTooLongMessage(message string) bool
- func IsInvalidRole(err error) bool
- func ValidateMessage(message Message) error
- func ValidatePart(part Part) error
- type AssetID
- type CapabilityRegistry
- type ChatRequest
- type Client
- type ErrorCode
- type FunctionDefinition
- type ImageAsset
- type ImagePartRef
- type InternalRequest
- type Message
- type MessageMeta
- type ModelCapabilities
- type Part
- type PartType
- type ProviderClient
- type ProviderError
- type Role
- type StreamEvent
- type StreamEventType
- type TextPart
- type ThinkingPart
- type ToolCall
- type ToolDefinition
- type ToolFunctionCall
- type ToolResultPart
- type ToolUsePart
- type Usage
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultModelCapabilities = NewCapabilityRegistry(map[string]ModelCapabilities{ "gpt-4o": {SupportsVision: true, SupportsToolUse: true, SupportsThinking: false}, "gpt-4.1": {SupportsVision: true, SupportsToolUse: true, SupportsThinking: false}, "gpt-5.4": {SupportsVision: true, SupportsToolUse: true, SupportsThinking: true}, "gpt-5.4-mini": {SupportsVision: true, SupportsToolUse: true, SupportsThinking: true}, "claude-sonnet-4": {SupportsVision: true, SupportsToolUse: true, SupportsThinking: true}, "qwen3.6-flash": {SupportsVision: true, SupportsToolUse: true, SupportsThinking: true}, "qwen3.6-plus": {SupportsVision: true, SupportsToolUse: true, SupportsThinking: true}, "qwen3.6-pro": {SupportsVision: true, SupportsToolUse: true, SupportsThinking: true}, "qwen3-vl-flash": {SupportsVision: true, SupportsToolUse: true, SupportsThinking: true}, "qwen3-vl-plus": {SupportsVision: true, SupportsToolUse: true, SupportsThinking: true}, })
Functions ¶
func IsContextTooLongMessage ¶
func IsInvalidRole ¶
func ValidateMessage ¶
func ValidatePart ¶
Types ¶
type CapabilityRegistry ¶
type CapabilityRegistry struct {
// contains filtered or unexported fields
}
func NewCapabilityRegistry ¶
func NewCapabilityRegistry(static map[string]ModelCapabilities) *CapabilityRegistry
func (*CapabilityRegistry) Learn ¶
func (r *CapabilityRegistry) Learn(model string, caps ModelCapabilities)
func (*CapabilityRegistry) Resolve ¶
func (r *CapabilityRegistry) Resolve(model string) ModelCapabilities
func (*CapabilityRegistry) SetOverride ¶
func (r *CapabilityRegistry) SetOverride(model string, caps ModelCapabilities)
type ChatRequest ¶
type ChatRequest struct {
Model string
Messages []Message
Tools []ToolDefinition
Assets map[AssetID]ImageAsset
Temperature float64
// OnStreamProgress is called during streaming when the provider receives
// non-content progress updates (e.g. reasoning_content chunks from
// DeepSeek-style models). charCount is the cumulative number of
// characters received so far; active is true while reasoning is still
// streaming.
OnStreamProgress func(charCount int, active bool)
}
type ErrorCode ¶
type ErrorCode string
const ( ErrorCodeImageTooLarge ErrorCode = "image_too_large" ErrorCodeUnsupportedImage ErrorCode = "unsupported_image" ErrorCodeAssetNotFound ErrorCode = "asset_not_found" ErrorCodeImageDecodeFailed ErrorCode = "image_decode_failed" ErrorCodeRateLimited ErrorCode = "rate_limited" ErrorCodeContextTooLong ErrorCode = "context_too_long" ErrorCodeInvalidToolCall ErrorCode = "invalid_tool_call" ErrorCodeUnknown ErrorCode = "unknown" )
type FunctionDefinition ¶
type ImageAsset ¶
type ImagePartRef ¶
type ImagePartRef struct {
AssetID AssetID `json:"asset_id"`
}
type InternalRequest ¶
type InternalRequest struct {
Model string
Messages []Message
Tools []ToolDefinition
Assets map[AssetID]ImageAsset
Stream bool
}
type Message ¶
type Message struct {
ID string `json:"id,omitempty"`
Role Role `json:"role"`
Parts []Part `json:"content,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
Meta MessageMeta `json:"meta,omitempty"`
Usage *Usage `json:"usage,omitempty"`
// Legacy compatibility fields used by existing runner/tui/provider paths.
Content string `json:"-"`
Name string `json:"-"`
ToolCallID string `json:"-"`
ToolCalls []ToolCall `json:"-"`
}
func ApplyCapabilities ¶
func ApplyCapabilities(messages []Message, caps ModelCapabilities) []Message
func NewAssistantTextMessage ¶
func NewTextMessage ¶
func NewToolResultMessage ¶
func NewUserTextMessage ¶
func (*Message) AppendPart ¶
func (*Message) AppendText ¶
func (Message) MarshalJSON ¶
func (*Message) UnmarshalJSON ¶
type MessageMeta ¶
type ModelCapabilities ¶
type Part ¶
type Part struct {
Type PartType `json:"type"`
Text *TextPart `json:"text,omitempty"`
Image *ImagePartRef `json:"image,omitempty"`
ToolUse *ToolUsePart `json:"tool_use,omitempty"`
ToolResult *ToolResultPart `json:"tool_result,omitempty"`
Thinking *ThinkingPart `json:"thinking,omitempty"`
}
one-of: exactly one payload should be populated.
type ProviderClient ¶
type ProviderClient interface {
Chat(ctx context.Context, req InternalRequest) (<-chan StreamEvent, error)
}
type ProviderError ¶
type ProviderError struct {
Code ErrorCode `json:"code"`
Provider string `json:"provider,omitempty"`
Message string `json:"message,omitempty"`
Status int `json:"status,omitempty"`
Retryable bool `json:"retryable,omitempty"`
}
func MapProviderError ¶
func MapProviderError(provider string, status int, body string, fallback error) *ProviderError
func (*ProviderError) Error ¶
func (e *ProviderError) Error() string
type StreamEvent ¶
type StreamEvent struct {
Type StreamEventType
Text string
ToolUse *ToolUsePart
Err *ProviderError
}
type StreamEventType ¶
type StreamEventType string
const ( EventTextDelta StreamEventType = "text_delta" EventToolUse StreamEventType = "tool_use" EventThinking StreamEventType = "thinking" EventDone StreamEventType = "done" EventError StreamEventType = "error" )
type ThinkingPart ¶
type ThinkingPart struct {
Value string `json:"value"`
}
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function ToolFunctionCall `json:"function"`
}
type ToolDefinition ¶
type ToolDefinition struct {
Type string `json:"type"`
Function FunctionDefinition `json:"function"`
}
type ToolFunctionCall ¶
type ToolResultPart ¶
type ToolUsePart ¶
Click to show internal directories.
Click to hide internal directories.