Documentation
¶
Index ¶
Constants ¶
const ( APIAnthropic = "anthropic-messages" APIOpenAICompletions = "openai-completions" ProviderAnthropic = "anthropic" ProviderDeepSeek = "deepseek" ProviderSilicon = "siliconflow" )
const ( ReasoningOff = "off" ReasoningMin = "minimal" ReasoningLow = "low" ReasoningMed = "medium" ReasoningHigh = "high" ReasoningXhigh = "xhigh" ReasoningMax = "max" )
const ( ThinkingFormatAnthropic = "anthropic" ThinkingFormatDeepSeek = "deepseek" ThinkingFormatOpenAI = "openai" )
Variables ¶
This section is empty.
Functions ¶
func DefaultEmbeddingModel ¶
DefaultEmbeddingModel returns a minimal Model for embedding requests. The embedding API endpoint defaults to SiliconFlow (free BAAI/bge-m3). API key is resolved from PI_API_KEY or PI_EMBEDDING_API_KEY.
func EmbeddingBaseURL ¶
func EmbeddingBaseURL() string
EmbeddingBaseURL returns the base URL for embedding requests (includes /v1). Defaults to SiliconFlow's API which offers BAAI/bge-m3 for free.
func EmbeddingModel ¶
func EmbeddingModel() string
EmbeddingModel returns the configured embedding model name.
func ListCatalog ¶
func ListCatalog()
Types ¶
type Provider ¶
type Provider struct {
Model types.Model
// Instance-level credentials. When empty, env fallbacks are used.
APIKey string
EmbeddingModel string
EmbeddingBaseURL string
EmbeddingAPIKey string
}
Provider wraps a model and provides a Stream method to interact with it. Each Provider instance is owned by a single Agent to ensure isolation.
API keys are resolved with the following priority:
- Instance-level fields (APIKey / EmbeddingAPIKey) — set via NewConfiguredProvider / WithEmbedding / WithAPIKey
- Global env fallbacks (PI_API_KEY, provider-specific vars) — used only when no instance-level key is configured.
func NewConfiguredProvider ¶
NewConfiguredProvider creates a Provider with an explicit API key, bypassing env resolution for chat completions.
func NewProvider ¶
func (*Provider) Embed ¶
Embed computes an embedding vector for the given text using the configured embedding provider. The embedding endpoint is resolved with instance-level precedence: WithEmbedding fields, else the chat model's BaseURL.
URL: {baseURL}/embeddings (baseURL already includes /v1), POST model + input.
func (*Provider) WithAPIKey ¶
WithAPIKey sets the chat-completion API key on the provider.
func (*Provider) WithEmbedding ¶
WithEmbedding configures a dedicated embedding endpoint, independent of the chat model. Empty baseURL falls back to the chat model's BaseURL.