awacke1 commited on
Commit
ba59039
Β·
verified Β·
1 Parent(s): ea6602a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +79 -0
app.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ # If you want to render Mermaid diagrams directly in Streamlit,
3
+ # install streamlit-mermaid: pip install streamlit-mermaid
4
+ # and then uncomment the following import:
5
+ # import streamlit_mermaid as st_mermaid
6
+
7
+ # -----------------------------------------------------------------------------------
8
+ # Default Mermaid code: a simple AI Architecture diagram with short text + emoji
9
+ # -----------------------------------------------------------------------------------
10
+ DEFAULT_MERMAID = """
11
+ flowchart LR
12
+ %% A short, labeled, emoji-filled flow
13
+ U((User 😎)) -- "Talk πŸ—£οΈ" --> LLM[LLM Agent πŸ€–\\nExtract Info]
14
+ LLM -- "Query πŸ”" --> HS[Hybrid Search πŸ”Ž\\nVector+NER+Lexical]
15
+ HS -- "Reason πŸ€”" --> RE[Reasoning Engine πŸ› οΈ\\nNeuralNetwork+Medical]
16
+ RE -- "Link πŸ“‘" --> KG((Knowledge Graph πŸ“š\\nOntology+GAR+RAG))
17
+ """
18
+
19
+ def main():
20
+ st.title("Mermaid Diagram Editor 🏺")
21
+
22
+ # Create two columns: left for Markdown, right for Mermaid
23
+ left_col, right_col = st.columns(2)
24
+
25
+ # --- Left Column: Markdown Editor ---
26
+ with left_col:
27
+ st.subheader("Markdown Side πŸ“")
28
+ markdown_text = st.text_area(
29
+ "Edit Markdown:",
30
+ value="## Hello!\nYou can type *Markdown* here.\n",
31
+ height=400
32
+ )
33
+
34
+ # A small button bar at bottom
35
+ colA, colB = st.columns([1,1])
36
+ with colA:
37
+ if st.button("πŸ”„ Refresh Markdown"):
38
+ st.write("**Markdown** content refreshed!")
39
+ with colB:
40
+ if st.button("❌ Clear Markdown"):
41
+ markdown_text = ""
42
+ st.experimental_rerun()
43
+
44
+ # Show the rendered Markdown below
45
+ st.markdown("---")
46
+ st.markdown("**Preview:**")
47
+ st.markdown(markdown_text)
48
+
49
+ # --- Right Column: Mermaid Editor ---
50
+ with right_col:
51
+ st.subheader("Mermaid Side πŸ§œβ€β™‚οΈ")
52
+ mermaid_code = st.text_area(
53
+ "Edit Mermaid Code:",
54
+ value=DEFAULT_MERMAID,
55
+ height=400
56
+ )
57
+
58
+ # A small button bar at bottom
59
+ colC, colD = st.columns([1,1])
60
+ with colC:
61
+ if st.button("🎨 Refresh Diagram"):
62
+ st.write("**Mermaid** diagram refreshed!")
63
+ with colD:
64
+ if st.button("❌ Clear Mermaid"):
65
+ mermaid_code = ""
66
+ st.experimental_rerun()
67
+
68
+ st.markdown("---")
69
+ st.markdown("**Mermaid Source:**")
70
+ st.code(mermaid_code, language="python", line_numbers=True)
71
+
72
+ # If streamlit-mermaid is installed, render the live diagram here:
73
+ # try:
74
+ # st_mermaid.mermaid(mermaid_code)
75
+ # except Exception as e:
76
+ # st.error("Could not render Mermaid diagram. " + str(e))
77
+
78
+ if __name__ == "__main__":
79
+ main()