Spaces:
Build error
Build error
Commit ·
388c629
1
Parent(s): 4ba3f06
add translation
Browse files- src/app.py +3 -1
- src/handler.py +3 -0
src/app.py
CHANGED
|
@@ -225,10 +225,12 @@ if selected == "Chatbot":
|
|
| 225 |
last_question = is_feedback['last_qna']['question']
|
| 226 |
|
| 227 |
if not last_question:
|
|
|
|
|
|
|
| 228 |
st.session_state.messages.append({
|
| 229 |
"role": "assistant",
|
| 230 |
"type": "warning",
|
| 231 |
-
"content":
|
| 232 |
})
|
| 233 |
st.rerun()
|
| 234 |
else:
|
|
|
|
| 225 |
last_question = is_feedback['last_qna']['question']
|
| 226 |
|
| 227 |
if not last_question:
|
| 228 |
+
resp = "Sorry, you have not asked a question, or the session has been reset. Please ask a question first before providing feedback."
|
| 229 |
+
mssg = translate_answer(query, resp)
|
| 230 |
st.session_state.messages.append({
|
| 231 |
"role": "assistant",
|
| 232 |
"type": "warning",
|
| 233 |
+
"content": mssg
|
| 234 |
})
|
| 235 |
st.rerun()
|
| 236 |
else:
|
src/handler.py
CHANGED
|
@@ -67,6 +67,9 @@ def save_feedback(feedback_obj: dict, last_qna: dict) -> str:
|
|
| 67 |
return f"An error occured when saving feedback: {str(e)}"
|
| 68 |
|
| 69 |
def translate_answer(question, answer):
|
|
|
|
|
|
|
|
|
|
| 70 |
detected_lang_question = detect(question)
|
| 71 |
detected_lang_answer = detect(answer)
|
| 72 |
|
|
|
|
| 67 |
return f"An error occured when saving feedback: {str(e)}"
|
| 68 |
|
| 69 |
def translate_answer(question, answer):
|
| 70 |
+
if len(question) < 5:
|
| 71 |
+
return answer
|
| 72 |
+
|
| 73 |
detected_lang_question = detect(question)
|
| 74 |
detected_lang_answer = detect(answer)
|
| 75 |
|