diff --git a/cmd/server/main.go b/cmd/server/main.go index 9502953..4f1ea4d 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -31,9 +31,9 @@ func main() { gin.SetMode(gin.ReleaseMode) } else { gin.SetMode(gin.DebugMode) - //config.SetEnv() - } + } + //config.SetEnv() // Build dependency injection container c := container.BuildContainer(runtime.GetContainer()) diff --git a/config/config.yaml b/config/config.yaml index 9a71c1c..a2d9b90 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -200,12 +200,13 @@ conversation: repeat_penalty: 1.0 temperature: 0.3 max_completion_tokens: 2048 + thinking: true no_match_prefix: |- NO_MATCH prompt: | - 这是用户和助手之间的对话。当用户提出问题时,助手会基于特定的信息进行解答。直接提供答案,没有思考过程 + 这是用户和助手之间的对话。当用户提出问题时,助手会基于特定的信息进行解答。直接提供答案 context_template: | ## 回答问题规则 - 回答问题仅依据检索到的信息中的事实,不利用任何先验知识。 diff --git a/internal/application/service/chat_pipline/common.go b/internal/application/service/chat_pipline/common.go index d153cdb..960cf23 100644 --- a/internal/application/service/chat_pipline/common.go +++ b/internal/application/service/chat_pipline/common.go @@ -22,6 +22,7 @@ func prepareChatModel(ctx context.Context, modelService interfaces.ModelService, } logger.Info(ctx, "Setting up chat options") + opt := &chat.ChatOptions{ Temperature: chatManage.SummaryConfig.Temperature, TopP: chatManage.SummaryConfig.TopP, @@ -30,7 +31,7 @@ func prepareChatModel(ctx context.Context, modelService interfaces.ModelService, MaxCompletionTokens: chatManage.SummaryConfig.MaxCompletionTokens, FrequencyPenalty: chatManage.SummaryConfig.FrequencyPenalty, PresencePenalty: chatManage.SummaryConfig.PresencePenalty, - Thinking: chatManage.SummaryConfig.Thinking, + Thinking: &chatManage.SummaryConfig.Thinking, } return chatModel, opt, nil diff --git a/internal/config/config.go b/internal/config/config.go index 0a7d9ee..2e03cb3 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -81,6 +81,7 @@ type SummaryConfig struct { Seed int `yaml:"seed" json:"seed"` MaxCompletionTokens int `yaml:"max_completion_tokens" json:"max_completion_tokens"` NoMatchPrefix string `yaml:"no_match_prefix" json:"no_match_prefix"` + Thinking bool `yaml:"thinking" json:"thinking"` } // ServerConfig 服务器配置 diff --git a/internal/handler/session.go b/internal/handler/session.go index 2bbd1d8..cc1b993 100644 --- a/internal/handler/session.go +++ b/internal/handler/session.go @@ -74,6 +74,7 @@ type SessionStrategy struct { SummaryParameters *types.SummaryConfig `json:"summary_parameters" gorm:"type:json"` // Prefix for responses when no match is found NoMatchPrefix string `json:"no_match_prefix"` + Thinking bool `json:"thinking"` } // CreateSessionRequest represents a request to create a new session @@ -141,6 +142,7 @@ func (h *SessionHandler) CreateSession(c *gin.Context) { createdSession.RerankThreshold = request.SessionStrategy.RerankThreshold if request.SessionStrategy.SummaryParameters != nil { createdSession.SummaryParameters = request.SessionStrategy.SummaryParameters + createdSession.SummaryParameters.Thinking = true } else { createdSession.SummaryParameters = &types.SummaryConfig{ MaxTokens: h.config.Conversation.Summary.MaxTokens, @@ -153,6 +155,7 @@ func (h *SessionHandler) CreateSession(c *gin.Context) { Temperature: h.config.Conversation.Summary.Temperature, Seed: h.config.Conversation.Summary.Seed, MaxCompletionTokens: h.config.Conversation.Summary.MaxCompletionTokens, + Thinking: h.config.Conversation.Summary.Thinking, } } if createdSession.SummaryParameters.Prompt == "" { @@ -190,6 +193,7 @@ func (h *SessionHandler) CreateSession(c *gin.Context) { Temperature: h.config.Conversation.Summary.Temperature, Seed: h.config.Conversation.Summary.Seed, MaxCompletionTokens: h.config.Conversation.Summary.MaxCompletionTokens, + Thinking: h.config.Conversation.Summary.Thinking, } logger.Debug(ctx, "Using default session strategy") diff --git a/internal/types/session.go b/internal/types/session.go index 40f2000..65b579d 100644 --- a/internal/types/session.go +++ b/internal/types/session.go @@ -43,7 +43,7 @@ type SummaryConfig struct { // Max completion tokens MaxCompletionTokens int `json:"max_completion_tokens"` // Think - Thinking *bool `json:"thinking"` + Thinking bool `json:"thinking"` } // Session represents the session