Skip to content

improvement(knowledge): search returns document name#1167

Merged
emir-karabeg merged 1 commit intostagingfrom
improvement/knowledge-search
Aug 28, 2025
Merged

improvement(knowledge): search returns document name#1167
emir-karabeg merged 1 commit intostagingfrom
improvement/knowledge-search

Conversation

@emir-karabeg
Copy link
Collaborator

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

  • New feature

Testing

Run knowledge base search and confirm the document name is returned for each document.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Aug 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Aug 28, 2025 10:59pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Aug 28, 2025 10:59pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: string to the KnowledgeSearchResult interface in types.ts
  • Tool configuration: Updated the knowledge search tool schema to include documentName in the output specification
  • Database queries: Modified all search functions in utils.ts to perform INNER JOINs with the document table to retrieve document.filename
  • API response: Updated the search route to map and return the documentName field

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.ts for potential race conditions

5 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

id: result.id,
content: result.content,
documentId: result.documentId,
documentName: (result as any).documentName || undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@emir-karabeg emir-karabeg changed the title improvement(knowledge): added document to return value of search improvement(knowledge): knowledge search returns document name Aug 28, 2025
@emir-karabeg emir-karabeg changed the title improvement(knowledge): knowledge search returns document name improvement(knowledge): search returns document name Aug 28, 2025
@emir-karabeg emir-karabeg merged commit 7cc4574 into staging Aug 28, 2025
5 checks passed
@emir-karabeg emir-karabeg deleted the improvement/knowledge-search branch August 28, 2025 23:07
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant