Spaces:
Sleeping
Sleeping
Commit
·
67f3d25
1
Parent(s):
475ac32
....
Browse files- app.py +3 -3
- tabs/chatbot_tab.py +26 -11
app.py
CHANGED
|
@@ -88,7 +88,7 @@ def run():
|
|
| 88 |
)
|
| 89 |
with st.sidebar.expander(tr("Développez moi")):
|
| 90 |
st.markdown(tr("""
|
| 91 |
-
Cette application vous permet de tester les futures fonctionnalités de la plateforme Value Props, et plus particulièrement «
|
| 92 |
Amusez vous bien !
|
| 93 |
"""))
|
| 94 |
with st.sidebar:
|
|
@@ -103,7 +103,7 @@ def run():
|
|
| 103 |
})
|
| 104 |
# tab_name = st.sidebar.radio("", list(TABS.keys()), 0)
|
| 105 |
st.sidebar.markdown("---")
|
| 106 |
-
st.sidebar.markdown(f"## {config.PROMOTION}")
|
| 107 |
|
| 108 |
st.sidebar.markdown("### Auteur:")
|
| 109 |
for member in config.TEAM_MEMBERS:
|
|
@@ -111,7 +111,7 @@ def run():
|
|
| 111 |
|
| 112 |
with st.sidebar:
|
| 113 |
st.write("")
|
| 114 |
-
llm_choice = st.selectbox("
|
| 115 |
if (llm_choice == "OpenAI 3.5") : st.session_state.model = "gpt-3.5-turbo"
|
| 116 |
elif (llm_choice == "OpenAI 4o") : st.session_state.model = "gpt-4o"
|
| 117 |
else: st.session_state.model = "mistral-large-latest"
|
|
|
|
| 88 |
)
|
| 89 |
with st.sidebar.expander(tr("Développez moi")):
|
| 90 |
st.markdown(tr("""
|
| 91 |
+
Cette application vous permet de tester les futures fonctionnalités de la plateforme Value Props, et plus particulièrement le «Sales Coaching».
|
| 92 |
Amusez vous bien !
|
| 93 |
"""))
|
| 94 |
with st.sidebar:
|
|
|
|
| 103 |
})
|
| 104 |
# tab_name = st.sidebar.radio("", list(TABS.keys()), 0)
|
| 105 |
st.sidebar.markdown("---")
|
| 106 |
+
st.sidebar.markdown(f"## {tr(config.PROMOTION)}")
|
| 107 |
|
| 108 |
st.sidebar.markdown("### Auteur:")
|
| 109 |
for member in config.TEAM_MEMBERS:
|
|
|
|
| 111 |
|
| 112 |
with st.sidebar:
|
| 113 |
st.write("")
|
| 114 |
+
llm_choice = st.selectbox(tr("Modèle :"),["Mistral large","OpenAI 3.5","OpenAI 4o"], label_visibility="visible")
|
| 115 |
if (llm_choice == "OpenAI 3.5") : st.session_state.model = "gpt-3.5-turbo"
|
| 116 |
elif (llm_choice == "OpenAI 4o") : st.session_state.model = "gpt-4o"
|
| 117 |
else: st.session_state.model = "mistral-large-latest"
|
tabs/chatbot_tab.py
CHANGED
|
@@ -77,8 +77,6 @@ app = workflow.compile(checkpointer=memory)
|
|
| 77 |
def init():
|
| 78 |
global config,thread_id, context,human_message1,ai_message1,language, app, model_speech,language,prompt,model
|
| 79 |
|
| 80 |
-
thread_id = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 81 |
-
config = {"configurable": {"thread_id": thread_id}}
|
| 82 |
model_speech = whisper.load_model("base")
|
| 83 |
|
| 84 |
options = ["Directeur Commercial", "Directeur Général", "Directeur Marketing"]
|
|
@@ -192,15 +190,30 @@ Attention: Ce n'est pas toi qui m'aide, c'est moi qui t'aide avec ma solution.
|
|
| 192 |
AIMessage(content=ai_message1),
|
| 193 |
HumanMessage(content="")
|
| 194 |
]
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
app.invoke(
|
| 198 |
-
{"messages": messages, "language": language},
|
| 199 |
-
config,
|
| 200 |
-
)
|
| 201 |
|
| 202 |
st.write("")
|
| 203 |
-
st.session_state
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
return config, thread_id
|
| 205 |
|
| 206 |
# Fonction pour générer et jouer le texte en speech
|
|
@@ -267,6 +280,7 @@ def run():
|
|
| 267 |
config,thread_id = init()
|
| 268 |
query = ""
|
| 269 |
st.button(label=tr("Validez"), type="primary")
|
|
|
|
| 270 |
elif (chosen_id == "tab2"):
|
| 271 |
try:
|
| 272 |
config
|
|
@@ -342,8 +356,7 @@ def run():
|
|
| 342 |
custom_sentence = output["messages"][-1].content
|
| 343 |
|
| 344 |
# Joue l'audio
|
| 345 |
-
|
| 346 |
-
play_audio(custom_sentence,l , 1)
|
| 347 |
|
| 348 |
# st.write("**"+tr("Prospect :")+"** "+custom_sentence)
|
| 349 |
with st.chat_message("assistant"):
|
|
@@ -372,6 +385,8 @@ def run():
|
|
| 372 |
else:
|
| 373 |
st.write("")
|
| 374 |
st.write("")
|
|
|
|
|
|
|
| 375 |
q1 = st.text_input(label="", value=tr("Combien le vendeur a-t-il posé de questions ouvertes ?"),label_visibility="collapsed")
|
| 376 |
output = app.invoke(
|
| 377 |
{"messages": q1,"language": language},
|
|
|
|
| 77 |
def init():
|
| 78 |
global config,thread_id, context,human_message1,ai_message1,language, app, model_speech,language,prompt,model
|
| 79 |
|
|
|
|
|
|
|
| 80 |
model_speech = whisper.load_model("base")
|
| 81 |
|
| 82 |
options = ["Directeur Commercial", "Directeur Général", "Directeur Marketing"]
|
|
|
|
| 190 |
AIMessage(content=ai_message1),
|
| 191 |
HumanMessage(content="")
|
| 192 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
st.write("")
|
| 195 |
+
if ("context" in st.session_state) and ("human_message1" in st.session_state):
|
| 196 |
+
if (st.session_state.context != context) or (st.session_state.human_message1 != human_message1 ):
|
| 197 |
+
to_init = True
|
| 198 |
+
else:
|
| 199 |
+
to_init = False
|
| 200 |
+
else:
|
| 201 |
+
to_init = True
|
| 202 |
+
|
| 203 |
+
if to_init:
|
| 204 |
+
thread_id = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 205 |
+
config = {"configurable": {"thread_id": thread_id}}
|
| 206 |
+
app.invoke(
|
| 207 |
+
{"messages": messages, "language": language},
|
| 208 |
+
config,
|
| 209 |
+
)
|
| 210 |
+
st.session_state.thread_id = thread_id
|
| 211 |
+
st.session_state.config = config
|
| 212 |
+
st.session_state.messages_init = messages
|
| 213 |
+
st.session_state.context = context
|
| 214 |
+
st.session_state.human_message1 = human_message1
|
| 215 |
+
st.session_state.messages = []
|
| 216 |
+
|
| 217 |
return config, thread_id
|
| 218 |
|
| 219 |
# Fonction pour générer et jouer le texte en speech
|
|
|
|
| 280 |
config,thread_id = init()
|
| 281 |
query = ""
|
| 282 |
st.button(label=tr("Validez"), type="primary")
|
| 283 |
+
st.write("**thread_id:** "+thread_id)
|
| 284 |
elif (chosen_id == "tab2"):
|
| 285 |
try:
|
| 286 |
config
|
|
|
|
| 356 |
custom_sentence = output["messages"][-1].content
|
| 357 |
|
| 358 |
# Joue l'audio
|
| 359 |
+
play_audio(custom_sentence,Lang_detected , 1)
|
|
|
|
| 360 |
|
| 361 |
# st.write("**"+tr("Prospect :")+"** "+custom_sentence)
|
| 362 |
with st.chat_message("assistant"):
|
|
|
|
| 385 |
else:
|
| 386 |
st.write("")
|
| 387 |
st.write("")
|
| 388 |
+
st.write("**thread_id:** "+thread_id)
|
| 389 |
+
st.write("")
|
| 390 |
q1 = st.text_input(label="", value=tr("Combien le vendeur a-t-il posé de questions ouvertes ?"),label_visibility="collapsed")
|
| 391 |
output = app.invoke(
|
| 392 |
{"messages": q1,"language": language},
|