mirror of
https://git.boos.lat/aibo/BossChat.git
synced 2026-10-30 15:16:11 +00:00
fix: propagate document indexing errors to caller
Previously indexing failures were silently logged, returning success even when the embedding model was not configured or Qdrant was down. Now the error is returned to the frontend so the user sees it.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -111,7 +112,7 @@ func (s *knowledgeDocumentService) CreateKnowledgeDocument(req request.CreateKno
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := rag.Index.IndexDocumentByID(context.Background(), item.ID); err != nil {
|
if err := rag.Index.IndexDocumentByID(context.Background(), item.ID); err != nil {
|
||||||
slog.Error("failed to index created knowledge document", "document_id", item.ID, "error", err)
|
return nil, fmt.Errorf("文档索引失败: %w", err)
|
||||||
}
|
}
|
||||||
item = s.Get(item.ID)
|
item = s.Get(item.ID)
|
||||||
return item, nil
|
return item, nil
|
||||||
@@ -160,7 +161,7 @@ func (s *knowledgeDocumentService) UpdateKnowledgeDocument(req request.UpdateKno
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := rag.Index.IndexDocumentByID(context.Background(), req.ID); err != nil {
|
if err := rag.Index.IndexDocumentByID(context.Background(), req.ID); err != nil {
|
||||||
slog.Error("failed to reindex updated knowledge document", "document_id", req.ID, "error", err)
|
return fmt.Errorf("文档重新索引失败: %w", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,7 +267,6 @@ function AgentEditDialogBody({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onFormError(errors: object) {
|
function onFormError(errors: object) {
|
||||||
console.error("Agent form validation errors:", errors)
|
|
||||||
const firstError = Object.values(errors).find(
|
const firstError = Object.values(errors).find(
|
||||||
(e: unknown) => (e as { message?: string })?.message
|
(e: unknown) => (e as { message?: string })?.message
|
||||||
) as { message?: string } | undefined
|
) as { message?: string } | undefined
|
||||||
|
|||||||
Reference in New Issue
Block a user