Skip to content

[feat]: implement custom hybrid search#109

Merged
chandansgowda merged 1 commit intoAOSSIE-Org:mainfrom
smokeyScraper:improve_search
Jul 22, 2025
Merged

[feat]: implement custom hybrid search#109
chandansgowda merged 1 commit intoAOSSIE-Org:mainfrom
smokeyScraper:improve_search

Conversation

@smokeyScraper
Copy link
Copy Markdown
Contributor

@smokeyScraper smokeyScraper commented Jul 22, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a hybrid search capability for contributors, combining vector similarity and keyword search to provide more relevant results.
    • Users can now perform searches using both embeddings and keywords with customizable weighting for each method.
    • Added a new public search function to enable easy access to the hybrid contributor search feature.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jul 22, 2025

Walkthrough

A new hybrid search capability for contributors was implemented in the Weaviate database operations. This includes an asynchronous method in the WeaviateUserOperations class and a top-level function to perform searches combining vector similarity and BM25 keyword results. The new functionality is now publicly exported by the package.

Changes

File(s) Change Summary
backend/app/database/weaviate/operations.py Added hybrid_search_contributors async method to WeaviateUserOperations and new top-level search_contributors function for hybrid search combining vector similarity and BM25.
backend/app/database/weaviate/init.py Imported and exported search_contributors in the package’s public API.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant WeaviateUserOperations
    participant WeaviateDB

    Caller->>WeaviateUserOperations: hybrid_search_contributors(query_embedding, keywords, ...)
    WeaviateUserOperations->>WeaviateDB: vector_search(query_embedding, limit)
    WeaviateDB-->>WeaviateUserOperations: vector_results
    WeaviateUserOperations->>WeaviateDB: bm25_search(keywords, limit)
    WeaviateDB-->>WeaviateUserOperations: bm25_results
    WeaviateUserOperations->>WeaviateUserOperations: merge & score results
    WeaviateUserOperations-->>Caller: top contributors list

    Caller->>search_contributors: (calls hybrid_search_contributors internally)
Loading

Estimated code review effort

2 (~15 minutes)

Poem

In Weaviate’s warren, a search was devised,
Hybrid and clever, with vectors it ties.
Contributors found, both near and afar,
By keywords and numbers—how brilliant we are!
Now exported and ready, for all to employ,
This bunny’s new search brings data some joy!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 887679a and 43d479c.

📒 Files selected for processing (2)
  • backend/app/database/weaviate/__init__.py (2 hunks)
  • backend/app/database/weaviate/operations.py (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • backend/app/database/weaviate/init.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/app/database/weaviate/operations.py
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
backend/app/database/weaviate/operations.py (1)

216-223: Consider adding weight validation for hybrid scoring.

The hybrid search implementation looks good, but consider validating that the weights sum to 1.0 for proper score normalization.

     async def hybrid_search_contributors(
         self,
         query_embedding: List[float],
         keywords: List[str],
         limit: int = 10,
         vector_weight: float = 0.7,
         bm25_weight: float = 0.3
     ) -> List[Dict[str, Any]]:
         """
         Hybrid search combining vector similarity and BM25 keyword search.
         """
+        if abs(vector_weight + bm25_weight - 1.0) > 0.001:
+            logger.warning(f"Hybrid search weights don't sum to 1.0: {vector_weight + bm25_weight}")
+        
         try:
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1356976 and 887679a.

📒 Files selected for processing (2)
  • backend/app/database/weaviate/__init__.py (2 hunks)
  • backend/app/database/weaviate/operations.py (2 hunks)
🧠 Learnings (1)
📓 Common learnings
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#87
File: tests/test_supabase.py:1-3
Timestamp: 2025-06-28T23:15:13.374Z
Learning: In the Devr.AI project, smokeyScraper prefers to defer test updates and fixes (like missing imports after module reorganization) to separate PRs rather than expanding the scope of module update/chore PRs to include comprehensive test refactoring.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#90
File: backend/app/agents/devrel/nodes/react_supervisor.py:97-101
Timestamp: 2025-07-05T04:33:39.840Z
Learning: In the Devr.AI project, smokeyScraper prefers to defer code deduplication refactoring (like extracting duplicate functions to shared utilities) until there are more common functionalities present among tools/workflow. With only two files using the same function, they consider it not a problem currently and prefer to "align later in a more better way" once more patterns emerge.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#85
File: tests/test_supabase.py:1-3
Timestamp: 2025-06-28T14:45:55.244Z
Learning: In the Devr.AI project, smokeyScraper prefers to defer comprehensive test refactoring to separate PRs/efforts when doing major backend restructuring, rather than expanding the scope of the current refactoring PR to include test updates.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#85
File: backend/app/services/auth/management.py:32-33
Timestamp: 2025-06-28T14:44:36.819Z
Learning: In the Devr.AI project, smokeyScraper prefers using machine timezone (IST) for datetime operations during development and testing for easier debugging, with plans to switch to UTC for deployment later.
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#87
File: tests/test_supabase.py:1-3
Timestamp: 2025-06-28T23:15:13.374Z
Learning: In the Devr.AI project, smokeyScraper prefers to defer test updates and fixes (like missing imports after module reorganization) to separate PRs rather than expanding the scope of module update/chore PRs to include comprehensive test refactoring.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#90
File: backend/app/agents/devrel/nodes/react_supervisor.py:97-101
Timestamp: 2025-07-05T04:33:39.840Z
Learning: In the Devr.AI project, smokeyScraper prefers to defer code deduplication refactoring (like extracting duplicate functions to shared utilities) until there are more common functionalities present among tools/workflow. With only two files using the same function, they consider it not a problem currently and prefer to "align later in a more better way" once more patterns emerge.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#85
File: tests/test_supabase.py:1-3
Timestamp: 2025-06-28T14:45:55.244Z
Learning: In the Devr.AI project, smokeyScraper prefers to defer comprehensive test refactoring to separate PRs/efforts when doing major backend restructuring, rather than expanding the scope of the current refactoring PR to include test updates.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#85
File: backend/app/services/auth/management.py:32-33
Timestamp: 2025-06-28T14:44:36.819Z
Learning: In the Devr.AI project, smokeyScraper prefers using machine timezone (IST) for datetime operations during development and testing for easier debugging, with plans to switch to UTC for deployment later.
🔇 Additional comments (2)
backend/app/database/weaviate/__init__.py (1)

6-6: LGTM! Clean module export addition.

The new search_contributors function is properly imported and exported, making the hybrid search functionality accessible to external modules.

Also applies to: 17-17

backend/app/database/weaviate/operations.py (1)

360-373: LGTM! Clean convenience function implementation.

The function follows the established pattern of other convenience functions in the file and properly delegates to the class method.

@chandansgowda chandansgowda merged commit 8fdf2d4 into AOSSIE-Org:main Jul 22, 2025
1 check passed
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