gutai123 commited on
Commit
38c1fba
·
verified ·
1 Parent(s): bdea572

Update user_utils.py

Browse files
Files changed (1) hide show
  1. user_utils.py +4 -1
user_utils.py CHANGED
@@ -37,11 +37,14 @@ def get_similar_docs(index,query,k=2):
37
  similar_docs = index.similarity_search(query, k=k)
38
  return similar_docs
39
 
 
40
  def get_answer(docs, user_input):
41
  # Concatenate all the documents into one large context
42
- context = " ".join([doc['page_content'] for doc in docs])
 
43
 
44
  # Use Hugging Face's QA model to get the answer
45
  response = qa_pipeline(question=user_input, context=context)
46
 
47
  return response['answer']
 
 
37
  similar_docs = index.similarity_search(query, k=k)
38
  return similar_docs
39
 
40
+
41
  def get_answer(docs, user_input):
42
  # Concatenate all the documents into one large context
43
+ # Assuming 'doc.page_content' is how the content is stored in your 'Document' object
44
+ context = " ".join([doc.page_content for doc in docs])
45
 
46
  # Use Hugging Face's QA model to get the answer
47
  response = qa_pipeline(question=user_input, context=context)
48
 
49
  return response['answer']
50
+