This commit is contained in:
lychang
2026-05-21 01:57:25 +08:00
parent 7f5350db62
commit 10905c0acc
15 changed files with 7271 additions and 6387 deletions

View File

@@ -37,7 +37,10 @@ type ChatRequest struct {
TopP float64 `json:"top_p,omitempty"` // 采样参数
FrequencyPenalty float64 `json:"frequency_penalty,omitempty"` // 频率惩罚
PresencePenalty float64 `json:"presence_penalty,omitempty"` // 存在惩罚
Stream bool `json:"stream,omitempty"` // 是否流式输出
Stream bool `json:"stream"` // 是否流式输出
Thinking struct {
Type string `json:"type"`
} `json:"thinking"`
}
// OllamaMessage Ollama消息格式
@@ -113,10 +116,10 @@ func NewLLMClient(config LLMConfig) *LLMClient {
}
// NewOpenAIClient 创建OpenAI客户端
func NewOpenAIClient(apiKey, model string) *LLMClient {
func NewOpenAIClient(apiKey, model, baseURL string) *LLMClient {
config := LLMConfig{
APIKey: apiKey,
BaseURL: "https://api.openai.com/v1",
BaseURL: baseURL,
Model: model,
Provider: "openai",
Temperature: 0.1,
@@ -149,6 +152,12 @@ func (c *LLMClient) Chat(messages []ChatMessage) (*ChatResponse, error) {
Messages: messages,
Temperature: c.config.Temperature,
MaxTokens: c.config.MaxTokens,
Stream: false,
Thinking: struct {
Type string `json:"type"`
}{
Type: "disabled",
},
}
return c.sendChatRequest(request)