From 3bf86672a321c93d028c115387736a8271291316 Mon Sep 17 00:00:00 2001 From: Niklas Finken <71568758+NickyHavoc@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:59:47 +0200 Subject: [PATCH] refactor: Fix typo and rename attribute in `MultipleChunkRetrieverQa` (#738) --- src/intelligence_layer/use_cases/__init__.py | 4 ++-- .../use_cases/qa/multiple_chunk_retriever_qa.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/intelligence_layer/use_cases/__init__.py b/src/intelligence_layer/use_cases/__init__.py index c4f8db15a..d1f86d7e2 100644 --- a/src/intelligence_layer/use_cases/__init__.py +++ b/src/intelligence_layer/use_cases/__init__.py @@ -50,10 +50,10 @@ from .qa.multiple_chunk_qa import MultipleChunkQaOutput as MultipleChunkQaOutput from .qa.multiple_chunk_qa import Subanswer as Subanswer from .qa.multiple_chunk_retriever_qa import ( - MulMultipleChunkRetrieverQaOutput as MulMultipleChunkRetrieverQaOutput, + MultipleChunkRetrieverQa as MultipleChunkRetrieverQa, ) from .qa.multiple_chunk_retriever_qa import ( - MultipleChunkRetrieverQa as MultipleChunkRetrieverQa, + MultipleChunkRetrieverQaOutput as MultipleChunkRetrieverQaOutput, ) from .qa.retriever_based_qa import EnrichedSubanswer as EnrichedSubanswer from .qa.retriever_based_qa import RetrieverBasedQa as RetrieverBasedQa 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 c18876c7a..2552bbcf2 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 @@ -18,17 +18,17 @@ class AnswerSource(BaseModel, Generic[ID]): - chunk: SearchResult[ID] + search_result: SearchResult[ID] highlights: Sequence[ScoredTextHighlight] -class MulMultipleChunkRetrieverQaOutput(BaseModel, Generic[ID]): +class MultipleChunkRetrieverQaOutput(BaseModel, Generic[ID]): answer: Optional[str] sources: Sequence[AnswerSource[ID]] class MultipleChunkRetrieverQa( - Task[RetrieverBasedQaInput, MulMultipleChunkRetrieverQaOutput[ID]], Generic[ID] + Task[RetrieverBasedQaInput, MultipleChunkRetrieverQaOutput[ID]], Generic[ID] ): """Answer a question based on documents found by a retriever. @@ -113,7 +113,7 @@ def _get_highlights_per_chunk( def do_run( self, input: RetrieverBasedQaInput, task_span: TaskSpan - ) -> MulMultipleChunkRetrieverQaOutput[ID]: + ) -> MultipleChunkRetrieverQaOutput[ID]: search_output = self._search.run( SearchInput(query=input.question), task_span ).results @@ -140,11 +140,11 @@ def do_run( chunk_start_indices, single_chunk_qa_output.highlights ) - return MulMultipleChunkRetrieverQaOutput( + return MultipleChunkRetrieverQaOutput( answer=single_chunk_qa_output.answer, sources=[ AnswerSource( - chunk=chunk, + search_result=chunk, highlights=highlights, ) for chunk, highlights in zip(sorted_search_output, highlights_per_chunk)