Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ from langchain.chains.question_answering import load_qa_chain
|
|
5 |
# from langchain.llms import HuggingFaceHub
|
6 |
from transformers import pipeline
|
7 |
from langchain.llms import HuggingFacePipeline
|
|
|
8 |
from langchain.chains.question_answering import load_qa_chain
|
9 |
from transformers import pipeline
|
10 |
from sentence_transformers import SentenceTransformer
|
@@ -177,8 +178,11 @@ def chatbot(query):
|
|
177 |
most_relevant_section = structured_chunks[best_idx][1]
|
178 |
|
179 |
# Process the most relevant chunk with QA
|
180 |
-
result_in_russian = qa_chain.run(input_documents=[{"text": most_relevant_section}], question=query_in_russian)
|
181 |
-
|
|
|
|
|
|
|
182 |
# Translate answer back to the original language as best as we can
|
183 |
final_answer = translate_answer_back(result_in_russian, query_language)
|
184 |
return final_answer
|
|
|
5 |
# from langchain.llms import HuggingFaceHub
|
6 |
from transformers import pipeline
|
7 |
from langchain.llms import HuggingFacePipeline
|
8 |
+
from langchain.docstore.document import Document
|
9 |
from langchain.chains.question_answering import load_qa_chain
|
10 |
from transformers import pipeline
|
11 |
from sentence_transformers import SentenceTransformer
|
|
|
178 |
most_relevant_section = structured_chunks[best_idx][1]
|
179 |
|
180 |
# Process the most relevant chunk with QA
|
181 |
+
# result_in_russian = qa_chain.run(input_documents=[{"text": most_relevant_section}], question=query_in_russian)
|
182 |
+
result_in_russian = qa_chain.run(
|
183 |
+
input_documents=[Document(page_content=most_relevant_section)],
|
184 |
+
question=query_in_russian
|
185 |
+
)
|
186 |
# Translate answer back to the original language as best as we can
|
187 |
final_answer = translate_answer_back(result_in_russian, query_language)
|
188 |
return final_answer
|