refactor: 将客服后端重构为宿主可嵌入模块

- 注入数据库、运行时配置、统一响应、文件存储和平台 AI 能力,补充业务读写工具与客户快捷操作契约。

- 移除模块内重复的组织、客户、工单、标签、技能、旧工作流、MCP 和迁移实现,将身份权限与业务主体交由宿主管理。

- 使用 libSQL 重构向量存储,并完善图片消息、访客身份、排队调度、企业微信和支持聊天页面。

- 统一 HTTP、DTO 与 WebSocket 的 snake_case 协议,补齐模块初始化、业务动作和公共载荷等回归测试。
This commit is contained in:
t
2026-08-28 22:23:13 +08:00
parent 6845c728f8
commit 18c9354095
377 changed files with 13199 additions and 22881 deletions
+153 -153
View File
@@ -9,109 +9,109 @@ type KnowledgeBaseResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
KnowledgeType string `json:"knowledgeType"`
KnowledgeTypeName string `json:"knowledgeTypeName"`
KnowledgeType string `json:"knowledge_type"`
KnowledgeTypeName string `json:"knowledge_type_name"`
Status enums.Status `json:"status"`
StatusName string `json:"statusName"`
DefaultTopK int `json:"defaultTopK"`
DefaultScoreThreshold float64 `json:"defaultScoreThreshold"`
DefaultRerankLimit int `json:"defaultRerankLimit"`
ChunkProvider string `json:"chunkProvider"`
ChunkTargetTokens int `json:"chunkTargetTokens"`
ChunkMaxTokens int `json:"chunkMaxTokens"`
ChunkOverlapTokens int `json:"chunkOverlapTokens"`
AnswerMode int `json:"answerMode"`
AnswerModeName string `json:"answerModeName"`
DocumentCount int64 `json:"documentCount"`
FAQCount int64 `json:"faqCount"`
StatusName string `json:"status_name"`
DefaultTopK int `json:"default_top_k"`
DefaultScoreThreshold float64 `json:"default_score_threshold"`
DefaultRerankLimit int `json:"default_rerank_limit"`
ChunkProvider string `json:"chunk_provider"`
ChunkTargetTokens int `json:"chunk_target_tokens"`
ChunkMaxTokens int `json:"chunk_max_tokens"`
ChunkOverlapTokens int `json:"chunk_overlap_tokens"`
AnswerMode int `json:"answer_mode"`
AnswerModeName string `json:"answer_mode_name"`
DocumentCount int64 `json:"document_count"`
FAQCount int64 `json:"faq_count"`
Remark string `json:"remark"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CreateUserName string `json:"createUserName"`
UpdateUserName string `json:"updateUserName"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreateUserName string `json:"create_user_name"`
UpdateUserName string `json:"update_user_name"`
}
type KnowledgeDocumentResponse struct {
ID int64 `json:"id"`
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
KnowledgeBaseName string `json:"knowledgeBaseName,omitempty"`
DirectoryID int64 `json:"directoryId"`
DirectoryName string `json:"directoryName,omitempty"`
DirectoryPath string `json:"directoryPath,omitempty"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
KnowledgeBaseName string `json:"knowledge_base_name,omitempty"`
DirectoryID int64 `json:"directory_id"`
DirectoryName string `json:"directory_name,omitempty"`
DirectoryPath string `json:"directory_path,omitempty"`
Title string `json:"title"`
ContentType enums.KnowledgeDocumentContentType `json:"contentType"`
ContentType enums.KnowledgeDocumentContentType `json:"content_type"`
Content string `json:"content"`
Status enums.Status `json:"status"`
StatusName string `json:"statusName"`
IndexStatus enums.KnowledgeDocumentIndexStatus `json:"indexStatus"`
IndexStatusName string `json:"indexStatusName"`
IndexedAt *time.Time `json:"indexedAt"`
IndexError string `json:"indexError"`
ContentHash string `json:"contentHash"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CreateUserName string `json:"createUserName"`
UpdateUserName string `json:"updateUserName"`
StatusName string `json:"status_name"`
IndexStatus enums.KnowledgeDocumentIndexStatus `json:"index_status"`
IndexStatusName string `json:"index_status_name"`
IndexedAt *time.Time `json:"indexed_at"`
IndexError string `json:"index_error"`
ContentHash string `json:"content_hash"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreateUserName string `json:"create_user_name"`
UpdateUserName string `json:"update_user_name"`
}
type KnowledgeDocumentListResponse struct {
ID int64 `json:"id"`
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
KnowledgeBaseName string `json:"knowledgeBaseName,omitempty"`
DirectoryID int64 `json:"directoryId"`
DirectoryName string `json:"directoryName,omitempty"`
DirectoryPath string `json:"directoryPath,omitempty"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
KnowledgeBaseName string `json:"knowledge_base_name,omitempty"`
DirectoryID int64 `json:"directory_id"`
DirectoryName string `json:"directory_name,omitempty"`
DirectoryPath string `json:"directory_path,omitempty"`
Title string `json:"title"`
ContentType enums.KnowledgeDocumentContentType `json:"contentType"`
ContentType enums.KnowledgeDocumentContentType `json:"content_type"`
Status enums.Status `json:"status"`
StatusName string `json:"statusName"`
IndexStatus enums.KnowledgeDocumentIndexStatus `json:"indexStatus"`
IndexStatusName string `json:"indexStatusName"`
IndexedAt *time.Time `json:"indexedAt"`
IndexError string `json:"indexError"`
ContentHash string `json:"contentHash"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CreateUserName string `json:"createUserName"`
UpdateUserName string `json:"updateUserName"`
StatusName string `json:"status_name"`
IndexStatus enums.KnowledgeDocumentIndexStatus `json:"index_status"`
IndexStatusName string `json:"index_status_name"`
IndexedAt *time.Time `json:"indexed_at"`
IndexError string `json:"index_error"`
ContentHash string `json:"content_hash"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreateUserName string `json:"create_user_name"`
UpdateUserName string `json:"update_user_name"`
}
type KnowledgeFAQResponse struct {
ID int64 `json:"id"`
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
KnowledgeBaseName string `json:"knowledgeBaseName,omitempty"`
DirectoryID int64 `json:"directoryId"`
DirectoryName string `json:"directoryName,omitempty"`
DirectoryPath string `json:"directoryPath,omitempty"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
KnowledgeBaseName string `json:"knowledge_base_name,omitempty"`
DirectoryID int64 `json:"directory_id"`
DirectoryName string `json:"directory_name,omitempty"`
DirectoryPath string `json:"directory_path,omitempty"`
Question string `json:"question"`
Answer string `json:"answer"`
SimilarQuestions []string `json:"similarQuestions"`
SimilarQuestions []string `json:"similar_questions"`
Status enums.Status `json:"status"`
StatusName string `json:"statusName"`
IndexStatus enums.KnowledgeDocumentIndexStatus `json:"indexStatus"`
IndexStatusName string `json:"indexStatusName"`
IndexedAt *time.Time `json:"indexedAt"`
IndexError string `json:"indexError"`
StatusName string `json:"status_name"`
IndexStatus enums.KnowledgeDocumentIndexStatus `json:"index_status"`
IndexStatusName string `json:"index_status_name"`
IndexedAt *time.Time `json:"indexed_at"`
IndexError string `json:"index_error"`
Remark string `json:"remark"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CreateUserName string `json:"createUserName"`
UpdateUserName string `json:"updateUserName"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreateUserName string `json:"create_user_name"`
UpdateUserName string `json:"update_user_name"`
}
type KnowledgeDirectoryResponse struct {
ID int64 `json:"id"`
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
ParentID int64 `json:"parentId"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
ParentID int64 `json:"parent_id"`
Name string `json:"name"`
SortNo int `json:"sortNo"`
SortNo int `json:"sort_no"`
Status enums.Status `json:"status"`
StatusName string `json:"statusName"`
StatusName string `json:"status_name"`
Remark string `json:"remark"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CreateUserName string `json:"createUserName"`
UpdateUserName string `json:"updateUserName"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreateUserName string `json:"create_user_name"`
UpdateUserName string `json:"update_user_name"`
Children []KnowledgeDirectoryResponse `json:"children"`
}
@@ -136,116 +136,116 @@ type KnowledgeFAQImportResult struct {
}
type KnowledgeSearchResult struct {
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
ChunkID int64 `json:"chunkId"`
DocumentID int64 `json:"documentId"`
DocumentTitle string `json:"documentTitle"`
FaqID int64 `json:"faqId"`
FaqQuestion string `json:"faqQuestion"`
ChunkNo int `json:"chunkNo"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
ChunkID int64 `json:"chunk_id"`
DocumentID int64 `json:"document_id"`
DocumentTitle string `json:"document_title"`
FaqID int64 `json:"faq_id"`
FaqQuestion string `json:"faq_question"`
ChunkNo int `json:"chunk_no"`
Title string `json:"title"`
SectionPath string `json:"sectionPath"`
SectionPath string `json:"section_path"`
Content string `json:"content"`
Score float64 `json:"score"`
RerankScore float64 `json:"rerankScore"`
RerankScore float64 `json:"rerank_score"`
}
type KnowledgeSearchResponse struct {
Question string `json:"question"`
Results []KnowledgeSearchResult `json:"results"`
HitCount int `json:"hitCount"`
LatencyMs int64 `json:"latencyMs"`
HitCount int `json:"hit_count"`
LatencyMs int64 `json:"latency_ms"`
}
type KnowledgeAnswerResponse struct {
Question string `json:"question"`
RewriteQuestion string `json:"rewriteQuestion,omitempty"`
RewriteQuestion string `json:"rewrite_question,omitempty"`
Answer string `json:"answer"`
AnswerStatus int `json:"answerStatus"`
AnswerStatusName string `json:"answerStatusName"`
AnswerStatus int `json:"answer_status"`
AnswerStatusName string `json:"answer_status_name"`
Citations []KnowledgeCitation `json:"citations"`
Hits []KnowledgeSearchResult `json:"hits"`
HitCount int `json:"hitCount"`
TopScore float64 `json:"topScore"`
LatencyMs int64 `json:"latencyMs"`
RetrieveMs int64 `json:"retrieveMs"`
GenerateMs int64 `json:"generateMs"`
PromptTokens int `json:"promptTokens"`
CompletionTokens int `json:"completionTokens"`
ModelName string `json:"modelName"`
RetrieveLogID int64 `json:"retrieveLogId"`
HitCount int `json:"hit_count"`
TopScore float64 `json:"top_score"`
LatencyMs int64 `json:"latency_ms"`
RetrieveMs int64 `json:"retrieve_ms"`
GenerateMs int64 `json:"generate_ms"`
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
ModelName string `json:"model_name"`
RetrieveLogID int64 `json:"retrieve_log_id"`
}
type KnowledgeCitation struct {
DocumentID int64 `json:"documentId"`
DocumentTitle string `json:"documentTitle"`
FaqID int64 `json:"faqId"`
FaqQuestion string `json:"faqQuestion"`
ChunkNo int `json:"chunkNo"`
DocumentID int64 `json:"document_id"`
DocumentTitle string `json:"document_title"`
FaqID int64 `json:"faq_id"`
FaqQuestion string `json:"faq_question"`
ChunkNo int `json:"chunk_no"`
Title string `json:"title"`
SectionPath string `json:"sectionPath"`
SectionPath string `json:"section_path"`
Snippet string `json:"snippet"`
Score float64 `json:"score"`
}
type KnowledgeRetrieveLogResponse struct {
ID int64 `json:"id"`
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
KnowledgeBaseName string `json:"knowledgeBaseName,omitempty"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
KnowledgeBaseName string `json:"knowledge_base_name,omitempty"`
Channel string `json:"channel"`
ChannelName string `json:"channelName"`
ChannelName string `json:"channel_name"`
Scene string `json:"scene"`
SceneName string `json:"sceneName"`
SessionID string `json:"sessionId"`
ConversationID int64 `json:"conversationId"`
RequestID string `json:"requestId"`
SceneName string `json:"scene_name"`
SessionID string `json:"session_id"`
ConversationID int64 `json:"conversation_id"`
RequestID string `json:"request_id"`
Question string `json:"question"`
RewriteQuestion string `json:"rewriteQuestion"`
RewriteQuestion string `json:"rewrite_question"`
Answer string `json:"answer"`
AnswerStatus int `json:"answerStatus"`
AnswerStatusName string `json:"answerStatusName"`
HitCount int `json:"hitCount"`
TopScore float64 `json:"topScore"`
ChunkProvider string `json:"chunkProvider"`
ChunkTargetTokens int `json:"chunkTargetTokens"`
ChunkMaxTokens int `json:"chunkMaxTokens"`
ChunkOverlapTokens int `json:"chunkOverlapTokens"`
RerankEnabled bool `json:"rerankEnabled"`
RerankLimit int `json:"rerankLimit"`
CitationCount int `json:"citationCount"`
UsedChunkCount int `json:"usedChunkCount"`
LatencyMs int64 `json:"latencyMs"`
RetrieveMs int64 `json:"retrieveMs"`
GenerateMs int64 `json:"generateMs"`
PromptTokens int `json:"promptTokens"`
CompletionTokens int `json:"completionTokens"`
ModelName string `json:"modelName"`
TraceData string `json:"traceData"`
CreatedAt time.Time `json:"createdAt"`
AnswerStatus int `json:"answer_status"`
AnswerStatusName string `json:"answer_status_name"`
HitCount int `json:"hit_count"`
TopScore float64 `json:"top_score"`
ChunkProvider string `json:"chunk_provider"`
ChunkTargetTokens int `json:"chunk_target_tokens"`
ChunkMaxTokens int `json:"chunk_max_tokens"`
ChunkOverlapTokens int `json:"chunk_overlap_tokens"`
RerankEnabled bool `json:"rerank_enabled"`
RerankLimit int `json:"rerank_limit"`
CitationCount int `json:"citation_count"`
UsedChunkCount int `json:"used_chunk_count"`
LatencyMs int64 `json:"latency_ms"`
RetrieveMs int64 `json:"retrieve_ms"`
GenerateMs int64 `json:"generate_ms"`
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
ModelName string `json:"model_name"`
TraceData string `json:"trace_data"`
CreatedAt time.Time `json:"created_at"`
}
type KnowledgeRetrieveHitResponse struct {
ID int64 `json:"id"`
RetrieveLogID int64 `json:"retrieveLogId"`
KnowledgeBaseID int64 `json:"knowledgeBaseId"`
ChunkID int64 `json:"chunkId"`
DocumentID int64 `json:"documentId"`
DocumentTitle string `json:"documentTitle"`
FaqID int64 `json:"faqId"`
FaqQuestion string `json:"faqQuestion"`
ChunkNo int `json:"chunkNo"`
RetrieveLogID int64 `json:"retrieve_log_id"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
ChunkID int64 `json:"chunk_id"`
DocumentID int64 `json:"document_id"`
DocumentTitle string `json:"document_title"`
FaqID int64 `json:"faq_id"`
FaqQuestion string `json:"faq_question"`
ChunkNo int `json:"chunk_no"`
Title string `json:"title"`
SectionPath string `json:"sectionPath"`
ChunkType string `json:"chunkType"`
ChunkTypeName string `json:"chunkTypeName"`
SectionPath string `json:"section_path"`
ChunkType string `json:"chunk_type"`
ChunkTypeName string `json:"chunk_type_name"`
Provider string `json:"provider"`
RankNo int `json:"rankNo"`
RankNo int `json:"rank_no"`
Score float64 `json:"score"`
RerankScore float64 `json:"rerankScore"`
UsedInAnswer bool `json:"usedInAnswer"`
IsCitation bool `json:"isCitation"`
RerankScore float64 `json:"rerank_score"`
UsedInAnswer bool `json:"used_in_answer"`
IsCitation bool `json:"is_citation"`
Snippet string `json:"snippet"`
CreatedAt time.Time `json:"createdAt"`
CreatedAt time.Time `json:"created_at"`
}
type KnowledgeRetrieveLogDetailResponse struct {
@@ -255,12 +255,12 @@ type KnowledgeRetrieveLogDetailResponse struct {
type KnowledgeFeedbackResponse struct {
ID int64 `json:"id"`
RetrieveLogID int64 `json:"retrieveLogId"`
FeedbackType int `json:"feedbackType"`
FeedbackTypeName string `json:"feedbackTypeName"`
FeedbackReason string `json:"feedbackReason"`
UserID int64 `json:"userId"`
AgentID int64 `json:"agentId"`
RetrieveLogID int64 `json:"retrieve_log_id"`
FeedbackType int `json:"feedback_type"`
FeedbackTypeName string `json:"feedback_type_name"`
FeedbackReason string `json:"feedback_reason"`
UserID int64 `json:"user_id"`
AgentID int64 `json:"agent_id"`
Remark string `json:"remark"`
CreatedAt time.Time `json:"createdAt"`
CreatedAt time.Time `json:"created_at"`
}