Documentation
¶
Index ¶
- func ClearCache()
- func CreateChatModel(ctx context.Context, modelType string, config *types.ModelConfig, ...) (model.ToolCallingChatModel, error)
- func CreateClaude(ctx context.Context, modelConfig *types.ModelConfig, options ...ModelOption) (model.ToolCallingChatModel, error)
- func CreateDeepSeek(ctx context.Context, modelConfig *types.ModelConfig, options ...ModelOption) (model.ToolCallingChatModel, error)
- func CreateOllama(ctx context.Context, modelConfig *types.ModelConfig, options ...ModelOption) (model.ToolCallingChatModel, error)
- func CreateOpenAI(ctx context.Context, modelConfig *types.ModelConfig, options ...ModelOption) (model.ToolCallingChatModel, error)
- func CreateQwen(ctx context.Context, modelConfig *types.ModelConfig, options ...ModelOption) (model.ToolCallingChatModel, error)
- func GetCacheStats() map[string]interface{}
- func GetChatModel(ctx context.Context, modelName string) (model.ToolCallingChatModel, error)
- func GetDefaultChatModel(ctx context.Context) (model.ToolCallingChatModel, error)
- func GetModelTimeout(config *types.ModelConfig) time.Duration
- func RegisterChatModelFactory(modelType string, factory ChatModelFactory)
- type ChatModelFactory
- type ChatModelWrapper
- func (w *ChatModelWrapper) Generate(ctx context.Context, input []*schema.Message, opts ...model.Option) (*schema.Message, error)
- func (w *ChatModelWrapper) GenerateFromPrompt(ctx context.Context, prompt string, opts ...model.Option) (*schema.Message, error)
- func (w *ChatModelWrapper) GenerateWithSystemPrompt(ctx context.Context, systemPrompt, userPrompt string, opts ...model.Option) (*schema.Message, error)
- func (w *ChatModelWrapper) GetModelName() string
- func (w *ChatModelWrapper) GetUnderlyingModel() model.ToolCallingChatModel
- func (w *ChatModelWrapper) Stream(ctx context.Context, input []*schema.Message, opts ...model.Option) (*schema.StreamReader[*schema.Message], error)
- func (w *ChatModelWrapper) StreamFromPrompt(ctx context.Context, prompt string, opts ...model.Option) (*schema.StreamReader[*schema.Message], error)
- func (w *ChatModelWrapper) StreamWithSystemPrompt(ctx context.Context, systemPrompt, userPrompt string, opts ...model.Option) (*schema.StreamReader[*schema.Message], error)
- func (w *ChatModelWrapper) WithTools(tools []*schema.ToolInfo) (*ChatModelWrapper, error)
- type ModelInstance
- type ModelOption
- type ModelOptions
- type WrapperInstance
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateChatModel ¶
func CreateChatModel(ctx context.Context, modelType string, config *types.ModelConfig, options ...ModelOption) (model.ToolCallingChatModel, error)
CreateChatModel creates a chat Model instance based on the Model type and configuration. It uses a registered factory for the given Model type.
func CreateClaude ¶
func CreateClaude(ctx context.Context, modelConfig *types.ModelConfig, options ...ModelOption) (model.ToolCallingChatModel, error)
CreateClaude creates a Claude ChatModel.
func CreateDeepSeek ¶
func CreateDeepSeek(ctx context.Context, modelConfig *types.ModelConfig, options ...ModelOption) (model.ToolCallingChatModel, error)
CreateDeepSeek creates a DeepSeek ChatModel.
func CreateOllama ¶
func CreateOllama(ctx context.Context, modelConfig *types.ModelConfig, options ...ModelOption) (model.ToolCallingChatModel, error)
CreateOllama creates an Ollama ChatModel.
func CreateOpenAI ¶
func CreateOpenAI(ctx context.Context, modelConfig *types.ModelConfig, options ...ModelOption) (model.ToolCallingChatModel, error)
CreateOpenAI creates an OpenAI ChatModel.
func CreateQwen ¶
func CreateQwen(ctx context.Context, modelConfig *types.ModelConfig, options ...ModelOption) (model.ToolCallingChatModel, error)
CreateQwen creates a Qwen ChatModel.
func GetCacheStats ¶ added in v0.1.2
func GetCacheStats() map[string]interface{}
GetCacheStats returns cache statistics for monitoring
func GetChatModel ¶
GetChatModel retrieves a chat Model instance by name. It first checks a cache of existing instances. If not found, it creates a new one using the configuration and caches it.
func GetDefaultChatModel ¶
func GetDefaultChatModel(ctx context.Context) (model.ToolCallingChatModel, error)
GetDefaultChatModel retrieves the default chat Model instance. It uses the default Model name from the application configuration.
func GetModelTimeout ¶
func GetModelTimeout(config *types.ModelConfig) time.Duration
GetModelTimeout returns the timeout duration for a Model. It defaults to 300 seconds if not specified in the configuration.
func RegisterChatModelFactory ¶
func RegisterChatModelFactory(modelType string, factory ChatModelFactory)
RegisterChatModelFactory registers a ChatModel factory for a given Model type.
Types ¶
type ChatModelFactory ¶
type ChatModelFactory func(ctx context.Context, modelConfig *types.ModelConfig, options ...ModelOption) (model.ToolCallingChatModel, error)
ChatModelFactory defines the function signature for a Model factory.
type ChatModelWrapper ¶ added in v0.1.2
type ChatModelWrapper struct {
Model model.ToolCallingChatModel
ModelName string
}
ChatModelWrapper wraps a ToolCallingChatModel with additional convenience methods.
func GetChatModelWrapper ¶ added in v0.1.2
func GetChatModelWrapper(ctx context.Context, modelName string) (*ChatModelWrapper, error)
GetChatModelWrapper retrieves a chat Model wrapper instance by name. It first checks a cache of existing wrapper instances. If not found, it creates a new one using the underlying chat Model and caches it.
func GetDefaultChatModelWrapper ¶ added in v0.1.2
func GetDefaultChatModelWrapper(ctx context.Context) (*ChatModelWrapper, error)
GetDefaultChatModelWrapper retrieves the default chat Model wrapper instance. It uses the default Model name from the application configuration.
func NewChatModelWrapper ¶ added in v0.1.2
func NewChatModelWrapper(chatModel model.ToolCallingChatModel, modelName string) *ChatModelWrapper
NewChatModelWrapper creates a new ChatModelWrapper instance.
func (*ChatModelWrapper) Generate ¶ added in v0.1.2
func (w *ChatModelWrapper) Generate(ctx context.Context, input []*schema.Message, opts ...model.Option) (*schema.Message, error)
Generate delegates to the underlying Model's Generate method.
func (*ChatModelWrapper) GenerateFromPrompt ¶ added in v0.1.2
func (w *ChatModelWrapper) GenerateFromPrompt(ctx context.Context, prompt string, opts ...model.Option) (*schema.Message, error)
GenerateFromPrompt generates a response from a simple text prompt. It automatically wraps the prompt in a user message and calls the underlying Generate method.
func (*ChatModelWrapper) GenerateWithSystemPrompt ¶ added in v0.1.2
func (w *ChatModelWrapper) GenerateWithSystemPrompt(ctx context.Context, systemPrompt, userPrompt string, opts ...model.Option) (*schema.Message, error)
GenerateWithSystemPrompt generates a response with both system and user messages.
func (*ChatModelWrapper) GetModelName ¶ added in v0.1.2
func (w *ChatModelWrapper) GetModelName() string
GetModelName returns the name of the wrapped Model.
func (*ChatModelWrapper) GetUnderlyingModel ¶ added in v0.1.2
func (w *ChatModelWrapper) GetUnderlyingModel() model.ToolCallingChatModel
GetUnderlyingModel returns the underlying ToolCallingChatModel.
func (*ChatModelWrapper) Stream ¶ added in v0.1.2
func (w *ChatModelWrapper) Stream(ctx context.Context, input []*schema.Message, opts ...model.Option) (*schema.StreamReader[*schema.Message], error)
Stream delegates to the underlying Model's Stream method.
func (*ChatModelWrapper) StreamFromPrompt ¶ added in v0.1.2
func (w *ChatModelWrapper) StreamFromPrompt(ctx context.Context, prompt string, opts ...model.Option) (*schema.StreamReader[*schema.Message], error)
StreamFromPrompt streams a response from a simple text prompt. It automatically wraps the prompt in a user message and calls the underlying Stream method.
func (*ChatModelWrapper) StreamWithSystemPrompt ¶ added in v0.1.2
func (w *ChatModelWrapper) StreamWithSystemPrompt(ctx context.Context, systemPrompt, userPrompt string, opts ...model.Option) (*schema.StreamReader[*schema.Message], error)
StreamWithSystemPrompt streams a response with both system and user messages.
func (*ChatModelWrapper) WithTools ¶ added in v0.1.2
func (w *ChatModelWrapper) WithTools(tools []*schema.ToolInfo) (*ChatModelWrapper, error)
WithTools returns a new ChatModelWrapper with the specified tools bound.
type ModelInstance ¶ added in v0.1.2
type ModelInstance struct {
Model model.ToolCallingChatModel
CreatedAt time.Time
LastUsed time.Time
}
ModelInstance represents a cached Model instance with metadata
type ModelOption ¶
type ModelOption func(*ModelOptions)
ModelOption defines an option function for configuring a Model.
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) ModelOption
WithHTTPClient sets a custom HTTP client for the Model.
func WithJSONFormat ¶
func WithJSONFormat() ModelOption
WithJSONFormat sets the Model to return responses in JSON format.
type ModelOptions ¶
type ModelOptions struct {
JSONFormat bool // Whether to return JSON format.
HTTPClient *http.Client
}
ModelOptions stores optional parameters for Model creation.
type WrapperInstance ¶ added in v0.1.2
type WrapperInstance struct {
Wrapper *ChatModelWrapper
CreatedAt time.Time
LastUsed time.Time
}
WrapperInstance represents a cached wrapper instance with metadata