mirror of
https://github.com/hwchase17/langchain
synced 2024-11-04 06:00:26 +00:00
21 lines
643 B
Python
21 lines
643 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.pubmed import PubMedAPIWrapper
|
||
|
|
||
|
|
||
|
class PubMedRetriever(BaseRetriever, PubMedAPIWrapper):
|
||
|
"""`PubMed API` retriever.
|
||
|
|
||
|
It wraps load() to get_relevant_documents().
|
||
|
It uses all PubMedAPIWrapper arguments without any change.
|
||
|
"""
|
||
|
|
||
|
def _get_relevant_documents(
|
||
|
self, query: str, *, run_manager: CallbackManagerForRetrieverRun
|
||
|
) -> List[Document]:
|
||
|
return self.load_docs(query=query)
|