Spaces:
Running
Running
Commit ·
5fd1333
1
Parent(s): 9e31ffc
Update chatbot_tab.py
Browse files- tabs/chatbot_tab.py +12 -2
tabs/chatbot_tab.py
CHANGED
|
@@ -138,6 +138,15 @@ def get_llm():
|
|
| 138 |
)
|
| 139 |
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
def init_run():
|
| 142 |
global initialized, to_init, thread_id, config, app, context, human_message1, model, used_model, messages
|
| 143 |
|
|
@@ -458,7 +467,8 @@ def run():
|
|
| 458 |
{"role": "user", "content": query})
|
| 459 |
|
| 460 |
# Récupération de la réponse
|
| 461 |
-
custom_sentence =
|
|
|
|
| 462 |
|
| 463 |
# Joue l'audio
|
| 464 |
play_audio(custom_sentence, Lang_detected, 1)
|
|
@@ -504,7 +514,7 @@ def run():
|
|
| 504 |
# {"messages": q,"language": language},
|
| 505 |
# config,
|
| 506 |
# )
|
| 507 |
-
custom_sentence = output["messages"][-1].content
|
| 508 |
st.write(custom_sentence)
|
| 509 |
st.write("")
|
| 510 |
if (used_model[:3] == 'mis'):
|
|
|
|
| 138 |
)
|
| 139 |
|
| 140 |
|
| 141 |
+
def extract_text(content):
|
| 142 |
+
if isinstance(content, list):
|
| 143 |
+
return "".join(
|
| 144 |
+
block.get("text", "") for block in content
|
| 145 |
+
if isinstance(block, dict) and block.get("type") == "text"
|
| 146 |
+
)
|
| 147 |
+
return str(content)
|
| 148 |
+
|
| 149 |
+
|
| 150 |
def init_run():
|
| 151 |
global initialized, to_init, thread_id, config, app, context, human_message1, model, used_model, messages
|
| 152 |
|
|
|
|
| 467 |
{"role": "user", "content": query})
|
| 468 |
|
| 469 |
# Récupération de la réponse
|
| 470 |
+
custom_sentence = extract_text(
|
| 471 |
+
output["messages"][-1].content)
|
| 472 |
|
| 473 |
# Joue l'audio
|
| 474 |
play_audio(custom_sentence, Lang_detected, 1)
|
|
|
|
| 514 |
# {"messages": q,"language": language},
|
| 515 |
# config,
|
| 516 |
# )
|
| 517 |
+
custom_sentence = extract_text(output["messages"][-1].content)
|
| 518 |
st.write(custom_sentence)
|
| 519 |
st.write("")
|
| 520 |
if (used_model[:3] == 'mis'):
|