core, tests: more tolerant _aget_relevant_documents function (#28462)

This commit is contained in:
Erick Friis
2024-12-05 16:49:30 -08:00
committed by GitHub
parent bc636ccc60
commit 18386c16c7
3 changed files with 14 additions and 5 deletions

View File

@@ -1,6 +1,5 @@
from typing import Any, Type
from langchain_core.callbacks import CallbackManagerForRetrieverRun
from langchain_core.documents import Document
from langchain_core.retrievers import BaseRetriever
@@ -11,9 +10,7 @@ class ParrotRetriever(BaseRetriever):
parrot_name: str
k: int = 3
def _get_relevant_documents(
self, query: str, *, run_manager: CallbackManagerForRetrieverRun, **kwargs: Any
) -> list[Document]:
def _get_relevant_documents(self, query: str, **kwargs: Any) -> list[Document]:
k = kwargs.get("k", self.k)
return [Document(page_content=f"{self.parrot_name} says: {query}")] * k