diff --git a/src/intelligence_layer/use_cases/qa/multiple_chunk_retriever_qa.py b/src/intelligence_layer/use_cases/qa/multiple_chunk_retriever_qa.py index d8bf9c05e..81881e3c8 100644 --- a/src/intelligence_layer/use_cases/qa/multiple_chunk_retriever_qa.py +++ b/src/intelligence_layer/use_cases/qa/multiple_chunk_retriever_qa.py @@ -15,6 +15,7 @@ from intelligence_layer.use_cases.search.expand_chunks import ( ExpandChunks, ExpandChunksInput, + ExpandChunksOutput, ) from intelligence_layer.use_cases.search.search import Search, SearchInput @@ -49,6 +50,8 @@ class MultipleChunkRetrieverQa( In contrast to the regular `RetrieverBasedQa`, this tasks injects multiple chunks into one `SingleChunkQa` task run. + We recommend using this task instead of `RetrieverBasedQa`. + Note: `model` provided should be a control-type model. @@ -62,17 +65,17 @@ class MultipleChunkRetrieverQa( def __init__( self, retriever: BaseRetriever[ID], - model: ControlModel | None = None, insert_chunk_number: int = 5, - insert_chunk_size: int = 256, + model: ControlModel | None = None, + expand_chunks: Task[ExpandChunksInput[ID], ExpandChunksOutput] | None = None, single_chunk_qa: Task[SingleChunkQaInput, SingleChunkQaOutput] | None = None, ): super().__init__() - self._model = model or LuminousControlModel("luminous-supreme-control") self._search = Search(retriever) - self._expand_chunks = ExpandChunks(retriever, self._model, insert_chunk_size) - self._single_chunk_qa = single_chunk_qa or SingleChunkQa(self._model) self._insert_chunk_number = insert_chunk_number + self._model = model or LuminousControlModel("luminous-supreme-control") + self._expand_chunks = expand_chunks or ExpandChunks(retriever, self._model) + self._single_chunk_qa = single_chunk_qa or SingleChunkQa(self._model) @staticmethod def _combine_input_texts(chunks: Sequence[str]) -> tuple[TextChunk, Sequence[int]]: diff --git a/src/intelligence_layer/use_cases/qa/retriever_based_qa.py b/src/intelligence_layer/use_cases/qa/retriever_based_qa.py index 1adb4df09..908288284 100644 --- a/src/intelligence_layer/use_cases/qa/retriever_based_qa.py +++ b/src/intelligence_layer/use_cases/qa/retriever_based_qa.py @@ -1,3 +1,4 @@ +import warnings from typing import Generic, Optional, Sequence from pydantic import BaseModel @@ -97,6 +98,11 @@ def __init__( def do_run( self, input: RetrieverBasedQaInput, task_span: TaskSpan ) -> RetrieverBasedQaOutput[ID]: + warnings.warn( + "`RetrieverBasedQa` is deprecated and will be removed in future versions.", + DeprecationWarning, + ) + search_output = self._search.run( SearchInput(query=input.question), task_span ).results diff --git a/tests/use_cases/qa/test_multiple_chunk_retriever_qa.py b/tests/use_cases/qa/test_multiple_chunk_retriever_qa.py index 4adbe0280..044df6e3b 100644 --- a/tests/use_cases/qa/test_multiple_chunk_retriever_qa.py +++ b/tests/use_cases/qa/test_multiple_chunk_retriever_qa.py @@ -1,16 +1,27 @@ from pytest import fixture from intelligence_layer.connectors import QdrantInMemoryRetriever -from intelligence_layer.core import NoOpTracer +from intelligence_layer.core import LuminousControlModel, NoOpTracer from intelligence_layer.core.tracer.in_memory_tracer import InMemoryTracer -from intelligence_layer.use_cases import MultipleChunkRetrieverQa, RetrieverBasedQaInput +from intelligence_layer.use_cases import ( + ExpandChunks, + MultipleChunkRetrieverQa, + RetrieverBasedQaInput, +) @fixture def multiple_chunk_retriever_qa( + luminous_control_model: LuminousControlModel, asymmetric_in_memory_retriever: QdrantInMemoryRetriever, ) -> MultipleChunkRetrieverQa[int]: - return MultipleChunkRetrieverQa(retriever=asymmetric_in_memory_retriever) + return MultipleChunkRetrieverQa( + retriever=asymmetric_in_memory_retriever, + model=luminous_control_model, + expand_chunks=ExpandChunks( + asymmetric_in_memory_retriever, luminous_control_model, 256 + ), + ) def test_multiple_chunk_retriever_qa_using_in_memory_retriever(