Documentation
¶
Overview ¶
Package providers defines shared types for LLM provider implementations.
Index ¶
- func AnthropicChatStream(ctx context.Context, client *http.Client, apiKey, baseURL string, ...) (<-chan StreamChunk, error)
- func GroqChatStream(ctx context.Context, client *http.Client, apiKey, baseURL string, ...) (<-chan StreamChunk, error)
- func OllamaChatStream(ctx context.Context, client *http.Client, baseURL string, input ChatInput) (<-chan StreamChunk, error)
- func OpenAIChatStream(ctx context.Context, client *http.Client, apiKey, baseURL string, ...) (<-chan StreamChunk, error)
- type ChatInput
- type ChatOutput
- func AnthropicChat(ctx context.Context, client *http.Client, apiKey, baseURL string, ...) (ChatOutput, error)
- func GeminiChat(ctx context.Context, client *http.Client, apiKey, baseURL string, ...) (ChatOutput, error)
- func GroqChat(ctx context.Context, client *http.Client, apiKey, baseURL string, ...) (ChatOutput, error)
- func MistralChat(ctx context.Context, client *http.Client, apiKey, baseURL string, ...) (ChatOutput, error)
- func OllamaChat(ctx context.Context, client *http.Client, baseURL string, input ChatInput) (ChatOutput, error)
- func OpenAIChat(ctx context.Context, client *http.Client, apiKey, baseURL string, ...) (ChatOutput, error)
- type Choice
- type ChoiceMessage
- type EmbedInput
- type EmbedOutput
- type EmbeddingData
- type FunctionCall
- type Message
- type StreamChunk
- type Tool
- type ToolCall
- type ToolFunction
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnthropicChatStream ¶
func AnthropicChatStream(ctx context.Context, client *http.Client, apiKey, baseURL string, input ChatInput) (<-chan StreamChunk, error)
AnthropicChatStream calls the Anthropic Messages API in streaming mode. Returns a channel of StreamChunk that is closed when the stream is complete.
func GroqChatStream ¶
func GroqChatStream(ctx context.Context, client *http.Client, apiKey, baseURL string, input ChatInput) (<-chan StreamChunk, error)
GroqChatStream calls the Groq API in streaming mode via the OpenAI-compatible endpoint.
func OllamaChatStream ¶
func OllamaChatStream(ctx context.Context, client *http.Client, baseURL string, input ChatInput) (<-chan StreamChunk, error)
OllamaChatStream calls the Ollama API in streaming mode. Returns a channel of StreamChunk that is closed when the stream is complete.
func OpenAIChatStream ¶
func OpenAIChatStream(ctx context.Context, client *http.Client, apiKey, baseURL string, input ChatInput) (<-chan StreamChunk, error)
OpenAIChatStream calls the OpenAI chat completions API in streaming mode. Returns a channel of StreamChunk that is closed when the stream is complete.
Types ¶
type ChatInput ¶
type ChatInput struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
Temperature float64 `json:"temperature,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
Tools []Tool `json:"tools,omitempty"`
ToolChoice string `json:"tool_choice,omitempty"`
System string `json:"system,omitempty"`
}
ChatInput is the JSON input for a chat completion request.
type ChatOutput ¶
type ChatOutput struct {
Choices []Choice `json:"choices"`
Usage Usage `json:"usage"`
Cost float64 `json:"cost"`
Model string `json:"model"`
Error string `json:"error,omitempty"`
}
ChatOutput is the JSON output from a chat completion.
func AnthropicChat ¶
func AnthropicChat(ctx context.Context, client *http.Client, apiKey, baseURL string, input ChatInput) (ChatOutput, error)
AnthropicChat calls the Anthropic Messages API.
func GeminiChat ¶
func GeminiChat(ctx context.Context, client *http.Client, apiKey, baseURL string, input ChatInput) (ChatOutput, error)
GeminiChat calls the Google Gemini generateContent API.
func GroqChat ¶
func GroqChat(ctx context.Context, client *http.Client, apiKey, baseURL string, input ChatInput) (ChatOutput, error)
GroqChat calls the Groq API, which is OpenAI-compatible.
func MistralChat ¶
func MistralChat(ctx context.Context, client *http.Client, apiKey, baseURL string, input ChatInput) (ChatOutput, error)
MistralChat calls the Mistral API, which is OpenAI-compatible. Default base URL: https://api.mistral.ai/v1
func OllamaChat ¶
func OllamaChat(ctx context.Context, client *http.Client, baseURL string, input ChatInput) (ChatOutput, error)
OllamaChat calls a local Ollama instance.
func OpenAIChat ¶
func OpenAIChat(ctx context.Context, client *http.Client, apiKey, baseURL string, input ChatInput) (ChatOutput, error)
OpenAIChat calls the OpenAI chat completions API.
type Choice ¶
type Choice struct {
Message ChoiceMessage `json:"message"`
FinishReason string `json:"finish_reason"`
}
Choice represents a single completion choice.
type ChoiceMessage ¶
type ChoiceMessage struct {
Role string `json:"role"`
Content string `json:"content"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
}
ChoiceMessage is the message within a choice.
type EmbedInput ¶
EmbedInput is the JSON input for an embedding request.
type EmbedOutput ¶
type EmbedOutput struct {
Data []EmbeddingData `json:"data"`
Usage Usage `json:"usage"`
Cost float64 `json:"cost"`
Error string `json:"error,omitempty"`
}
EmbedOutput is the JSON output from an embedding request.
func OpenAIEmbed ¶
func OpenAIEmbed(ctx context.Context, client *http.Client, apiKey, baseURL string, input EmbedInput) (EmbedOutput, error)
OpenAIEmbed calls the OpenAI embeddings API.
type EmbeddingData ¶
EmbeddingData holds a single embedding vector.
type FunctionCall ¶
FunctionCall contains the name and arguments for a tool invocation.
type Message ¶
type Message struct {
Role string `json:"role"`
Content string `json:"content,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Name string `json:"name,omitempty"`
}
Message represents a conversation message.
type StreamChunk ¶
type StreamChunk struct {
Content string `json:"content"`
Index int `json:"index"`
Done bool `json:"done"`
}
StreamChunk represents a single chunk of content from a streaming LLM response.
type Tool ¶
type Tool struct {
Type string `json:"type"`
Function ToolFunction `json:"function"`
}
Tool defines a function tool available to the model.
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function FunctionCall `json:"function"`
}
ToolCall represents a model's request to call a tool.
type ToolFunction ¶
type ToolFunction struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters any `json:"parameters"`
}
ToolFunction describes a callable function.