Spaces:
Running
Running
Ilyas KHIAT
commited on
Commit
·
5f96521
1
Parent(s):
aa26a9b
enhance
Browse files- audit_page/dialogue_doc.py +19 -3
audit_page/dialogue_doc.py
CHANGED
@@ -35,6 +35,16 @@ def chat_history_formatter(chat_history):
|
|
35 |
formatted_chat += f"Human:\n {message.content}\n\n"
|
36 |
return formatted_chat
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
def doc_dialog_main():
|
39 |
st.title("Dialogue avec le document")
|
40 |
|
@@ -182,7 +192,7 @@ def doc_dialog_main():
|
|
182 |
elif choice == "graphe de connaissance":
|
183 |
if "graph" not in st.session_state or st.session_state.graph == None:
|
184 |
with st.spinner("Génération du graphe..."):
|
185 |
-
keywords_list = audit["Mots clés"].strip().split(",")
|
186 |
allowed_nodes_types =keywords_list+ ["Person","Organization","Location","Event","Date","Time","Ressource","Concept"]
|
187 |
graph = get_graph(text,allowed_nodes=allowed_nodes_types)
|
188 |
st.session_state.graph = graph
|
@@ -219,11 +229,17 @@ def doc_dialog_main():
|
|
219 |
|
220 |
#add mots cles to evry label in audit["Mots clés"]
|
221 |
#filter_labels = [ label + " (mot clé)" if label.strip().lower() in audit["Mots clés"].strip().lower().split(",") else label for label in st.session_state.filter_views[st.session_state.current_view] ]
|
222 |
-
|
|
|
223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
if add_view_col.button("➕",help="Ajouter une vue"):
|
225 |
add_view_dialog(filter)
|
226 |
-
|
227 |
if filter:
|
228 |
nodes = filter_nodes_by_types(nodes,filter)
|
229 |
|
|
|
35 |
formatted_chat += f"Human:\n {message.content}\n\n"
|
36 |
return formatted_chat
|
37 |
|
38 |
+
def filter_correspondance(source_list:list[str],ref_dict:dict,reverse=False):
|
39 |
+
source_list = [item.lower().strip() for item in source_list]
|
40 |
+
if reverse:
|
41 |
+
return [key for key, value in ref_dict.items() if value.lower().strip() in source_list]
|
42 |
+
else:
|
43 |
+
# st.write(source_list)
|
44 |
+
# st.write(ref_dict.keys())
|
45 |
+
return [value for key, value in ref_dict.items() if key.lower().strip() in source_list]
|
46 |
+
|
47 |
+
|
48 |
def doc_dialog_main():
|
49 |
st.title("Dialogue avec le document")
|
50 |
|
|
|
192 |
elif choice == "graphe de connaissance":
|
193 |
if "graph" not in st.session_state or st.session_state.graph == None:
|
194 |
with st.spinner("Génération du graphe..."):
|
195 |
+
keywords_list = [keyword.strip() for keyword in audit["Mots clés"].strip().split(",")]
|
196 |
allowed_nodes_types =keywords_list+ ["Person","Organization","Location","Event","Date","Time","Ressource","Concept"]
|
197 |
graph = get_graph(text,allowed_nodes=allowed_nodes_types)
|
198 |
st.session_state.graph = graph
|
|
|
229 |
|
230 |
#add mots cles to evry label in audit["Mots clés"]
|
231 |
#filter_labels = [ label + " (mot clé)" if label.strip().lower() in audit["Mots clés"].strip().lower().split(",") else label for label in st.session_state.filter_views[st.session_state.current_view] ]
|
232 |
+
keywords_list = [keyword.strip().lower() for keyword in audit["Mots clés"].strip().split(",")]
|
233 |
+
dict_filters = {label: "Mot clé : "+label if label.strip().lower() in keywords_list else label for label in st.session_state.filter_views[st.session_state.current_view]}
|
234 |
|
235 |
+
default_target_filter = filter_correspondance(st.session_state.filter_views[st.session_state.current_view],dict_filters)
|
236 |
+
# st.write(default_target_filter)
|
237 |
+
# st.write(dict_filters)
|
238 |
+
target_filter = filter_correspondance(st.session_state.node_types.keys(),dict_filters)
|
239 |
+
filter = filter_col.multiselect("Filtrer selon l'étiquette",target_filter,placeholder="Sélectionner une ou plusieurs étiquettes",default=default_target_filter,label_visibility="collapsed")
|
240 |
+
filter = filter_correspondance(filter,dict_filters,reverse=True)
|
241 |
if add_view_col.button("➕",help="Ajouter une vue"):
|
242 |
add_view_dialog(filter)
|
|
|
243 |
if filter:
|
244 |
nodes = filter_nodes_by_types(nodes,filter)
|
245 |
|