Spaces:
Paused
Paused
WaysAhead Global commited on
Upload visualization.py
Browse files
reasoning_ai_app/utils/visualization.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import graphviz
|
| 3 |
+
|
| 4 |
+
def show_reasoning_graph(steps):
|
| 5 |
+
st.markdown("### 🧭 Reasoning Flow Chart")
|
| 6 |
+
dot = graphviz.Digraph()
|
| 7 |
+
dot.attr(rankdir='LR', size='8,5')
|
| 8 |
+
|
| 9 |
+
for idx, step in enumerate(steps.split('\n')):
|
| 10 |
+
label = step.strip().replace("\"", "'")
|
| 11 |
+
if label:
|
| 12 |
+
dot.node(f"S{idx}", label)
|
| 13 |
+
|
| 14 |
+
for i in range(len(steps.split('\n')) - 1):
|
| 15 |
+
dot.edge(f"S{i}", f"S{i+1}")
|
| 16 |
+
|
| 17 |
+
st.graphviz_chart(dot)
|