Documentation
¶
Index ¶
- func BuildToolDefinitions(tools []ToolDefinition) []map[string]interface{}
- func ConvertMessages(messages []*types.Message) []map[string]interface{}
- func MergeConfig(reqTemp, modelTemp float64, reqTokens, modelTokens int) (float64, int)
- func ReadErrorResponse(resp *http.Response) error
- func ReadJSONResponse(resp *http.Response, target interface{}) error
- type BaseModel
- type FunctionSchema
- type HTTPClient
- type InvokeRequest
- type Model
- type ResponseFormat
- type ToolDefinition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildToolDefinitions ¶
func BuildToolDefinitions(tools []ToolDefinition) []map[string]interface{}
BuildToolDefinitions converts model tool definitions to a specific format This is a helper that can be customized per provider
func ConvertMessages ¶
ConvertMessages converts types.Message to a generic message format This is useful for building request messages across different providers
func MergeConfig ¶
MergeConfig merges request-level config with model-level config Request-level values take precedence over model-level values
func ReadErrorResponse ¶
ReadErrorResponse reads an error response and returns an error
func ReadJSONResponse ¶
ReadJSONResponse reads and decodes a JSON response
Types ¶
type BaseModel ¶
BaseModel provides common functionality for model implementations
func (*BaseModel) GetProvider ¶
GetProvider returns the model provider
type FunctionSchema ¶
type FunctionSchema struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Parameters map[string]interface{} `json:"parameters,omitempty"`
}
FunctionSchema defines the schema of a callable function
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient provides common HTTP functionality for model providers
type InvokeRequest ¶
type InvokeRequest struct {
Messages []*types.Message
Tools []ToolDefinition
Temperature float64
MaxTokens int
Stream bool
Extra map[string]interface{}
ResponseFormat *ResponseFormat // Optional: structured output constraint
}
InvokeRequest contains parameters for model invocation
type Model ¶
type Model interface {
// Invoke calls the model synchronously
Invoke(ctx context.Context, req *InvokeRequest) (*types.ModelResponse, error)
// InvokeStream calls the model with streaming response
InvokeStream(ctx context.Context, req *InvokeRequest) (<-chan types.ResponseChunk, error)
// GetProvider returns the model provider name
GetProvider() string
// GetID returns the model identifier
GetID() string
// GetName returns the model name
GetName() string
}
Model represents a language model interface
type ResponseFormat ¶ added in v1.4.0
type ResponseFormat struct {
Type string `json:"type"` // "json_object" or "json_schema"
JSONSchema map[string]interface{} `json:"json_schema,omitempty"` // Schema when Type == "json_schema"
}
ResponseFormat specifies the format constraint for model output. Used to request structured JSON output from models that support it.
type ToolDefinition ¶
type ToolDefinition struct {
Type string `json:"type"` // "function"
Function FunctionSchema `json:"function"`
}
ToolDefinition defines a tool that can be called by the model
Directories
¶
| Path | Synopsis |
|---|---|
|
evolink
|
|
|
Package fallback provides a Model implementation that chains multiple models together, falling back to the next model when one fails with a retryable error.
|
Package fallback provides a Model implementation that chains multiple models together, falling back to the next model when one fails with a retryable error. |