Documentation
¶
Index ¶
- type AIClient
- func (c *AIClient) Chat(req *aiconfig.ChatRequest) (*aiconfig.ChatResponse, error)
- func (c *AIClient) ChatStream(req *aiconfig.ChatRequest) (<-chan *aiconfig.ChatResponse, error)
- func (c *AIClient) GetLogger() xlog.Logger
- func (c *AIClient) GetModels() []string
- func (c *AIClient) GetProvider() aiconfig.AIProvider
- func (c *AIClient) GetProviderName() string
- func (c *AIClient) SetLogger(logger xlog.Logger)
- type AIClientManager
- func (m *AIClientManager) AddClient(providerType aiconfig.ProviderType, config *aiconfig.Config) error
- func (m *AIClientManager) AddClientFromEnv(providerType aiconfig.ProviderType) error
- func (m *AIClientManager) ChatStreamWithFallback(providerTypes []aiconfig.ProviderType, req *aiconfig.ChatRequest) (<-chan *aiconfig.ChatResponse, error)
- func (m *AIClientManager) ChatStreamWithProvider(providerType aiconfig.ProviderType, req *aiconfig.ChatRequest) (<-chan *aiconfig.ChatResponse, error)
- func (m *AIClientManager) ChatWithFallback(providerTypes []aiconfig.ProviderType, req *aiconfig.ChatRequest) (*aiconfig.ChatResponse, error)
- func (m *AIClientManager) ChatWithProvider(providerType aiconfig.ProviderType, req *aiconfig.ChatRequest) (*aiconfig.ChatResponse, error)
- func (m *AIClientManager) GetClient(providerType aiconfig.ProviderType) (*AIClient, error)
- func (m *AIClientManager) GetDefaultClient() (*AIClient, error)
- func (m *AIClientManager) ListClients() []aiconfig.ProviderType
- func (m *AIClientManager) RemoveClient(providerType aiconfig.ProviderType)
- func (m *AIClientManager) SetLogger(logger xlog.Logger)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AIClient ¶
type AIClient struct {
// contains filtered or unexported fields
}
AIClient AI客户端
func NewAIClient ¶
NewAIClient 创建AI客户端
func NewAIClientFromEnv ¶
func NewAIClientFromEnv(providerType aiconfig.ProviderType) (*AIClient, error)
NewAIClientFromEnv 从环境变量创建AI客户端
func (*AIClient) Chat ¶
func (c *AIClient) Chat(req *aiconfig.ChatRequest) (*aiconfig.ChatResponse, error)
Chat 发送聊天请求
func (*AIClient) ChatStream ¶
func (c *AIClient) ChatStream(req *aiconfig.ChatRequest) (<-chan *aiconfig.ChatResponse, error)
ChatStream 发送流式聊天请求
func (*AIClient) GetProvider ¶
func (c *AIClient) GetProvider() aiconfig.AIProvider
GetProvider 获取提供者
func (*AIClient) GetProviderName ¶
GetProviderName 获取提供者名称
type AIClientManager ¶
type AIClientManager struct {
// contains filtered or unexported fields
}
AIClientManager AI客户端管理器
func (*AIClientManager) AddClient ¶
func (m *AIClientManager) AddClient(providerType aiconfig.ProviderType, config *aiconfig.Config) error
AddClient 添加客户端
func (*AIClientManager) AddClientFromEnv ¶
func (m *AIClientManager) AddClientFromEnv(providerType aiconfig.ProviderType) error
AddClientFromEnv 从环境变量添加客户端
func (*AIClientManager) ChatStreamWithFallback ¶
func (m *AIClientManager) ChatStreamWithFallback(providerTypes []aiconfig.ProviderType, req *aiconfig.ChatRequest) (<-chan *aiconfig.ChatResponse, error)
ChatStreamWithFallback 使用多个提供者发送流式聊天请求(带降级)
func (*AIClientManager) ChatStreamWithProvider ¶
func (m *AIClientManager) ChatStreamWithProvider(providerType aiconfig.ProviderType, req *aiconfig.ChatRequest) (<-chan *aiconfig.ChatResponse, error)
ChatStreamWithProvider 使用指定提供者发送流式聊天请求
func (*AIClientManager) ChatWithFallback ¶
func (m *AIClientManager) ChatWithFallback(providerTypes []aiconfig.ProviderType, req *aiconfig.ChatRequest) (*aiconfig.ChatResponse, error)
ChatWithFallback 使用多个提供者发送聊天请求(带降级)
func (*AIClientManager) ChatWithProvider ¶
func (m *AIClientManager) ChatWithProvider(providerType aiconfig.ProviderType, req *aiconfig.ChatRequest) (*aiconfig.ChatResponse, error)
ChatWithProvider 使用指定提供者发送聊天请求
func (*AIClientManager) GetClient ¶
func (m *AIClientManager) GetClient(providerType aiconfig.ProviderType) (*AIClient, error)
GetClient 获取客户端
func (*AIClientManager) GetDefaultClient ¶
func (m *AIClientManager) GetDefaultClient() (*AIClient, error)
GetDefaultClient 获取默认客户端(OpenAI)
func (*AIClientManager) ListClients ¶
func (m *AIClientManager) ListClients() []aiconfig.ProviderType
ListClients 列出所有客户端
func (*AIClientManager) RemoveClient ¶
func (m *AIClientManager) RemoveClient(providerType aiconfig.ProviderType)
RemoveClient 移除客户端
func (*AIClientManager) SetLogger ¶
func (m *AIClientManager) SetLogger(logger xlog.Logger)
SetLogger 设置日志记录器
Click to show internal directories.
Click to hide internal directories.