feat(thinkingControl): implement thinking mode configuration in model editor

- Added a new thinking mode control field in the ModelEditorDialog, allowing users to specify how the agent's thinking mode is formatted for API requests.
- Introduced localization strings for thinking mode labels and descriptions in English, Korean, Russian, and Chinese, enhancing user experience across multiple languages.
- Updated the model form data structure to include thinking control settings, ensuring proper handling during model edits and saves.
- Implemented utility functions for resolving and defaulting thinking control values based on provider and model, improving backend integration.
- Added tests for the new thinking control functionality to ensure reliability and correctness in handling user configurations.
This commit is contained in:
wizardchen
2026-06-05 14:42:08 +08:00
committed by lyingbug
parent 063809896a
commit e2a41ecf0a
26 changed files with 2075 additions and 1206 deletions
+4 -24
View File
@@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"net/http"
"strings"
"github.com/Tencent/WeKnora/internal/models/provider"
@@ -150,7 +149,9 @@ func NewChat(config *ChatConfig, ollamaService *ollama.OllamaService) (Chat, err
return wrapChatLangfuse(c, err)
}
// NewRemoteChat 根据 provider 创建远程聊天实例
// NewRemoteChat 根据 provider 创建远程聊天实例。
// Anthropic 走独立的 Messages 协议实现;其余 OpenAI 兼容供应商统一由
// RemoteAPIChat 处理,provider 特定行为在构造时通过 providerAdapter 解析。
func NewRemoteChat(config *ChatConfig) (Chat, error) {
providerName := provider.ProviderName(config.Provider)
if providerName == "" {
@@ -159,26 +160,5 @@ func NewRemoteChat(config *ChatConfig) (Chat, error) {
if providerName == provider.ProviderAnthropic {
return NewAnthropicChat(config)
}
remoteChat, err := NewRemoteAPIChat(config)
if err != nil {
return nil, err
}
// Look up provider-specific behavior from spec registry
if spec := findProviderSpec(providerName, config.ModelName); spec != nil {
if spec.RequestCustomizer != nil {
remoteChat.SetRequestCustomizer(spec.RequestCustomizer)
}
if spec.EndpointCustomizer != nil {
remoteChat.SetEndpointCustomizer(spec.EndpointCustomizer)
}
if spec.HeaderCustomizer != nil {
remoteChat.SetHeaderCustomizer(func(req *http.Request, body []byte) error {
return spec.HeaderCustomizer(remoteChat, req, body)
})
}
}
return remoteChat, nil
return NewRemoteAPIChat(config)
}