Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Description
app/services/retrieval_service.pyand implemented a hybrid in-memory retriever builderget_hybrid_retrieverplus resilient fallbacks inapp/agents/legal_research/retrievers.pyto support dense (Chroma + embeddings) and sparse (BM25) retrieval and fusion.app/api/v1/endpoints/documents.pyby building a compact retrieval query, fetchingretrieved_legal_contextandretrieved_legal_sources, injecting them intocase_facts, and returningretrieval_sourcesin the generation response using the newGeneratedDocumentResponseschema inapp/schemas/document.py.app/agents/document_generator/prompt_templates.pyto include theGrounded Legal Context (Retrieved)block and fixed logging indentation; updatedapp/agents/legal_research/agent.pyto use theRetrievalService; added documentation files (docs/*.md) describing the RAG upgrade plan.backend/unit_tests/test_retrievers_unit.pythat mock embedding/vector/BM25 components to validate hybrid retriever construction and contract (invoke) behavior.Testing
pytest backend/unit_tests/test_retrievers_unit.py, which exercisedget_hybrid_retrieverconstruction and the ensembleinvokecontract, and the tests passed.POST /generatecode path locally with retrieval disabled (fallback) to ensure no runtime errors when retrieval fails and the endpoint returns persisted document fields as expected.Codex Task