Created
October 2, 2023 17:45
-
-
Save fsndzomga/5c20f822b5e95e2c68b62abb5ed5db8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Responder(): | |
def __init__(self, collection) -> None: | |
self.llm = OpenaiLanguageModel(anonymize=False) | |
self.collection = collection | |
def __call__(self, question) -> Any: | |
results = self.collection.query( | |
query_texts=["This is a query document"], | |
n_results=10 | |
) | |
# Joining all the text content of documents into one string | |
merged_text = ' '.join([doc for doc in results['documents'][0]]) | |
prompt = f""" | |
Answer this question: {question}, using these informations from the document: {merged_text} | |
""" | |
response = self.llm.generate(prompt) | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment