Documentation
¶
Overview ¶
Package llm 提供精简版 LLM 健康检查
Package llm 提供统一的 LLM 客户端,支持 OpenAI Chat、OpenAI Responses 和 Anthropic 三种 API 格式
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChatRequest ¶
type ChatRequest struct {
Messages []Message `json:"messages"`
Model string `json:"model,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
System string `json:"system,omitempty"`
InterfaceType InterfaceType `json:"interface_type,omitempty"`
}
ChatRequest 聊天请求
type ChatResponse ¶
ChatResponse 聊天响应
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client LLM 客户端
func (*Client) Chat ¶
func (c *Client) Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error)
Chat 发送聊天请求(统一入口)
func (*Client) ChatNoException ¶
func (c *Client) ChatNoException(ctx context.Context, req ChatRequest) (*ChatResponse, error)
ChatNoException 发送聊天请求,出错时返回错误信息而不是抛出异常
type ClientOption ¶
type ClientOption func(*Client)
ClientOption 客户端配置选项
func WithInterfaceType ¶
func WithInterfaceType(t InterfaceType) ClientOption
WithInterfaceType 设置接口类型
type Config ¶
type Config struct {
BaseURL string `json:"base_url,omitempty"`
APIKey string `json:"api_key"`
Model string `json:"model"`
InterfaceType InterfaceType `json:"interface_type,omitempty"`
}
Config 健康检查配置
type InterfaceType ¶
type InterfaceType string
InterfaceType 定义 API 接口类型
const ( InterfaceOpenAIChat InterfaceType = "openai_chat" InterfaceOpenAIResponses InterfaceType = "openai_responses" InterfaceAnthropic InterfaceType = "anthropic" )
Click to show internal directories.
Click to hide internal directories.