refactor(agent): streamline document info retrieval and enhance chunk search logic

- Removed the validation for a maximum of 10 knowledge IDs in GetDocumentInfoTool to allow more flexibility.
- Adjusted pagination settings in chunk retrieval to limit results to 1 per request for more granular control.
- Updated the searchChunks method to use case-insensitive matching based on the database type, improving compatibility across different systems.
- Enhanced query structure for better readability and maintainability.
This commit is contained in:
wizardchen
2026-03-18 23:49:46 +08:00
committed by lyingbug
parent b4f3ad71ad
commit 4c3f083642
2 changed files with 18 additions and 31 deletions
+1 -9
View File
@@ -91,14 +91,6 @@ func (t *GetDocumentInfoTool) Execute(ctx context.Context, args json.RawMessage)
}, fmt.Errorf("knowledge_ids is required")
}
// Validate max 10 documents
if len(knowledgeIDs) > 10 {
return &types.ToolResult{
Success: false,
Error: "knowledge_ids must contain at least one valid knowledge ID",
}, fmt.Errorf("no valid knowledge IDs provided")
}
// Concurrently get info for each knowledge ID
type docInfo struct {
knowledge *types.Knowledge
@@ -141,7 +133,7 @@ func (t *GetDocumentInfoTool) Execute(ctx context.Context, args json.RawMessage)
_, total, err := t.chunkService.GetRepository().
ListPagedChunksByKnowledgeID(ctx, knowledge.TenantID, id, &types.Pagination{
Page: 1,
PageSize: 1000,
PageSize: 1,
}, []types.ChunkType{"text"}, "", "", "", "", "")
if err != nil {
mu.Lock()