Documentation
¶
Index ¶
- func FormatToolCall(toolCall *ToolUseBlockParam) string
- func FormatToolResult(toolResult *ToolResultBlockParam) string
- func MergeConfig(config interface{}, yamlConfig map[string]interface{})
- type AliasesModelProvider
- type Base64ImageSourceParam
- type Base64PDFSourceParam
- type CachedModels
- type ContentBlockParamUnion
- func NewImageBlock[T Base64ImageSourceParam | URLImageSourceParam](source T) ContentBlockParamUnion
- func NewTextBlock(text string) ContentBlockParamUnion
- func NewThinkingBlock(signature string, thinking string) ContentBlockParamUnion
- func NewToolResultBlock(toolUseID string, content string, isError *bool) ContentBlockParamUnion
- func NewToolUseBlock(id string, input json.RawMessage, name string) ContentBlockParamUnion
- type ContentBlockSourceContentUnionParam
- type ContentBlockSourceParam
- type ContentBlockType
- type GenerateContext
- type ImageBlockParam
- type ImageBlockParamSourceUnion
- type Info
- type LocalModelProvider
- type Message
- type MockProvider
- func (mp *MockProvider) Close() error
- func (mp *MockProvider) Generate(gtx GenerateContext, request *Request, ...) ([]Message, *execcontext.TokenUsage, error)
- func (mp *MockProvider) GetName() string
- func (mp *MockProvider) IsModelSupported(model string) bool
- func (mp *MockProvider) ListModels(ctx context.Context) ([]Info, error)
- func (mp *MockProvider) SetResponse(prompt, response string)
- type ModelCache
- type PlainTextSourceParam
- type Provider
- type Registry
- func (mr *Registry) GetProviderByName(name string) (Provider, error)
- func (mr *Registry) GetProviderForModel(providerName, model string) (Provider, error)
- func (mr *Registry) IsModelSupported(providerName, model string) bool
- func (mr *Registry) ModelAlias(providerName, model string) (string, error)
- func (mr *Registry) RegisterProvider(provider Provider) error
- type Request
- type TextBlockParam
- type ThinkingBlockParam
- type ToolResultBlockParam
- type ToolUseBlockParam
- type URLImageSourceParam
- type URLPDFSourceParam
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatToolCall ¶
func FormatToolCall(toolCall *ToolUseBlockParam) string
func FormatToolResult ¶
func FormatToolResult(toolResult *ToolResultBlockParam) string
func MergeConfig ¶
func MergeConfig(config interface{}, yamlConfig map[string]interface{})
MergeConfig merges a yaml config into a struct
Types ¶
type AliasesModelProvider ¶
type Base64ImageSourceParam ¶
type Base64ImageSourceParam struct {
Data string `json:"data" format:"byte"`
MediaType string `json:"media_type"`
Type string `json:"type"`
}
Image Source Types
type Base64PDFSourceParam ¶
type Base64PDFSourceParam struct {
Data string `json:"data" format:"byte"`
MediaType string `json:"media_type"`
Type string `json:"type"`
}
Document Source Types
type CachedModels ¶
type CachedModels struct {
Models []Info `json:"models"`
Provider string `json:"provider"`
CachedAt time.Time `json:"cached_at"`
ExpiresAt time.Time `json:"expires_at"`
}
CachedModels represents cached model data
type ContentBlockParamUnion ¶
type ContentBlockParamUnion struct {
OfText *TextBlockParam `json:",omitzero,inline"`
OfImage *ImageBlockParam `json:",omitzero,inline"`
OfToolUse *ToolUseBlockParam `json:",omitzero,inline"`
OfToolResult *ToolResultBlockParam `json:",omitzero,inline"`
OfThinking *ThinkingBlockParam `json:",omitzero,inline"`
}
Main Union Type
func NewImageBlock ¶
func NewImageBlock[T Base64ImageSourceParam | URLImageSourceParam](source T) ContentBlockParamUnion
func NewTextBlock ¶
func NewTextBlock(text string) ContentBlockParamUnion
func NewThinkingBlock ¶
func NewThinkingBlock(signature string, thinking string) ContentBlockParamUnion
func NewToolResultBlock ¶
func NewToolResultBlock(toolUseID string, content string, isError *bool) ContentBlockParamUnion
func NewToolUseBlock ¶
func NewToolUseBlock(id string, input json.RawMessage, name string) ContentBlockParamUnion
func (*ContentBlockParamUnion) Type ¶
func (c *ContentBlockParamUnion) Type() ContentBlockType
type ContentBlockSourceContentUnionParam ¶
type ContentBlockSourceContentUnionParam struct {
OfString *string `json:",omitzero,inline"`
OfContentBlockSourceContent []ContentBlockSourceContentUnionParam `json:",omitzero,inline"`
}
type ContentBlockSourceParam ¶
type ContentBlockSourceParam struct {
Content ContentBlockSourceContentUnionParam `json:"content,omitzero"`
Type string `json:"type"`
}
type ContentBlockType ¶
type ContentBlockType string
const ( ContentBlockTypeText ContentBlockType = "text" ContentBlockTypeImage ContentBlockType = "image" ContentBlockTypeToolUse ContentBlockType = "tool_use" ContentBlockTypeToolResult ContentBlockType = "tool_result" ContentBlockTypeThinking ContentBlockType = "thinking" )
type GenerateContext ¶
type ImageBlockParam ¶
type ImageBlockParam struct {
Source ImageBlockParamSourceUnion `json:"source,omitzero"`
Type string `json:"type"` // image
}
type ImageBlockParamSourceUnion ¶
type ImageBlockParamSourceUnion struct {
OfBase64 *Base64ImageSourceParam `json:",omitzero,inline"`
OfURL *URLImageSourceParam `json:",omitzero,inline"`
}
type Info ¶
type Info struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Provider string `json:"provider"`
CreatedAt string `json:"created_at,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Description string `json:"description,omitempty"`
Features []string `json:"features,omitempty"`
}
ModelInfo represents information about an available model
type LocalModelProvider ¶
type LocalModelProvider interface {
// contains filtered or unexported methods
}
type Message ¶
type Message struct {
Role string `json:"role"`
IsTruncated bool `json:"-"`
Content []ContentBlockParamUnion `json:"content"`
}
type MockProvider ¶
type MockProvider struct {
// contains filtered or unexported fields
}
MockModelProvider is a mock implementation for testing
func NewMockProvider ¶
func NewMockProvider(name string, models []Info) *MockProvider
NewMockModelProvider creates a new mock model provider
func (*MockProvider) Generate ¶
func (mp *MockProvider) Generate(gtx GenerateContext, request *Request, progressChan chan<- pkgEvents.ExecutionEvent) ([]Message, *execcontext.TokenUsage, error)
Generate generates a mock response
func (*MockProvider) GetName ¶
func (mp *MockProvider) GetName() string
GetName returns the provider name
func (*MockProvider) IsModelSupported ¶
func (mp *MockProvider) IsModelSupported(model string) bool
IsModelSupported checks if a model is supported
func (*MockProvider) ListModels ¶
func (mp *MockProvider) ListModels(ctx context.Context) ([]Info, error)
ListModels returns the supported models
func (*MockProvider) SetResponse ¶
func (mp *MockProvider) SetResponse(prompt, response string)
SetResponse sets a mock response for a specific prompt
type ModelCache ¶
type ModelCache struct {
// contains filtered or unexported fields
}
ModelCache handles caching of model lists from providers
func NewModelCache ¶
func NewModelCache(disable bool) *ModelCache
NewModelCache creates a new model cache
func (*ModelCache) InvalidateCache ¶
func (mc *ModelCache) InvalidateCache(providerName string)
InvalidateCache removes cached data for a provider
type PlainTextSourceParam ¶
type Provider ¶
type Provider interface {
// Generate generates a response from the model
Generate(ctx GenerateContext, request *Request, progressChan chan<- pkgEvents.ExecutionEvent) ([]Message, *execcontext.TokenUsage, error)
// GetName returns the provider name
GetName() string
// ListModels dynamically queries available models from the provider API
ListModels(ctx context.Context) ([]Info, error)
// Close cleans up resources
Close() error
}
Provider defines the interface for AI model providers
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
ModelRegistry manages available model providers
func NewRegistry ¶
NewRegistry creates a new model registry
func (*Registry) GetProviderByName ¶
GetProviderByName returns a provider by name
func (*Registry) GetProviderForModel ¶
GetProviderForModel returns the provider for a specific model from a specific provider
func (*Registry) IsModelSupported ¶
IsModelSupported checks if a model is supported
func (*Registry) ModelAlias ¶
func (*Registry) RegisterProvider ¶
RegisterProvider registers a model provider
type Request ¶
type Request struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
SystemPrompt string `json:"system_prompt,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
Stop []string `json:"stop,omitempty"`
Tools []tools.Tool `json:"tools,omitempty"`
// Additional metadata
RequestID string `json:"request_id,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
Request represents a request to generate text from a model
type TextBlockParam ¶
type ThinkingBlockParam ¶
type ToolResultBlockParam ¶
type ToolUseBlockParam ¶
type ToolUseBlockParam struct {
ID string `json:"id"`
Input json.RawMessage `json:"input,omitzero"`
Name string `json:"name"`
Type string `json:"type"` // tool_use
}