-
Notifications
You must be signed in to change notification settings - Fork 58
fix: Migrate from deprecated vector_dbs to vector_stores API #678
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughReplaces vector DB listing with vector store listing in query endpoints; updates Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client as HTTP Client
participant Endpoint as Query / Streaming Endpoint
participant SDK as API Client (client.vector_stores)
participant RAG as get_rag_toolgroups
participant Agent as Toolgroup Agent
Client->>Endpoint: Request (query / streaming)
Endpoint->>SDK: client.vector_stores.list()
note right of SDK `#D6EAF8`: returns response object with `.data` list
SDK-->>Endpoint: list response (data -> vector_store objects)
Endpoint->>Endpoint: extract vector_store_ids from .data (ids)
Endpoint->>RAG: get_rag_toolgroups(vector_store_ids)
RAG-->>Endpoint: Toolgroups or None
Endpoint->>Agent: Build/run agent with toolgroups
Agent-->>Client: Response / stream
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used📓 Path-based instructions (5)src/**/*.py📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/app/endpoints/**/*.py📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/**/{client,app/endpoints/**}.py📄 CodeRabbit inference engine (CLAUDE.md)
Files:
tests/{unit,integration}/**/*.py📄 CodeRabbit inference engine (CLAUDE.md)
Files:
tests/**/*.py📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧬 Code graph analysis (1)src/app/endpoints/streaming_query.py (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (7)
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. Comment |
93b4b1b to
a5f1f16
Compare
There was a problem hiding this 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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/app/endpoints/query.py(2 hunks)src/app/endpoints/streaming_query.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/app/endpoints/streaming_query.py
🧰 Additional context used
📓 Path-based instructions (5)
src/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
Use absolute imports for internal modules (e.g., from auth import get_auth_dependency)
Files:
src/app/endpoints/query.py
src/app/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
Use standard FastAPI imports (from fastapi import APIRouter, HTTPException, Request, status, Depends) in FastAPI app code
Files:
src/app/endpoints/query.py
**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.py: All modules start with descriptive module-level docstrings explaining purpose
Use logger = logging.getLogger(name) for module logging after import logging
Define type aliases at module level for clarity
All functions require docstrings with brief descriptions
Provide complete type annotations for all function parameters and return types
Use typing_extensions.Self in model validators where appropriate
Use modern union syntax (str | int) and Optional[T] or T | None consistently
Function names use snake_case with descriptive, action-oriented prefixes (get_, validate_, check_)
Avoid in-place parameter modification; return new data structures instead of mutating arguments
Use appropriate logging levels: debug, info, warning, error with clear messages
All classes require descriptive docstrings explaining purpose
Class names use PascalCase with conventional suffixes (Configuration, Error/Exception, Resolver, Interface)
Abstract base classes should use abc.ABC and @AbstractMethod for interfaces
Provide complete type annotations for all class attributes
Follow Google Python docstring style for modules, classes, and functions, including Args, Returns, Raises, Attributes sections as needed
Files:
src/app/endpoints/query.py
src/{app/**/*.py,client.py}
📄 CodeRabbit inference engine (CLAUDE.md)
Use async def for I/O-bound operations and external API calls
Files:
src/app/endpoints/query.py
src/app/endpoints/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
In API endpoints, raise FastAPI HTTPException with appropriate status codes for error handling
Files:
src/app/endpoints/query.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: e2e_tests (ci)
- GitHub Check: e2e_tests (azure)
🔇 Additional comments (2)
src/app/endpoints/query.py (2)
686-688: LGTM! API migration is correct.The migration from
client.vector_dbs.list()toclient.vector_stores.list()correctly implements the API update. The list comprehension properly extracts IDs from the response data.
689-689: LGTM! Function call updated correctly.The call to
get_rag_toolgroupsnow correctly passesvector_store_ids, maintaining consistency with the API migration.
a5f1f16 to
7fd8a8f
Compare
7fd8a8f to
8fb26da
Compare
8fb26da to
ad70fef
Compare
ad70fef to
721963f
Compare
There was a problem hiding this 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
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/app/endpoints/query.py(2 hunks)src/app/endpoints/streaming_query.py(1 hunks)tests/unit/app/endpoints/test_query.py(16 hunks)tests/unit/app/endpoints/test_streaming_query.py(12 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
tests/{unit,integration}/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
tests/{unit,integration}/**/*.py: Use pytest for all unit and integration tests; do not use unittest framework
Unit tests must achieve 60% code coverage; integration tests must achieve 10% coverage
Files:
tests/unit/app/endpoints/test_streaming_query.pytests/unit/app/endpoints/test_query.py
tests/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
Use
pytest-mockwith AsyncMock objects for mocking in tests
Files:
tests/unit/app/endpoints/test_streaming_query.pytests/unit/app/endpoints/test_query.py
src/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
src/**/*.py: Use absolute imports for internal modules in LCS project (e.g.,from auth import get_auth_dependency)
All modules must start with descriptive docstrings explaining their purpose
Uselogger = logging.getLogger(__name__)pattern for module logging
All functions must include complete type annotations for parameters and return types, using modern syntax (str | int) andOptional[Type]orType | None
All functions must have docstrings with brief descriptions following Google Python docstring conventions
Function names must use snake_case with descriptive, action-oriented names (get_, validate_, check_)
Avoid in-place parameter modification anti-patterns; return new data structures instead of modifying input parameters
Useasync deffor I/O operations and external API calls
All classes must include descriptive docstrings explaining their purpose following Google Python docstring conventions
Class names must use PascalCase with descriptive names and standard suffixes:Configurationfor config classes,Error/Exceptionfor exceptions,Resolverfor strategy patterns,Interfacefor abstract base classes
Abstract classes must use ABC with@abstractmethoddecorators
Include complete type annotations for all class attributes in Python classes
Useimport loggingand module logger pattern with standard log levels: debug, info, warning, error
Files:
src/app/endpoints/query.pysrc/app/endpoints/streaming_query.py
src/app/endpoints/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
Use FastAPI
HTTPExceptionwith appropriate status codes for API endpoint error handling
Files:
src/app/endpoints/query.pysrc/app/endpoints/streaming_query.py
src/**/{client,app/endpoints/**}.py
📄 CodeRabbit inference engine (CLAUDE.md)
Handle
APIConnectionErrorfrom Llama Stack in integration code
Files:
src/app/endpoints/query.pysrc/app/endpoints/streaming_query.py
🧬 Code graph analysis (2)
src/app/endpoints/streaming_query.py (1)
src/app/endpoints/query.py (1)
get_rag_toolgroups(832-859)
tests/unit/app/endpoints/test_query.py (1)
src/app/endpoints/query.py (1)
get_rag_toolgroups(832-859)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
- GitHub Check: e2e_tests (ci)
- GitHub Check: e2e_tests (azure)
- GitHub Check: build-pr
🔇 Additional comments (10)
src/app/endpoints/streaming_query.py (1)
1064-1072: Migration to vector_stores API looks correct.The change properly updates from the deprecated
vector_dbsAPI tovector_stores:
- Accesses
client.vector_stores.list().datato get the list- Uses
vector_store.idinstead of the old identifier attribute- Passes
vector_store_idstoget_rag_toolgroups()matching the updated function signatureThe toolgroup construction logic is preserved (empty list converts to None).
tests/unit/app/endpoints/test_streaming_query.py (3)
379-383: Test mock structure correctly updated for vector_stores API.The test properly mocks the new vector_stores API structure:
mock_vector_store.idinstead ofidentifiermock_list_response.datawrapper around the listmock_client.vector_stores.listreturns the wrapperThis pattern is consistently applied throughout the test file.
426-428: Consistent mock updates across all test scenarios.All test cases properly update their mocks to use:
mock_list_response.data = []for empty vector stores- The
vector_stores.list()API instead ofvector_dbs.list()The consistency across tests ensures comprehensive coverage of the API migration.
Also applies to: 484-486, 543-545, 604-606, 659-661, 715-717, 1128-1130, 1209-1211, 1275-1277
1533-1537: Vector store mocks correctly configured for no_tools tests.Tests for
no_toolsparameter correctly set up vector store mocks with:
mock_vector_store.id = "VectorDB-1"mock_list_response.data = [mock_vector_store]These tests verify that even when vector stores are available, they're bypassed when
no_tools=True, which is the expected behavior.Also applies to: 1585-1589
src/app/endpoints/query.py (1)
736-739: Vector stores API integration looks correct.The code properly:
- Calls
client.vector_stores.list().datato get the list- Accesses
vector_store.idattribute on each item- Passes
vector_store_idstoget_rag_toolgroups()with the updated signatureThe toolgroup construction logic remains consistent (empty list converts to None).
tests/unit/app/endpoints/test_query.py (5)
539-543: Test mocks correctly updated for vector_stores API.All test cases properly update their mocks to reflect the new API structure:
mock_vector_store.idinstead ofidentifiermock_vector_stores_response.datawrapper around the listmock_client.vector_stores.listreturns the wrapperThis ensures tests accurately reflect the production code changes.
Also applies to: 579-583, 620-624
669-671: Empty vector stores correctly mocked across test scenarios.Tests with no vector stores available correctly mock:
mock_vector_stores_response.data = []- Return value from
mock_client.vector_stores.list()These tests verify behavior when RAG is not available, which should result in
toolgroups=Nonebeing passed toagent.create_turn.Also applies to: 727-729, 788-790, 851-853, 908-910, 966-968, 1150-1152, 1233-1235, 1294-1296
1407-1411: Shield violation test properly configured with vector stores.The test for shield violations correctly sets up:
- Vector store with
id = "VectorDB-1"- Wrapper with
mock_vector_stores_response.data = [mock_vector_store]- Assertion at line 1442 verifies
get_rag_toolgroups(["VectorDB-1"])is calledThis ensures shield handling works correctly with the vector_stores API.
1448-1457: Direct test of get_rag_toolgroups updated correctly.The unit test for
get_rag_toolgroupsproperly validates:
- Empty
vector_store_idslist returnsNone(lines 1448-1450)- Non-empty list returns a toolgroup with the correct structure (lines 1452-1457)
- Args dictionary contains
"vector_store_ids"key (line 1457)This confirms the function signature change and args key update are correct.
1678-1682: No-tools feature tests correctly configured.Tests verifying the
no_toolsparameter behavior properly set up vector stores:
- Line 1678-1682:
no_tools=Truetest with vector stores available- Line 1735-1739:
no_tools=Falsetest with vector stores available- Line 1784 assertion: Verifies RAG toolgroups are included when
no_tools=FalseThese tests confirm that vector stores are correctly bypassed when tools are disabled, regardless of their availability.
Also applies to: 1735-1739
721963f to
b6ccb45
Compare
Description
This PR updates the codebase to use the new vector_stores API instead of the deprecated vector_dbs API, which was removed in llama-stack PR #3774.
Type of change
Related Tickets & Documents
Summary by CodeRabbit
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.