Spaces:
Sleeping
Sleeping
Commit
·
8aef1af
1
Parent(s):
2ba3545
Update app.py
Browse files
app.py
CHANGED
|
@@ -200,56 +200,57 @@ def draw_graph(graph_data, current_node, predicted_path):
|
|
| 200 |
|
| 201 |
dot = graphviz.Digraph()
|
| 202 |
|
| 203 |
-
# ---
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
|
|
|
|
|
|
| 209 |
|
| 210 |
-
#
|
| 211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
|
| 213 |
-
#
|
|
|
|
|
|
|
| 214 |
for n in nodes:
|
| 215 |
-
# Базовий стиль (
|
| 216 |
-
fill = '#
|
| 217 |
-
color = '#BDC3C7'
|
| 218 |
-
pen = '1'
|
| 219 |
-
fontcolor = 'black'
|
| 220 |
|
| 221 |
-
#
|
| 222 |
-
if n == current_node:
|
| 223 |
-
fill = '#FF4B4B'
|
| 224 |
-
color = 'black'
|
| 225 |
-
pen = '3' # Товстіша рамка
|
| 226 |
-
fontcolor = 'white' # Білий текст на червоному фоні
|
| 227 |
|
| 228 |
-
#
|
| 229 |
-
elif n in predicted_path:
|
| 230 |
-
fill = '#
|
| 231 |
-
color = '#F1C40F'
|
| 232 |
-
pen = '2'
|
| 233 |
|
| 234 |
-
|
|
|
|
| 235 |
|
| 236 |
-
# Малюємо ребра (стрілочки)
|
| 237 |
for e in edges:
|
| 238 |
-
color = '#
|
| 239 |
-
pen = '1'
|
| 240 |
|
| 241 |
-
#
|
| 242 |
if e["from"] in predicted_path and e["to"] in predicted_path:
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
pen = '2'
|
| 250 |
-
except ValueError:
|
| 251 |
-
pass # Якщо раптом вузол не в списку, ігноруємо
|
| 252 |
-
|
| 253 |
dot.edge(e["from"], e["to"], color=color, penwidth=pen)
|
| 254 |
|
| 255 |
return dot
|
|
@@ -356,7 +357,10 @@ elif st.session_state.page == "chat":
|
|
| 356 |
curr_id = node_to_id[st.session_state.current_node]
|
| 357 |
target_id = node_to_id["close_deal"] # Fixed: using close_deal from sales_script.json
|
| 358 |
path = get_predicted_path(graph, curr_id, target_id, id_to_node, node_to_id)
|
| 359 |
-
st.graphviz_chart(
|
|
|
|
|
|
|
|
|
|
| 360 |
|
| 361 |
with col_chat:
|
| 362 |
for msg in st.session_state.messages:
|
|
|
|
| 200 |
|
| 201 |
dot = graphviz.Digraph()
|
| 202 |
|
| 203 |
+
# --- НАЛАШТУВАННЯ ГЕОМЕТРІЇ (Compact Mode) ---
|
| 204 |
+
dot.attr(
|
| 205 |
+
rankdir='TB', # Зверху вниз
|
| 206 |
+
splines='ortho', # Ламані лінії (прямі кути)
|
| 207 |
+
nodesep='0.3', # Мінімальний відступ збоку
|
| 208 |
+
ranksep='0.4', # Мінімальний відступ знизу (робить граф коротшим)
|
| 209 |
+
bgcolor='transparent' # Прозорий фон, щоб зливався з темою
|
| 210 |
+
)
|
| 211 |
|
| 212 |
+
# --- СТИЛЬ БЛОКІВ (Wide & Slim) ---
|
| 213 |
+
# shape='note' виглядає як документ, або 'box' для суворості
|
| 214 |
+
# fixedsize='false' дозволяє блоку розтягуватись під текст, але ми задаємо мінімальну ширину
|
| 215 |
+
dot.attr('node',
|
| 216 |
+
shape='box',
|
| 217 |
+
style='rounded,filled',
|
| 218 |
+
fontname='Arial',
|
| 219 |
+
fontsize='11',
|
| 220 |
+
width='2.5', # Робимо їх широкими
|
| 221 |
+
height='0.5', # Робимо їх низькими
|
| 222 |
+
margin='0.1' # Менше полів всередині блоку
|
| 223 |
+
)
|
| 224 |
|
| 225 |
+
# --- СТИЛЬ ЛІНІЙ ---
|
| 226 |
+
dot.attr('edge', fontname='Arial', fontsize='9', arrowsize='0.6')
|
| 227 |
+
|
| 228 |
for n in nodes:
|
| 229 |
+
# Базовий стиль (Світло-сірий, непомітний)
|
| 230 |
+
fill = '#F7F9F9'; color = '#BDC3C7'; pen = '1'; font = '#424949'
|
|
|
|
|
|
|
|
|
|
| 231 |
|
| 232 |
+
# Поточний крок (Червоний акцент)
|
| 233 |
+
if n == current_node:
|
| 234 |
+
fill = '#FF4B4B'; color = '#922B21'; pen = '2'; font = 'white'
|
|
|
|
|
|
|
|
|
|
| 235 |
|
| 236 |
+
# Золотий шлях (Жовтий підсвіт)
|
| 237 |
+
elif n in predicted_path:
|
| 238 |
+
fill = '#FEF9E7'; color = '#F1C40F'; pen = '1'; font = 'black'
|
|
|
|
|
|
|
| 239 |
|
| 240 |
+
# Малюємо вузол
|
| 241 |
+
dot.node(n, label=n, fillcolor=fill, color=color, penwidth=pen, fontcolor=font)
|
| 242 |
|
|
|
|
| 243 |
for e in edges:
|
| 244 |
+
color = '#D5D8DC'; pen = '1' # Дуже світлі лінії за замовчуванням
|
|
|
|
| 245 |
|
| 246 |
+
# Підсвітка шляху
|
| 247 |
if e["from"] in predicted_path and e["to"] in predicted_path:
|
| 248 |
+
try:
|
| 249 |
+
# Перевіряємо послідовність
|
| 250 |
+
if predicted_path.index(e["to"]) == predicted_path.index(e["from"]) + 1:
|
| 251 |
+
color = '#F1C40F'; pen = '2.5' # Жирна золота лінія
|
| 252 |
+
except: pass
|
| 253 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
dot.edge(e["from"], e["to"], color=color, penwidth=pen)
|
| 255 |
|
| 256 |
return dot
|
|
|
|
| 357 |
curr_id = node_to_id[st.session_state.current_node]
|
| 358 |
target_id = node_to_id["close_deal"] # Fixed: using close_deal from sales_script.json
|
| 359 |
path = get_predicted_path(graph, curr_id, target_id, id_to_node, node_to_id)
|
| 360 |
+
st.graphviz_chart(
|
| 361 |
+
draw_graph(graph_data, st.session_state.current_node, path),
|
| 362 |
+
use_container_width=True # Розтягує граф на всю ширину колонки
|
| 363 |
+
)
|
| 364 |
|
| 365 |
with col_chat:
|
| 366 |
for msg in st.session_state.messages:
|