providers

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package providers implements LLM client providers for various APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(provider string, cfg llm.ClientConfig) (llm.Client, error)

NewClient creates an LLM client for the specified provider. Supported providers: "openai", "anthropic", "ollama".

func NewEmbedder

func NewEmbedder(provider string, cfg OpenAIEmbedderConfig) (llm.Embedder, error)

NewEmbedder creates an Embedder for the specified provider. Supported providers: "openai", "gemini", "ollama". Returns an error for "anthropic" (no embedding API).

Types

type AnthropicClient

type AnthropicClient struct {
	// contains filtered or unexported fields
}

AnthropicClient implements llm.Client for the Anthropic Messages API.

func NewAnthropicClient

func NewAnthropicClient(cfg llm.ClientConfig) *AnthropicClient

NewAnthropicClient creates a new Anthropic client.

func (*AnthropicClient) Chat

Chat sends a non-streaming messages request.

func (*AnthropicClient) ChatStream

func (c *AnthropicClient) ChatStream(ctx context.Context, req *llm.ChatRequest) (<-chan llm.StreamDelta, error)

ChatStream sends a streaming messages request.

func (*AnthropicClient) ModelID

func (c *AnthropicClient) ModelID() string

type OAuthClient

type OAuthClient struct {
	// contains filtered or unexported fields
}

OAuthClient wraps a ResponsesClient with automatic OAuth token refresh. It implements llm.Client and transparently refreshes expired tokens before each API call. ChatGPT OAuth tokens are scoped to the Responses API, not the Chat Completions API, so this client uses the Responses API format.

func NewOAuthClient

func NewOAuthClient(cfg llm.ClientConfig, provider string, oauthConfig oauth.ProviderConfig) *OAuthClient

NewOAuthClient creates a new OAuth-aware client that uses the Responses API. The token is loaded from stored credentials and refreshed automatically.

func (*OAuthClient) Chat

Chat sends a Responses API request, refreshing the token if needed.

func (*OAuthClient) ChatStream

func (c *OAuthClient) ChatStream(ctx context.Context, req *llm.ChatRequest) (<-chan llm.StreamDelta, error)

ChatStream sends a streaming Responses API request, refreshing the token if needed.

func (*OAuthClient) ModelID

func (c *OAuthClient) ModelID() string

ModelID returns the model identifier.

type OllamaClient

type OllamaClient struct {
	*OpenAIClient
}

OllamaClient wraps OpenAIClient with Ollama-specific defaults. Ollama provides an OpenAI-compatible API at localhost:11434/v1.

func NewOllamaClient

func NewOllamaClient(cfg llm.ClientConfig) *OllamaClient

NewOllamaClient creates a client that talks to a local Ollama server.

type OllamaEmbedder

type OllamaEmbedder struct {
	*OpenAIEmbedder
}

OllamaEmbedder wraps OpenAIEmbedder with Ollama-specific defaults. Ollama provides an OpenAI-compatible /v1/embeddings endpoint.

func NewOllamaEmbedder

func NewOllamaEmbedder(cfg OpenAIEmbedderConfig) *OllamaEmbedder

NewOllamaEmbedder creates an embedder that talks to a local Ollama server.

type OpenAIClient

type OpenAIClient struct {
	// contains filtered or unexported fields
}

OpenAIClient implements llm.Client for the OpenAI Chat Completions API. Also works with Azure OpenAI and any OpenAI-compatible endpoint.

func NewOpenAIClient

func NewOpenAIClient(cfg llm.ClientConfig) *OpenAIClient

NewOpenAIClient creates a new OpenAI client.

func (*OpenAIClient) Chat

Chat sends a non-streaming chat completion request.

func (*OpenAIClient) ChatStream

func (c *OpenAIClient) ChatStream(ctx context.Context, req *llm.ChatRequest) (<-chan llm.StreamDelta, error)

ChatStream sends a streaming chat completion request.

func (*OpenAIClient) ModelID

func (c *OpenAIClient) ModelID() string

type OpenAIEmbedder

type OpenAIEmbedder struct {
	// contains filtered or unexported fields
}

OpenAIEmbedder implements llm.Embedder using the OpenAI Embeddings API.

func NewOpenAIEmbedder

func NewOpenAIEmbedder(cfg OpenAIEmbedderConfig) *OpenAIEmbedder

NewOpenAIEmbedder creates an OpenAI embedder.

func (*OpenAIEmbedder) Dimensions

func (e *OpenAIEmbedder) Dimensions() int

func (*OpenAIEmbedder) Embed

Embed produces embeddings for the given texts using POST /v1/embeddings.

type OpenAIEmbedderConfig

type OpenAIEmbedderConfig struct {
	APIKey  string
	OrgID   string
	BaseURL string
	Model   string
	Dims    int
}

OpenAIEmbedderConfig configures the OpenAI embedder.

type ResponsesClient

type ResponsesClient struct {
	// contains filtered or unexported fields
}

ResponsesClient implements llm.Client using the OpenAI Responses API. This is used with ChatGPT OAuth tokens which are scoped to the Responses API endpoint (chatgpt.com/backend-api) rather than the Chat Completions API.

func NewResponsesClient

func NewResponsesClient(cfg llm.ClientConfig) *ResponsesClient

NewResponsesClient creates a new Responses API client.

func (*ResponsesClient) Chat

Chat sends a Responses API request. The ChatGPT Codex backend requires streaming, so this method always uses stream=true internally and collects the full response from the streamed deltas.

func (*ResponsesClient) ChatStream

func (c *ResponsesClient) ChatStream(ctx context.Context, req *llm.ChatRequest) (<-chan llm.StreamDelta, error)

ChatStream sends a streaming Responses API request.

func (*ResponsesClient) ModelID

func (c *ResponsesClient) ModelID() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL