Spaces:
Runtime error
Runtime error
pedropauletti
commited on
Commit
•
e306148
1
Parent(s):
711c996
Update app.py
Browse files
app.py
CHANGED
@@ -42,28 +42,24 @@ def add_file(chat_history, file):
|
|
42 |
|
43 |
|
44 |
def chatbot_response(chat_history, language):
|
45 |
-
global retriever
|
46 |
-
global last_answer
|
47 |
-
|
48 |
-
print(chat_history)
|
49 |
|
50 |
chat_history[-1][1] = ""
|
51 |
|
|
|
|
|
52 |
|
53 |
if language == 'pt-br':
|
54 |
-
|
55 |
-
|
56 |
else:
|
57 |
-
|
58 |
-
|
59 |
-
last_answer = response
|
60 |
-
|
61 |
-
for character in response:
|
62 |
-
chat_history[-1][1] += character
|
63 |
-
time.sleep(0.01)
|
64 |
-
yield chat_history
|
65 |
|
|
|
66 |
|
|
|
|
|
|
|
|
|
67 |
|
68 |
def get_answers(retriever, query):
|
69 |
from haystack.pipelines import FAQPipeline
|
|
|
42 |
|
43 |
|
44 |
def chatbot_response(chat_history, language):
|
|
|
|
|
|
|
|
|
45 |
|
46 |
chat_history[-1][1] = ""
|
47 |
|
48 |
+
global retriever
|
49 |
+
global last_answer
|
50 |
|
51 |
if language == 'pt-br':
|
52 |
+
response = get_answers(retriever, GoogleTranslator(source='pt', target='en').translate(chat_history[-1][0]))
|
53 |
+
response = GoogleTranslator(source='en', target='pt').translate(response)
|
54 |
else:
|
55 |
+
response = get_answers(retriever, history[-1][0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
+
last_answer = response
|
58 |
|
59 |
+
for character in response:
|
60 |
+
chat_history[-1][1] += character
|
61 |
+
time.sleep(0.01)
|
62 |
+
yield chat_history
|
63 |
|
64 |
def get_answers(retriever, query):
|
65 |
from haystack.pipelines import FAQPipeline
|