Documentation
¶
Overview ¶
Package model 提供 OpenAI-Compatible 模型调用(DeepSeek / 月之暗面 / 通义 / 自托管 等)。
范围:M1 只需要 Complete(非流式 + tool_calls)。后续如需流式,可平移用户既有的 CompleteStream 实现(同一组类型)。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FunctionCall ¶
type FunctionSchema ¶
type Message ¶
type Message struct {
Role string `json:"role"`
Content string `json:"content,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"` // assistant 消息携带模型决定要调的工具
ToolCallID string `json:"tool_call_id,omitempty"` // tool 消息:对应哪一次工具调用
Name string `json:"name,omitempty"`
}
Message 一条对话消息。role: system / user / assistant / tool。
type OpenAICompatibleProvider ¶
OpenAICompatibleProvider 调用任何 OpenAI-Compatible /chat/completions 端点 (DeepSeek / Moonshot / 通义 / 自托管 vLLM 等)。M1 只用 Complete(非流式)。
func NewOpenAICompatibleProvider ¶
func NewOpenAICompatibleProvider(baseURL, apiKey string) *OpenAICompatibleProvider
type Request ¶
type Request struct {
Model string `json:"-"`
Messages []Message `json:"messages"`
Temperature float64 `json:"temperature,omitempty"`
Tools []ToolDefinition `json:"tools,omitempty"`
// ToolChoice 可为字符串("auto"/"none"/"required")或对象
// ({"type":"function","function":{"name":"X"}} 强制调用某个函数)。
ToolChoice any `json:"tool_choice,omitempty"`
}
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type"` // 目前固定 "function"
Function FunctionCall `json:"function"`
}
ToolCall 模型一次工具调用(assistant 消息里的 tool_calls 元素)。
type ToolDefinition ¶
type ToolDefinition struct {
Type string `json:"type"` // "function"
Function FunctionSchema `json:"function"`
}
ToolDefinition 我们告诉模型可用的工具。
Click to show internal directories.
Click to hide internal directories.