Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -75,7 +75,12 @@ def respond(
|
|
75 |
messages.append({"role": "assistant", "content": val[1]})
|
76 |
|
77 |
#latest user question
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
79 |
#print(messages)
|
80 |
|
81 |
response = ""
|
@@ -88,9 +93,9 @@ def respond(
|
|
88 |
top_p=top_p,
|
89 |
):
|
90 |
token = message.choices[0].delta.content
|
91 |
-
|
92 |
response += token
|
93 |
-
|
|
|
94 |
|
95 |
"""
|
96 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
|
|
75 |
messages.append({"role": "assistant", "content": val[1]})
|
76 |
|
77 |
#latest user question
|
78 |
+
from googletrans import Translator
|
79 |
+
translator = Translator()
|
80 |
+
message_language = translator.detect(message).lang
|
81 |
+
print(message_language)
|
82 |
+
en_message = translator.translate(message).text
|
83 |
+
messages.append({"role": "user", "content": en_message})
|
84 |
#print(messages)
|
85 |
|
86 |
response = ""
|
|
|
93 |
top_p=top_p,
|
94 |
):
|
95 |
token = message.choices[0].delta.content
|
|
|
96 |
response += token
|
97 |
+
translated_response = translator.translate(response, src='en', dest=message_language).text
|
98 |
+
yield translated_response
|
99 |
|
100 |
"""
|
101 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|