feat: Revamp conversation configuration management and enhance localization

- Removed outdated DEVELOPMENT.md, consolidating development instructions into relevant documentation.
- Updated conversation configuration to include new parameters such as max rounds, embedding thresholds, and rewrite prompts.
- Enhanced UI components to support new conversation settings, including AgentSettings.vue and related views.
- Improved localization in English, Russian, and Chinese for new conversation configuration fields and UI elements.
- Implemented logic to apply tenant-specific conversation settings, ensuring defaults are respected.
This commit is contained in:
wizardchen
2025-11-18 23:18:43 +08:00
parent 60240ee337
commit ddf6b4e748
36 changed files with 2941 additions and 1914 deletions
@@ -2,6 +2,10 @@ package chatpipline
import (
"context"
"fmt"
"sort"
"strconv"
"strings"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/models/chat"
@@ -9,6 +13,78 @@ import (
"github.com/Tencent/WeKnora/internal/types/interfaces"
)
const (
logValueMaxRune = 300
defaultStageName = "PIPELINE"
defaultActionName = "info"
pipelineLogPrefix = "[PIPELINE]"
pipelineTruncateEll = "..."
)
func pipelineLog(stage, action string, fields map[string]interface{}) string {
if stage == "" {
stage = defaultStageName
}
if action == "" {
action = defaultActionName
}
builder := strings.Builder{}
builder.Grow(128)
builder.WriteString(pipelineLogPrefix)
builder.WriteString(" stage=")
builder.WriteString(stage)
builder.WriteString(" action=")
builder.WriteString(action)
if len(fields) > 0 {
keys := make([]string, 0, len(fields))
for k := range fields {
keys = append(keys, k)
}
sort.Strings(keys)
for _, key := range keys {
builder.WriteString(" ")
builder.WriteString(key)
builder.WriteString("=")
builder.WriteString(formatLogValue(fields[key]))
}
}
return builder.String()
}
func pipelineInfo(ctx context.Context, stage, action string, fields map[string]interface{}) {
logger.GetLogger(ctx).Info(pipelineLog(stage, action, fields))
}
func pipelineWarn(ctx context.Context, stage, action string, fields map[string]interface{}) {
logger.GetLogger(ctx).Warn(pipelineLog(stage, action, fields))
}
func pipelineError(ctx context.Context, stage, action string, fields map[string]interface{}) {
logger.GetLogger(ctx).Error(pipelineLog(stage, action, fields))
}
func formatLogValue(value interface{}) string {
switch v := value.(type) {
case string:
return strconv.Quote(truncateForLog(v))
case fmt.Stringer:
return strconv.Quote(truncateForLog(v.String()))
default:
return fmt.Sprintf("%v", v)
}
}
func truncateForLog(content string) string {
content = strings.ReplaceAll(content, "\n", "\\n")
runes := []rune(content)
if len(runes) <= logValueMaxRune {
return content
}
return string(runes[:logValueMaxRune]) + pipelineTruncateEll
}
// prepareChatModel shared logic to prepare chat model and options
func prepareChatModel(ctx context.Context, modelService interfaces.ModelService,
chatManage *types.ChatManage,
@@ -35,14 +111,6 @@ func prepareChatModel(ctx context.Context, modelService interfaces.ModelService,
return chatModel, opt, nil
}
// prepareBaseMessages prepare basic messages (system prompt and current user content)
func prepareBaseMessages(chatManage *types.ChatManage) []chat.Message {
var chatMessages []chat.Message
chatMessages = append(chatMessages, chat.Message{Role: "system", Content: chatManage.SummaryConfig.Prompt})
chatMessages = append(chatMessages, chat.Message{Role: "user", Content: chatManage.UserContent})
return chatMessages
}
// prepareMessagesWithHistory prepare complete messages including history
func prepareMessagesWithHistory(chatManage *types.ChatManage) []chat.Message {
chatMessages := []chat.Message{