Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend: Hybrid Search improvements #845

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

tianjing-li
Copy link
Collaborator

@tianjing-li tianjing-li commented Nov 18, 2024

  • Improves Hybrid search tool implementation
  • Removes reranking from leaf tools, and instead have the main Hybrid Search tool perform rerank on all aggregated results
  • Use .get() instead of mydict["key"] to avoid KeyError exceptions
  • Add better tool error handling in no results scenario or tool auth failure scenarios

AI Description

This PR introduces several changes to the backend tools and configuration, primarily focusing on error handling, search functionality, and tool authentication.

Changes:

  • Error Handling:
    • A new ToolError class is introduced in src/backend/tools/base.py to handle tool-related errors.
    • The ToolErrorCode enum is added to categorize error types.
    • The ToolAuthException class is defined to handle tool authentication exceptions.
    • The _call_tool_async function in src/backend/chat/custom/tool_calls.py now catches ToolAuthException and returns an error response with authentication failure details.
  • Search Functionality:
    • The src/backend/tools/brave_search/tool.py file is updated to handle search results and return them in a consistent format.
    • Similar changes are made in src/backend/tools/google_search.py and src/backend/tools/tavily_search.py to handle search results and errors.
    • The HybridWebSearch class in src/backend/tools/hybrid_search.py now has a reduced POST_RERANK_MAX_RESULTS value.
  • Tool Authentication:
    • The src/backend/chat/custom/tool_calls.py file now imports ToolAuthException, ToolError, and ToolErrorCode from src/backend/tools/base.py for tool authentication and error handling.
  • Configuration:
    • The src/backend/tests/unit/configuration.yaml file is updated to include the hybrid_web_search tool and its enabled web searches.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 47.54098% with 32 lines in your changes missing coverage. Please review.

Project coverage is 79.55%. Comparing base (8fd8cf1) to head (6af4eb8).

Files with missing lines Patch % Lines
src/backend/tools/tavily_search.py 0.00% 10 Missing ⚠️
src/backend/tools/brave_search/tool.py 0.00% 9 Missing ⚠️
src/backend/tools/google_search.py 0.00% 5 Missing ⚠️
src/backend/tools/hybrid_search.py 20.00% 4 Missing ⚠️
src/backend/tools/base.py 86.95% 3 Missing ⚠️
src/backend/chat/custom/tool_calls.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #845      +/-   ##
==========================================
+ Coverage   79.27%   79.55%   +0.28%     
==========================================
  Files         251      251              
  Lines       10652    10628      -24     
==========================================
+ Hits         8444     8455      +11     
+ Misses       2208     2173      -35     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

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.

2 participants