refactor(chat): simplify temperature option handling in chat request builders

- Streamlined the handling of the temperature option in both OllamaChat and RemoteAPIChat by removing unnecessary conditional checks.
- Ensured that the temperature value is directly assigned when options are provided, improving code clarity and reducing complexity.
This commit is contained in:
wizardchen
2026-03-31 12:11:21 +08:00
committed by lyingbug
parent aed88d4d9d
commit 4dd481560d
2 changed files with 2 additions and 6 deletions
+1 -3
View File
@@ -93,9 +93,7 @@ func (c *OllamaChat) buildChatRequest(messages []Message, opts *ChatOptions, isS
// 添加可选参数
if opts != nil {
if opts.Temperature > 0 {
chatReq.Options["temperature"] = opts.Temperature
}
chatReq.Options["temperature"] = opts.Temperature
if opts.TopP > 0 {
chatReq.Options["top_p"] = opts.TopP
}
+1 -3
View File
@@ -177,9 +177,7 @@ func (c *RemoteAPIChat) BuildChatCompletionRequest(messages []Message, opts *Cha
}
if opts != nil {
if opts.Temperature > 0 {
req.Temperature = float32(opts.Temperature)
}
req.Temperature = float32(opts.Temperature)
if opts.TopP > 0 {
req.TopP = float32(opts.TopP)
}