Files
ai-agent/internal/pkg/dto/response/knowledge_response.go
T
t 18c9354095 refactor: 将客服后端重构为宿主可嵌入模块
- 注入数据库、运行时配置、统一响应、文件存储和平台 AI 能力,补充业务读写工具与客户快捷操作契约。

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

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

- 统一 HTTP、DTO 与 WebSocket 的 snake_case 协议,补齐模块初始化、业务动作和公共载荷等回归测试。
2026-08-28 22:23:13 +08:00

267 lines
13 KiB
Go

package response
import (
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
"time"
)
type KnowledgeBaseResponse struct {
ID int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
KnowledgeType string `json:"knowledge_type"`
KnowledgeTypeName string `json:"knowledge_type_name"`
Status enums.Status `json:"status"`
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:"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:"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:"content_type"`
Content string `json:"content"`
Status enums.Status `json:"status"`
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:"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:"content_type"`
Status enums.Status `json:"status"`
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:"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:"similar_questions"`
Status enums.Status `json:"status"`
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:"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:"knowledge_base_id"`
ParentID int64 `json:"parent_id"`
Name string `json:"name"`
SortNo int `json:"sort_no"`
Status enums.Status `json:"status"`
StatusName string `json:"status_name"`
Remark string `json:"remark"`
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"`
}
type KnowledgeFAQExportedFile struct {
Filename string
ContentType string
Data []byte
}
type KnowledgeFAQImportError struct {
Row int `json:"row"`
Message string `json:"message"`
}
type KnowledgeFAQImportResult struct {
Total int `json:"total"`
Created int `json:"created"`
Updated int `json:"updated"`
Skipped int `json:"skipped"`
Failed int `json:"failed"`
Errors []KnowledgeFAQImportError `json:"errors"`
}
type KnowledgeSearchResult struct {
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:"section_path"`
Content string `json:"content"`
Score float64 `json:"score"`
RerankScore float64 `json:"rerank_score"`
}
type KnowledgeSearchResponse struct {
Question string `json:"question"`
Results []KnowledgeSearchResult `json:"results"`
HitCount int `json:"hit_count"`
LatencyMs int64 `json:"latency_ms"`
}
type KnowledgeAnswerResponse struct {
Question string `json:"question"`
RewriteQuestion string `json:"rewrite_question,omitempty"`
Answer string `json:"answer"`
AnswerStatus int `json:"answer_status"`
AnswerStatusName string `json:"answer_status_name"`
Citations []KnowledgeCitation `json:"citations"`
Hits []KnowledgeSearchResult `json:"hits"`
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:"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:"section_path"`
Snippet string `json:"snippet"`
Score float64 `json:"score"`
}
type KnowledgeRetrieveLogResponse struct {
ID int64 `json:"id"`
KnowledgeBaseID int64 `json:"knowledge_base_id"`
KnowledgeBaseName string `json:"knowledge_base_name,omitempty"`
Channel string `json:"channel"`
ChannelName string `json:"channel_name"`
Scene string `json:"scene"`
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:"rewrite_question"`
Answer string `json:"answer"`
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:"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:"section_path"`
ChunkType string `json:"chunk_type"`
ChunkTypeName string `json:"chunk_type_name"`
Provider string `json:"provider"`
RankNo int `json:"rank_no"`
Score float64 `json:"score"`
RerankScore float64 `json:"rerank_score"`
UsedInAnswer bool `json:"used_in_answer"`
IsCitation bool `json:"is_citation"`
Snippet string `json:"snippet"`
CreatedAt time.Time `json:"created_at"`
}
type KnowledgeRetrieveLogDetailResponse struct {
Log KnowledgeRetrieveLogResponse `json:"log"`
Hits []KnowledgeRetrieveHitResponse `json:"hits"`
}
type KnowledgeFeedbackResponse struct {
ID int64 `json:"id"`
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:"created_at"`
}