feat: Refactor tenant configuration management to use KV API
- Updated tenant web search and agent configuration endpoints to utilize a KV-style API for better flexibility. - Enhanced the tenant handler to support generic key-value operations for retrieving and updating configurations. - Improved frontend API calls to align with the new KV API structure, ensuring consistent data handling. - Removed deprecated direct configuration endpoints for a cleaner and more maintainable codebase.
This commit is contained in:
@@ -5,6 +5,12 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultAgentTemperature = 0.7
|
||||
DefaultAgentMaxIterations = 20
|
||||
DefaultAgentReflectionEnabled = false
|
||||
)
|
||||
|
||||
// formatFileSize formats file size in human-readable format
|
||||
func formatFileSize(size int64) string {
|
||||
const (
|
||||
@@ -42,6 +48,24 @@ type KnowledgeBaseInfo struct {
|
||||
RecentDocs []RecentDocInfo // Recently added documents (up to 10)
|
||||
}
|
||||
|
||||
// PlaceholderDefinition defines a placeholder exposed to UI/configuration
|
||||
type PlaceholderDefinition struct {
|
||||
Name string `json:"name"`
|
||||
Label string `json:"label"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// AvailablePlaceholders lists all supported prompt placeholders for UI hints
|
||||
func AvailablePlaceholders() []PlaceholderDefinition {
|
||||
return []PlaceholderDefinition{
|
||||
{
|
||||
Name: "knowledge_bases",
|
||||
Label: "知识库列表",
|
||||
Description: "自动格式化为表格形式的知识库列表,包含知识库名称、描述、文档数量、最近添加的文档等信息",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// formatKnowledgeBaseList formats knowledge base information for the prompt
|
||||
func formatKnowledgeBaseList(kbInfos []*KnowledgeBaseInfo) string {
|
||||
if len(kbInfos) == 0 {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package tools
|
||||
|
||||
// AvailableTool defines a simple tool metadata used by settings APIs.
|
||||
type AvailableTool struct {
|
||||
Name string `json:"name"`
|
||||
Label string `json:"label"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// AvailableToolDefinitions returns the list of tools exposed to the UI.
|
||||
// Keep this in sync with registered tools in this package.
|
||||
func AvailableToolDefinitions() []AvailableTool {
|
||||
return []AvailableTool{
|
||||
{Name: "thinking", Label: "思考", Description: "AI 进行深度思考和推理"},
|
||||
{Name: "todo_write", Label: "制定计划", Description: "为复杂任务制定执行计划"},
|
||||
{Name: "knowledge_search", Label: "知识搜索", Description: "在知识库中搜索相关信息"},
|
||||
{Name: "get_related_chunks", Label: "获取相关片段", Description: "查找相关的知识片段"},
|
||||
{Name: "query_knowledge_graph", Label: "查询知识图谱", Description: "从知识图谱中查询关系"},
|
||||
{Name: "get_document_info", Label: "获取文档信息", Description: "查看文档元数据"},
|
||||
{Name: "database_query", Label: "查询数据库", Description: "查询数据库中的信息"},
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultAllowedTools returns the default allowed tools list.
|
||||
func DefaultAllowedTools() []string {
|
||||
return []string{
|
||||
"thinking",
|
||||
"todo_write",
|
||||
"knowledge_search",
|
||||
"get_related_chunks",
|
||||
"query_knowledge_graph",
|
||||
"get_document_info",
|
||||
"database_query",
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user