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

refactor(rag): improve RAG manager implementation #268

Merged
merged 2 commits into from
Nov 22, 2024

Conversation

ErikBjare
Copy link
Owner

@ErikBjare ErikBjare commented Nov 22, 2024

  • Introduce shared RAG manager singleton via get_rag_manager()
  • Add DEFAULT_COLLECTION constant for consistent collection naming
  • Remove unused _clear_cache function
  • Update gptme-rag dependency to 0.3.1

Important

Refactor RAG manager to use a shared singleton, add a default collection constant, remove an unused function, and update the gptme-rag dependency.

  • RAG Manager:
    • Introduce shared singleton RAGManager via get_rag_manager() in _rag_context.py.
    • Replace rag_manager initialization in rag.py with get_rag_manager() calls.
  • Constants:
    • Add DEFAULT_COLLECTION in _rag_context.py for consistent collection naming.
  • Functions:
    • Remove unused _clear_cache() function in _rag_context.py.
  • Dependencies:
    • Update gptme-rag dependency to version 0.3.1 in pyproject.toml.

This description was created by Ellipsis for edbf520. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 6d52f30 in 1 minute and 41 seconds

More details
  • Looked at 137 lines of code in 3 files
  • Skipped 1 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_p2M0n9iq439lwJmQ


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -20,10 +23,21 @@
_HAS_RAG = False


# Shared RAG manager instance
_rag_manager: "RAGManager | None" = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Using a global variable for _rag_manager can lead to issues in multi-threaded environments or when the state needs to be reset. Consider using a class or context manager to handle the RAG manager instance.

@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 72.52%. Comparing base (3f00be1) to head (edbf520).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
gptme/tools/rag.py 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #268      +/-   ##
==========================================
+ Coverage   72.36%   72.52%   +0.15%     
==========================================
  Files          64       64              
  Lines        4313     4316       +3     
==========================================
+ Hits         3121     3130       +9     
+ Misses       1192     1186       -6     
Flag Coverage Δ
anthropic/claude-3-haiku-20240307 71.24% <86.66%> (+0.15%) ⬆️
openai/gpt-4o-mini 71.15% <86.66%> (+0.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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


🚨 Try these New Features:

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on 46cf058 in 38 seconds

More details
  • Looked at 46 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_EcIhhVh9TNumyMlF


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Makefile Outdated
@@ -146,7 +151,7 @@ cloc-server:
cloc gptme/server --by-file

cloc-tests:
cloc tests/*.py --by-file
cloc tests --by-file
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing cloc tests/*.py to cloc tests might include non-Python files in the count, leading to inaccurate LoC statistics. Consider reverting to cloc tests/*.py.

Suggested change
cloc tests --by-file
cloc tests/*.py --by-file

- Introduce shared RAG manager singleton via get_rag_manager()
- Add DEFAULT_COLLECTION constant for consistent collection naming
- Remove unused _clear_cache function
- Update gptme-rag dependency to 0.3.1
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 0e9cb11 in 51 seconds

More details
  • Looked at 137 lines of code in 3 files
  • Skipped 1 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_sJAu7mC5IPqELk8I


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

- Fix type error by using correct internal path to _rag_manager
- Split imports for better readability
- Organize imports more clearly
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on edbf520 in 24 seconds

More details
  • Looked at 33 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. tests/test_tools_rag.py:10
  • Draft comment:
    Combine multiple imports from the same module into a single line for better readability.
from gptme.tools.rag import _HAS_RAG, init as init_rag, rag_index, rag_search
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The import statements can be optimized for readability and maintainability.

Workflow ID: wflow_F4KAVc4T7bEKKLFC


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@ErikBjare ErikBjare merged commit 63e8d04 into master Nov 22, 2024
7 checks passed
@ErikBjare ErikBjare deleted the dev/more-rag-fixes branch November 22, 2024 20:21
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