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.main
parent
aed88d4d9d
commit
4dd481560d
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue