mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
26 lines
773 B
Python
26 lines
773 B
Python
|
from typing import List
|
||
|
|
||
|
from langchain_core.callbacks import CallbackManagerForRetrieverRun
|
||
|
from langchain_core.documents import Document
|
||
|
from langchain_core.retrievers import BaseRetriever
|
||
|
|
||
|
from langchain_community.utilities.arxiv import ArxivAPIWrapper
|
||
|
|
||
|
|
||
|
class ArxivRetriever(BaseRetriever, ArxivAPIWrapper):
|
||
|
"""`Arxiv` retriever.
|
||
|
|
||
|
It wraps load() to get_relevant_documents().
|
||
|
It uses all ArxivAPIWrapper arguments without any change.
|
||
|
"""
|
||
|
|
||
|
get_full_documents: bool = False
|
||
|
|
||
|
def _get_relevant_documents(
|
||
|
self, query: str, *, run_manager: CallbackManagerForRetrieverRun
|
||
|
) -> List[Document]:
|
||
|
if self.get_full_documents:
|
||
|
return self.load(query=query)
|
||
|
else:
|
||
|
return self.get_summaries_as_docs(query)
|