Documentation
¶
Index ¶
- Variables
- type ChatResponse
- type OpenAI
- func (o *OpenAI) Chat(message string) (*common.Response, error)
- func (o *OpenAI) ResetDialog()
- func (o *OpenAI) SetApiKey(apiKey string) *OpenAI
- func (o *OpenAI) SetFunTools(funList ...common.ToolFunction) *OpenAI
- func (o *OpenAI) SetMaxRounds(maxRounds int) *OpenAI
- func (o *OpenAI) SetMaxTokens(maxTokens int) *OpenAI
- func (o *OpenAI) SetResponseType(t string) *OpenAI
- func (o *OpenAI) SetStream(enable bool) *OpenAI
- func (o *OpenAI) SetSystem(prompt string) *OpenAI
- func (o *OpenAI) SetTemperature(temperature float64) *OpenAI
- func (o *OpenAI) SetTopK(topK float64) *OpenAI
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DeepSeekR1 深度思考模型 DeepSeekR1 = common.Model{ Url: "https://api.deepseek.com/chat/completions", ModelType: "deepseek-reasoner", IsReason: true, } // DeepSeekV3 对话模型 DeepSeekV3 = common.Model{ Url: "https://api.deepseek.com/chat/completions", ModelType: "deepseek-chat", IsReason: false, } // IflytekX 讯飞星火对话模型 IflytekX = common.Model{ Url: "http://maas-api.cn-huabei-1.xf-yun.com/v1/chat/completions", ModelType: "xsparkprox", IsReason: false, } )
Functions ¶
This section is empty.
Types ¶
type ChatResponse ¶
type ChatResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Choices []struct {
Message struct {
Role string `json:"role"`
Content string `json:"content"`
} `json:"message"`
FinishReason string `json:"finish_reason"`
} `json:"choices"`
Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
} `json:"usage"`
}
ChatResponse 响应结构体(根据实际 API 响应格式调整)
func (*ChatResponse) Message ¶
func (cr *ChatResponse) Message() string
func (*ChatResponse) Think ¶
func (cr *ChatResponse) Think() string
type OpenAI ¶
type OpenAI struct {
// contains filtered or unexported fields
}
func NewOpenAiClient ¶
func (*OpenAI) SetFunTools ¶ added in v0.0.5
func (o *OpenAI) SetFunTools(funList ...common.ToolFunction) *OpenAI
SetFunTools 设置函数工具
func (*OpenAI) SetMaxRounds ¶
SetMaxRounds 设置历史保存轮数
func (*OpenAI) SetMaxTokens ¶
SetMaxTokens 设置最大token数
func (*OpenAI) SetResponseType ¶ added in v0.0.4
SetResponseType 设置OpenAI实例的响应格式类型。
func (*OpenAI) SetTemperature ¶
SetTemperature 设置模型温度 0~1 值越高模型约自由发挥
Click to show internal directories.
Click to hide internal directories.