0b4a1b4594
- Updated OSSStorage validation errors to use internationalized messages. - Changed error messages in provider.go for unsupported file storage types. - Refactored tag_service.go to replace hardcoded error messages with internationalized versions. - Updated ticket_service.go to use internationalized error messages for various validation checks. - Refactored ticket_tag_service.go to use internationalized error messages for tag validation. - Changed ticket_view_service.go to use internationalized error messages for view validation. - Updated tool_catalog_service.go to use internationalized error messages for tool code validation. - Refactored user_service.go to replace error messages with internationalized versions. - Updated ws_service.go to use internationalized error messages for WebSocket handling. - Refactored wxwork_kf_inbound_service.go to use internationalized error messages for message handling. - Updated wxwork_kf_outbound_service.go to use internationalized error messages for outbound message handling. - Refactored wxwork_login_service.go to use internationalized error messages for login handling. - Updated login.go in wxwork package to use internationalized error messages for login state and ticket validation.
96 lines
2.3 KiB
Go
96 lines
2.3 KiB
Go
package dashboard
|
|
|
|
import (
|
|
"agent-desk/internal/pkg/httpx"
|
|
"context"
|
|
|
|
"agent-desk/internal/ai/rag"
|
|
"agent-desk/internal/pkg/constants"
|
|
"agent-desk/internal/pkg/dto/request"
|
|
"agent-desk/internal/services"
|
|
|
|
"agent-desk/internal/pkg/httpx/params"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func KnowledgeRetrievePostDebugSearch(ctx *gin.Context) {
|
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionKnowledgeDocumentView); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
|
|
req := request.KnowledgeSearchRequest{}
|
|
if err := params.ReadJSON(ctx, &req); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
|
|
resp, err := rag.Answer.DebugSearch(context.Background(), req)
|
|
if err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
httpx.WriteJSON(ctx, resp)
|
|
}
|
|
|
|
func KnowledgeRetrievePostDebugAnswer(ctx *gin.Context) {
|
|
operator, err := services.AuthService.RequirePermission(ctx, constants.PermissionKnowledgeDocumentView)
|
|
if err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
|
|
req := request.KnowledgeAnswerRequest{}
|
|
if err := params.ReadJSON(ctx, &req); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
|
|
resp, err := rag.Answer.DebugAnswer(context.Background(), req, operator)
|
|
if err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
httpx.WriteJSON(ctx, resp)
|
|
}
|
|
|
|
func KnowledgeRetrievePostBuild(ctx *gin.Context) {
|
|
req := struct {
|
|
DocumentID int64 `json:"documentId"`
|
|
FAQID int64 `json:"faqId"`
|
|
}{}
|
|
if err := params.ReadJSON(ctx, &req); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
|
|
if req.DocumentID > 0 {
|
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionKnowledgeDocumentUpdate); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
if err := rag.Answer.BuildDocumentIndex(context.Background(), req.DocumentID); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
httpx.WriteJSON(ctx, nil)
|
|
return
|
|
}
|
|
|
|
if req.FAQID > 0 {
|
|
if _, err := services.AuthService.RequirePermission(ctx, constants.PermissionKnowledgeFAQUpdate); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
if err := rag.Index.IndexFAQByID(context.Background(), req.FAQID); err != nil {
|
|
httpx.WriteJSON(ctx, err)
|
|
return
|
|
}
|
|
httpx.WriteJSON(ctx, nil)
|
|
return
|
|
}
|
|
|
|
httpx.WriteJSON(ctx, httpx.JsonErrorMsg(ctx, "error.e0066"))
|
|
}
|