improvement(knowledge): search returns document name#1167
improvement(knowledge): search returns document name#1167emir-karabeg merged 1 commit intostagingfrom
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR enhances the knowledge base search functionality by adding document name information to search results and includes minor performance optimizations. The primary change adds a documentName field to the KnowledgeSearchResult interface and corresponding database queries, enabling users to see which document each search result originated from rather than just seeing a UUID documentId.
The implementation spans multiple files in the knowledge search system:
- Type definitions: Added
documentName: stringto theKnowledgeSearchResultinterface intypes.ts - Tool configuration: Updated the knowledge search tool schema to include
documentNamein the output specification - Database queries: Modified all search functions in
utils.tsto perform INNER JOINs with the document table to retrievedocument.filename - API response: Updated the search route to map and return the
documentNamefield
The PR also includes two secondary improvements: parallelization of knowledge base access checks and tag definition fetching in the search API route for better performance, and increasing the create menu close delay from 150ms to 300ms for improved user experience when navigating dropdown menus.
These changes integrate seamlessly with the existing knowledge base architecture, maintaining backward compatibility while providing more contextual information to users during search operations.
Confidence score: 4/5
- This PR is generally safe to merge with well-structured changes across the knowledge search system
- Score reflects solid implementation with proper database joins and consistent field additions, though the parallel Promise execution changes require careful attention
- Pay close attention to the search route optimizations in
apps/sim/app/api/knowledge/search/route.tsfor potential race conditions
5 files reviewed, 1 comment
| id: result.id, | ||
| content: result.content, | ||
| documentId: result.documentId, | ||
| documentName: (result as any).documentName || undefined, |
There was a problem hiding this comment.
style: Using type assertion to any for documentName access. Consider adding proper typing to SearchResult interface
Context Used: Context - Avoid using type assertions to 'any' in TypeScript. Instead, ensure proper type definitions are used to maintain type safety. (link)
Summary
Added document to return value of search. I also changed the create menu timeout delay to 300ms from 150ms. Slightly optimized speed of search route.
Type of Change
Testing
Run knowledge base search and confirm the document name is returned for each document.
Checklist