Documentation
¶
Index ¶
- Variables
- func Poll[T any](ctx context.Context, cfg PollConfig, check PollFunc[T]) (*T, error)
- type APIKeyEntry
- type BaseProviderConfig
- type ClaudeConfig
- type DeepSeekConfig
- type DoubaoConfig
- type GLMConfig
- type GeminiConfig
- type GeminiSafetySetting
- type GrokConfig
- type HunyuanConfig
- type KimiConfig
- type LlamaConfig
- type MiniMaxConfig
- type MistralConfig
- type OpenAIConfig
- type PollConfig
- type PollFunc
- type PollResult
- type ProviderCapability
- type QwenConfig
Constants ¶
This section is empty.
Variables ¶
var ChatProviderCapabilityMatrix = []ProviderCapability{ {Provider: "OpenAI", Image: true, Video: true, AudioGenerate: true, AudioSTT: true, Embedding: true, FineTuning: true}, {Provider: "Claude", Image: false, Video: false, AudioGenerate: false, AudioSTT: false, Embedding: false, FineTuning: false}, {Provider: "Gemini", Image: true, Video: true, AudioGenerate: true, AudioSTT: true, Embedding: true, FineTuning: true}, {Provider: "DeepSeek", Image: false, Video: false, AudioGenerate: false, AudioSTT: false, Embedding: false, FineTuning: false}, {Provider: "Qwen", Image: true, Video: true, AudioGenerate: true, AudioSTT: false, Embedding: true, FineTuning: false, Rerank: true}, {Provider: "GLM", Image: true, Video: true, AudioGenerate: true, AudioSTT: false, Embedding: true, FineTuning: true, Rerank: true}, {Provider: "Grok", Image: true, Video: true, AudioGenerate: false, AudioSTT: false, Embedding: true, FineTuning: false}, {Provider: "Doubao", Image: true, Video: false, AudioGenerate: true, AudioSTT: false, Embedding: true, FineTuning: false}, {Provider: "Kimi", Image: false, Video: false, AudioGenerate: false, AudioSTT: false, Embedding: false, FineTuning: false}, {Provider: "Mistral", Image: false, Video: false, AudioGenerate: false, AudioSTT: true, Embedding: true, FineTuning: true}, {Provider: "Hunyuan", Image: false, Video: false, AudioGenerate: false, AudioSTT: false, Embedding: false, FineTuning: false}, {Provider: "MiniMax", Image: false, Video: false, AudioGenerate: true, AudioSTT: false, Embedding: false, FineTuning: false}, {Provider: "Llama", Image: false, Video: false, AudioGenerate: false, AudioSTT: false, Embedding: false, FineTuning: false}, }
ChatProviderCapabilityMatrix lists the implemented capabilities for the 13 chat providers. Order is stable and used by docs generator.
Functions ¶
Types ¶
type APIKeyEntry ¶ added in v1.0.0
type APIKeyEntry struct {
Key string `json:"key" yaml:"key"`
BaseURL string `json:"base_url,omitempty" yaml:"base_url,omitempty"`
Weight int `json:"weight,omitempty" yaml:"weight,omitempty"`
}
APIKeyEntry 结构化 API Key 条目,每个 Key 可绑定独立的 BaseURL 和权重
type BaseProviderConfig ¶
type BaseProviderConfig struct {
APIKey string `json:"api_key" yaml:"api_key"`
APIKeys []APIKeyEntry `json:"api_keys,omitempty" yaml:"api_keys,omitempty"` // 多 API Key 支持,轮询使用
BaseURL string `json:"base_url" yaml:"base_url"`
Model string `json:"model,omitempty" yaml:"model,omitempty"`
Models []string `json:"models,omitempty" yaml:"models,omitempty"` // 可用模型白名单
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}
BaseProviderConfig 所有 Provider 共享的基础配置字段。 通过嵌入此结构体,各 Provider 的 Config 自动获得 APIKey、BaseURL、Model、Timeout 四个字段, 避免重复定义。
type ClaudeConfig ¶
type ClaudeConfig struct {
BaseProviderConfig `yaml:",inline"`
AnthropicVersion string `json:"anthropic_version,omitempty" yaml:"anthropic_version,omitempty"` // 默认 "2023-06-01"
}
ClaudeConfig Claude Provider 配置
type DeepSeekConfig ¶
type DeepSeekConfig struct {
BaseProviderConfig `yaml:",inline"`
}
DeepSeekConfig DeepSeek Provider 配置
type DoubaoConfig ¶
type DoubaoConfig struct {
BaseProviderConfig `yaml:",inline"`
AccessKey string `json:"access_key,omitempty" yaml:"access_key,omitempty"` // 火山引擎 Access Key
SecretKey string `json:"secret_key,omitempty" yaml:"secret_key,omitempty"` // 火山引擎 Secret Key
Region string `json:"region,omitempty" yaml:"region,omitempty"` // 区域,默认 cn-beijing
}
DoubaoConfig ByteDance Doubao Provider 配置
type GLMConfig ¶
type GLMConfig struct {
BaseProviderConfig `yaml:",inline"`
}
GLMConfig Zhipu AI GLM Provider 配置
type GeminiConfig ¶
type GeminiConfig struct {
BaseProviderConfig `yaml:",inline"`
ProjectID string `json:"project_id,omitempty" yaml:"project_id,omitempty"`
Region string `json:"region,omitempty" yaml:"region,omitempty"`
AuthType string `json:"auth_type,omitempty" yaml:"auth_type,omitempty"` // "api_key"(默认) | "oauth"
SafetySettings []GeminiSafetySetting `json:"safety_settings,omitempty" yaml:"safety_settings,omitempty"`
}
GeminiConfig Gemini Provider 配置
type GeminiSafetySetting ¶ added in v1.2.0
type GeminiSafetySetting struct {
Category string `json:"category" yaml:"category"`
Threshold string `json:"threshold" yaml:"threshold"`
}
GeminiSafetySetting configures safety filter thresholds. Category: HARM_CATEGORY_HARASSMENT, HARM_CATEGORY_HATE_SPEECH,
HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_CIVIC_INTEGRITY.
Threshold: BLOCK_NONE, BLOCK_LOW_AND_ABOVE, BLOCK_MEDIUM_AND_ABOVE, BLOCK_HIGH_AND_ABOVE.
type GrokConfig ¶
type GrokConfig struct {
BaseProviderConfig `yaml:",inline"`
}
GrokConfig xAI Grok Provider 配置
type HunyuanConfig ¶
type HunyuanConfig struct {
BaseProviderConfig `yaml:",inline"`
}
HunyuanConfig Tencent Hunyuan Provider 配置
type KimiConfig ¶
type KimiConfig struct {
BaseProviderConfig `yaml:",inline"`
}
KimiConfig Moonshot Kimi Provider 配置
type LlamaConfig ¶
type LlamaConfig struct {
BaseProviderConfig `yaml:",inline"`
Provider string `json:"provider,omitempty" yaml:"provider,omitempty"` // together/replicate/openrouter
}
LlamaConfig Meta Llama Provider 配置 (via Together AI/Replicate)
type MiniMaxConfig ¶
type MiniMaxConfig struct {
BaseProviderConfig `yaml:",inline"`
}
MiniMaxConfig MiniMax Provider 配置
type MistralConfig ¶
type MistralConfig struct {
BaseProviderConfig `yaml:",inline"`
}
MistralConfig Mistral AI Provider 配置
type OpenAIConfig ¶
type OpenAIConfig struct {
BaseProviderConfig `yaml:",inline"`
Organization string `json:"organization,omitempty" yaml:"organization,omitempty"`
UseResponsesAPI bool `json:"use_responses_api,omitempty" yaml:"use_responses_api,omitempty"` // 启用新的 Responses API (2025)
}
OpenAIConfig OpenAI Provider 配置
type PollConfig ¶ added in v1.4.6
type PollConfig struct {
Interval time.Duration // 轮询间隔,默认 5s
MaxAttempts int // 最大尝试次数,0 表示无限(依赖 ctx 超时)
}
PollConfig 配置轮询行为。
type PollFunc ¶ added in v1.4.6
type PollFunc[T any] func(ctx context.Context) PollResult[T]
PollFunc 是轮询回调函数,每次 tick 调用一次。 返回 PollResult 指示任务状态。
type PollResult ¶ added in v1.4.6
type PollResult[T any] struct { Done bool // 任务是否完成(成功或失败) Result *T // 成功时的结果 Err error // 失败时的错误(设置 Done=true + Err 表示任务失败) }
PollResult 表示单次轮询检查的结果。
type ProviderCapability ¶ added in v1.4.6
type ProviderCapability struct {
Provider string
Image bool
Video bool
AudioGenerate bool
AudioSTT bool
Embedding bool
FineTuning bool
Rerank bool
}
ProviderCapability declares implemented multimodal capabilities per chat provider. Keep this as the single source of truth for docs matrix generation.
type QwenConfig ¶
type QwenConfig struct {
BaseProviderConfig `yaml:",inline"`
}
QwenConfig Alibaba Qwen Provider 配置