Skip to content

Instantly share code, notes, and snippets.

@fsndzomga
Created October 2, 2023 17:45
Show Gist options
  • Save fsndzomga/5c20f822b5e95e2c68b62abb5ed5db8f to your computer and use it in GitHub Desktop.
Save fsndzomga/5c20f822b5e95e2c68b62abb5ed5db8f to your computer and use it in GitHub Desktop.
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