Documentation
¶
Index ¶
- type Client
- func (c Client) CompleteRaw(ctx context.Context, model string, messages []Message, tools []ToolDef, ...) (Message, Usage, error)
- func (c Client) CompleteWithUsage(ctx context.Context, model string, messages []Message, maxTokens int) (string, Usage, error)
- func (c Client) FetchModels() ([]ModelEntry, error)
- func (c Client) Stream(ctx context.Context, model string, messages []Message, maxTokens int) (<-chan string, <-chan Usage, <-chan error)
- type Message
- type ModelEntry
- type RateLimitError
- type ToolCall
- type ToolCallFunction
- type ToolDef
- type ToolFunction
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client targets one OpenAI-compatible chat-completions provider. BaseURL is the API root (no trailing slash), e.g. "https://api.groq.com/openai/v1" or a self-hosted vLLM endpoint. APIKey is sent as a bearer token; empty means the endpoint needs no auth (local servers).
func (Client) CompleteRaw ¶
func (c Client) CompleteRaw( ctx context.Context, model string, messages []Message, tools []ToolDef, maxTokens int, ) (Message, Usage, error)
CompleteRaw runs a non-streaming completion with optional tools and returns the full assistant message. When the model wants tools, the returned message's ToolCalls is non-empty and Content is usually blank.
func (Client) CompleteWithUsage ¶
func (c Client) CompleteWithUsage( ctx context.Context, model string, messages []Message, maxTokens int, ) (string, Usage, error)
CompleteWithUsage runs a non-streaming completion and returns the assistant text plus token usage.
func (Client) FetchModels ¶
func (c Client) FetchModels() ([]ModelEntry, error)
FetchModels returns all chat-capable models from the provider.
type Message ¶
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Name string `json:"name,omitempty"`
}
Message is one chat message. ToolCalls is populated on an assistant message that requested tools; ToolCallID + Name tag a tool-result message sent back to the model.
type ModelEntry ¶
type RateLimitError ¶
RateLimitError is returned when the provider responds with 429.
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function ToolCallFunction `json:"function"`
}
ToolCall is a tool invocation the model asked for.
type ToolCallFunction ¶
type ToolDef ¶
type ToolDef struct {
Type string `json:"type"`
Function ToolFunction `json:"function"`
}
ToolDef is a tool offered to the model in a request.
type ToolFunction ¶
type ToolFunction struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters json.RawMessage `json:"parameters"`
}