fix: Adjust temperature validation to allow zero as a valid setting and default only for negative values.

This commit is contained in:
Andy Yang
2026-03-19 18:50:32 +08:00
committed by lyingbug
parent a4d3d69843
commit 5c31a9123f
3 changed files with 4 additions and 4 deletions
@@ -118,7 +118,7 @@ func (s *sessionService) applyAgentOverridesToChatManage(
cm.SummaryConfig.ContextTemplate = customAgent.Config.ContextTemplate cm.SummaryConfig.ContextTemplate = customAgent.Config.ContextTemplate
logger.Infof(ctx, "Using custom agent's context_template") logger.Infof(ctx, "Using custom agent's context_template")
} }
if customAgent.Config.Temperature > 0 { if customAgent.Config.Temperature >= 0 {
cm.SummaryConfig.Temperature = customAgent.Config.Temperature cm.SummaryConfig.Temperature = customAgent.Config.Temperature
logger.Infof(ctx, "Using custom agent's temperature: %f", customAgent.Config.Temperature) logger.Infof(ctx, "Using custom agent's temperature: %f", customAgent.Config.Temperature)
} }
+2 -2
View File
@@ -286,7 +286,7 @@ func (h *Handler) createDefaultSummaryConfig(ctx context.Context) *types.Summary
if tenant.ConversationConfig.ContextTemplate != "" { if tenant.ConversationConfig.ContextTemplate != "" {
cfg.ContextTemplate = tenant.ConversationConfig.ContextTemplate cfg.ContextTemplate = tenant.ConversationConfig.ContextTemplate
} }
if tenant.ConversationConfig.Temperature > 0 { if tenant.ConversationConfig.Temperature >= 0 {
cfg.Temperature = tenant.ConversationConfig.Temperature cfg.Temperature = tenant.ConversationConfig.Temperature
} }
if tenant.ConversationConfig.MaxCompletionTokens > 0 { if tenant.ConversationConfig.MaxCompletionTokens > 0 {
@@ -344,7 +344,7 @@ func (h *Handler) fillSummaryConfigDefaults(ctx context.Context, config *types.S
if config.ContextTemplate == "" { if config.ContextTemplate == "" {
config.ContextTemplate = defaultContextTemplate config.ContextTemplate = defaultContextTemplate
} }
if config.Temperature == 0 { if config.Temperature < 0 {
config.Temperature = defaultTemperature config.Temperature = defaultTemperature
} }
if config.MaxCompletionTokens == 0 { if config.MaxCompletionTokens == 0 {
+1 -1
View File
@@ -211,7 +211,7 @@ func (a *CustomAgent) EnsureDefaults() {
if a == nil { if a == nil {
return return
} }
if a.Config.Temperature == 0 { if a.Config.Temperature < 0 {
a.Config.Temperature = 0.7 a.Config.Temperature = 0.7
} }
if a.Config.MaxIterations == 0 { if a.Config.MaxIterations == 0 {