[docs]classKayAiRetriever(BaseRetriever):""" Retriever for Kay.ai datasets. To work properly, expects you to have KAY_API_KEY env variable set. You can get one for free at https://kay.ai/. """client:Anynum_contexts:int
[docs]@classmethoddefcreate(cls,dataset_id:str,data_types:List[str],num_contexts:int=6,)->KayAiRetriever:""" Create a KayRetriever given a Kay dataset id and a list of datasources. Args: dataset_id: A dataset id category in Kay, like "company" data_types: A list of datasources present within a dataset. For "company" the corresponding datasources could be ["10-K", "10-Q", "8-K", "PressRelease"]. num_contexts: The number of documents to retrieve on each query. Defaults to 6. """try:fromkay.rag.retrieversimportKayRetrieverexceptImportError:raiseImportError("Could not import kay python package. Please install it with ""`pip install kay`.",)client=KayRetriever(dataset_id,data_types)returncls(client=client,num_contexts=num_contexts)