Documentation
¶
Index ¶
- func IsKind(err error, kind ErrorKind) bool
- func NewError(engine Engine, kind ErrorKind, status int, msg string, err error) error
- type ChatRequest
- type ChatResponse
- type Config
- type Engine
- type Error
- type ErrorKind
- type HealthStatus
- type Message
- type ModelRuntime
- type OpenAICompatibleRuntime
- func (r *OpenAICompatibleRuntime) Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error)
- func (r *OpenAICompatibleRuntime) Engine() Engine
- func (r *OpenAICompatibleRuntime) GenerateStructured(ctx context.Context, req StructuredRequest) (*StructuredResponse, error)
- func (r *OpenAICompatibleRuntime) Health(ctx context.Context) (*HealthStatus, error)
- func (r *OpenAICompatibleRuntime) Stream(ctx context.Context, req ChatRequest) (<-chan StreamEvent, error)
- type RuntimeConfig
- type StreamEvent
- type StreamEventKind
- type StructuredRequest
- type StructuredResponse
- type Tool
- type ToolCall
- type ToolCallFunction
- type ToolFunction
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChatRequest ¶
type ChatResponse ¶
type Config ¶
type Config struct {
Engine Engine `json:"engine" yaml:"engine"`
BaseURL string `json:"base_url" yaml:"base_url"`
APIKey string `json:"api_key,omitempty" yaml:"api_key,omitempty"`
Model string `json:"model,omitempty" yaml:"model,omitempty"`
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`
TimeoutMS int `json:"timeout_ms,omitempty" yaml:"timeout_ms,omitempty"`
}
type HealthStatus ¶
type ModelRuntime ¶
type ModelRuntime interface {
Engine() Engine
Health(context.Context) (*HealthStatus, error)
Chat(context.Context, ChatRequest) (*ChatResponse, error)
Stream(context.Context, ChatRequest) (<-chan StreamEvent, error)
GenerateStructured(context.Context, StructuredRequest) (*StructuredResponse, error)
}
type OpenAICompatibleRuntime ¶
type OpenAICompatibleRuntime struct {
// contains filtered or unexported fields
}
func NewOpenAICompatibleRuntime ¶
func NewOpenAICompatibleRuntime(cfg Config) (*OpenAICompatibleRuntime, error)
func (*OpenAICompatibleRuntime) Chat ¶
func (r *OpenAICompatibleRuntime) Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error)
func (*OpenAICompatibleRuntime) Engine ¶
func (r *OpenAICompatibleRuntime) Engine() Engine
func (*OpenAICompatibleRuntime) GenerateStructured ¶
func (r *OpenAICompatibleRuntime) GenerateStructured(ctx context.Context, req StructuredRequest) (*StructuredResponse, error)
func (*OpenAICompatibleRuntime) Health ¶
func (r *OpenAICompatibleRuntime) Health(ctx context.Context) (*HealthStatus, error)
func (*OpenAICompatibleRuntime) Stream ¶
func (r *OpenAICompatibleRuntime) Stream(ctx context.Context, req ChatRequest) (<-chan StreamEvent, error)
type RuntimeConfig ¶
type StreamEvent ¶
type StreamEvent struct {
Kind StreamEventKind
Delta string
Err error
}
type StreamEventKind ¶
type StreamEventKind string
const ( StreamEventDelta StreamEventKind = "delta" StreamEventDone StreamEventKind = "done" StreamEventError StreamEventKind = "error" )
type StructuredRequest ¶
type StructuredRequest struct {
ChatRequest
Name string
Strict bool
Schema map[string]any
}
type StructuredResponse ¶
type Tool ¶
type Tool struct {
Type string `json:"type"`
Function ToolFunction `json:"function"`
}
type ToolCall ¶
type ToolCall struct {
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Function ToolCallFunction `json:"function"`
}
type ToolCallFunction ¶
type ToolCallFunction struct {
Name string `json:"name"`
Arguments map[string]any `json:"arguments,omitempty"`
}
func (ToolCallFunction) MarshalJSON ¶
func (f ToolCallFunction) MarshalJSON() ([]byte, error)
func (*ToolCallFunction) UnmarshalJSON ¶
func (f *ToolCallFunction) UnmarshalJSON(data []byte) error
type ToolFunction ¶
Click to show internal directories.
Click to hide internal directories.