Spaces:
Sleeping
Sleeping
Ilyas KHIAT
commited on
Commit
•
f95928b
1
Parent(s):
41671a6
prompts suggestions and pdf fix
Browse files- chat_with_pps.py +12 -3
- prompt.py +1 -1
chat_with_pps.py
CHANGED
@@ -150,8 +150,7 @@ def display_chart():
|
|
150 |
|
151 |
@st.experimental_dialog("Choisissez un prompt",width="large")
|
152 |
def show_prompts():
|
153 |
-
|
154 |
-
st.rerun()
|
155 |
if st.button("Fermer"):
|
156 |
st.rerun()
|
157 |
|
@@ -245,6 +244,13 @@ def extract_format_prompts_from_response(response):
|
|
245 |
def extract_pp_from_query(query):
|
246 |
return " ".join(query.split(" ")[1:])
|
247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
def display_chat():
|
249 |
# app config
|
250 |
st.title("Chatbot")
|
@@ -318,6 +324,10 @@ def display_chat():
|
|
318 |
st.write(message.content)
|
319 |
if "cartographie" in message.content:
|
320 |
display_chart()
|
|
|
|
|
|
|
|
|
321 |
elif isinstance(message, HumanMessage):
|
322 |
with st.chat_message("Moi"):
|
323 |
st.write(message.content)
|
@@ -341,7 +351,6 @@ def display_chat():
|
|
341 |
extract_format_prompts_from_response(propositions_prompts)
|
342 |
|
343 |
|
344 |
-
|
345 |
if "pp_grouped" not in st.session_state or st.session_state['pp_grouped'] is None or len(st.session_state['pp_grouped']) == 0:
|
346 |
st.session_state['pp_grouped'] = []
|
347 |
if "Nom de la marque" not in st.session_state:
|
|
|
150 |
|
151 |
@st.experimental_dialog("Choisissez un prompt",width="large")
|
152 |
def show_prompts():
|
153 |
+
get_prompts_list()
|
|
|
154 |
if st.button("Fermer"):
|
155 |
st.rerun()
|
156 |
|
|
|
244 |
def extract_pp_from_query(query):
|
245 |
return " ".join(query.split(" ")[1:])
|
246 |
|
247 |
+
def display_prompts(prompts):
|
248 |
+
for i,prompt in enumerate(prompts):
|
249 |
+
col1,col2 = st.columns([9,1])
|
250 |
+
col1.markdown(f"{prompt}")
|
251 |
+
col2.button("➡️",key=f"execf_{i}",on_click=lambda i=i: st.session_state.chat_history.append(HumanMessage(content=prompts[i])))
|
252 |
+
|
253 |
+
|
254 |
def display_chat():
|
255 |
# app config
|
256 |
st.title("Chatbot")
|
|
|
324 |
st.write(message.content)
|
325 |
if "cartographie" in message.content:
|
326 |
display_chart()
|
327 |
+
if message.content == st.session_state.chat_history[0].content:
|
328 |
+
st.markdown("---\n")
|
329 |
+
first_prompts = ["Quels mécanismes de communication me suggères tu pour maintenir un dialogue régulier avec mes parties prenantes clés ?","En plus des parties prenantes déjà identifiées que tu peux consulter, quels groupes ou individus, impactés par les activités de mon organisation, devrais ajouter dans notre cartographie des parties prenantes ?"]
|
330 |
+
display_prompts(first_prompts)
|
331 |
elif isinstance(message, HumanMessage):
|
332 |
with st.chat_message("Moi"):
|
333 |
st.write(message.content)
|
|
|
351 |
extract_format_prompts_from_response(propositions_prompts)
|
352 |
|
353 |
|
|
|
354 |
if "pp_grouped" not in st.session_state or st.session_state['pp_grouped'] is None or len(st.session_state['pp_grouped']) == 0:
|
355 |
st.session_state['pp_grouped'] = []
|
356 |
if "Nom de la marque" not in st.session_state:
|
prompt.py
CHANGED
@@ -54,7 +54,7 @@ def get_prompts_list():
|
|
54 |
|
55 |
if execute:
|
56 |
st.session_state.chat_history.append(HumanMessage(content=prompts[i]['text']))
|
57 |
-
|
58 |
if do_action:
|
59 |
prompt_html = prompts[i]['text'].replace('\n', '<br>')
|
60 |
prompt_metadata = extract_metadata(prompts[i])
|
|
|
54 |
|
55 |
if execute:
|
56 |
st.session_state.chat_history.append(HumanMessage(content=prompts[i]['text']))
|
57 |
+
st.rerun()
|
58 |
if do_action:
|
59 |
prompt_html = prompts[i]['text'].replace('\n', '<br>')
|
60 |
prompt_metadata = extract_metadata(prompts[i])
|