Source code for langchain_community.retrievers.breebs

from typing import List

import requests
from langchain_core.callbacks.manager import CallbackManagerForRetrieverRun
from langchain_core.documents.base import Document
from langchain_core.retrievers import BaseRetriever

[docs]class BreebsRetriever(BaseRetriever): """A retriever class for `Breebs`. See for more info. Args: breeb_key: The key to trigger the breeb (specialized knowledge pill on a specific topic). To retrieve the list of all available Breebs : you can call """ breeb_key: str url = "" def __init__(self, breeb_key: str): super().__init__(breeb_key=breeb_key) # type: ignore[call-arg] self.breeb_key = breeb_key def _get_relevant_documents( self, query: str, *, run_manager: CallbackManagerForRetrieverRun ) -> List[Document]: """Retrieve context for given query. Note that for time being there is no score.""" r = self.url, json={ "breeb_key": self.breeb_key, "query": query, }, ) if r.status_code != 200: return [] else: chunks = r.json() return [ Document( page_content=chunk["content"], metadata={"source": chunk["source_url"], "score": 1}, ) for chunk in chunks ]