-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathapp.py
More file actions
146 lines (123 loc) · 4.71 KB
/
app.py
File metadata and controls
146 lines (123 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import subprocess
import sys
from pathlib import Path
import streamlit as st
from streamlit.runtime.scriptrunner import get_script_run_ctx
def inject_css() -> None:
with open("styles.css", "r") as file:
css_file = file.read()
st.markdown(
f"""
<style>
{css_file}
</style>
""",
unsafe_allow_html=True,
)
def _launch_via_streamlit() -> None:
script_path = Path(__file__).resolve()
result = subprocess.run(
[sys.executable, "-m", "streamlit", "run", str(script_path)],
check=False,
)
raise SystemExit(result.returncode)
def run_app():
pg = st.navigation(
[
st.Page(
"setup_page.py",
title="Setup",
icon=":material/settings_suggest:",
default=True,
),
st.Page("promoai_page.py", title="ProMoAI", icon=":material/account_tree:"),
st.Page("pmax.py", title="PMAx", icon=":material/query_stats:"),
]
)
pg.run()
def sidebar_info():
if "resettable" not in st.session_state:
st.session_state["resettable"] = False
with st.sidebar:
if st.session_state["resettable"]:
st.markdown(
"<div class='sidebar-header'>Session</div>", unsafe_allow_html=True
)
if st.sidebar.button("🔄 Reset PMAx", use_container_width=True):
st.session_state["setup_complete"] = False
if "uploaded_log" in st.session_state:
del st.session_state["uploaded_log"]
if "uploaded_log_path" in st.session_state:
del st.session_state["uploaded_log_path"]
if "agent_state" in st.session_state:
del st.session_state["agent_state"]
if "artifact_session_dir" in st.session_state:
del st.session_state["artifact_session_dir"]
if "messages" in st.session_state:
del st.session_state["messages"]
if "pdf_bytes" in st.session_state:
del st.session_state["pdf_bytes"]
if "pdf_signature" in st.session_state:
del st.session_state["pdf_signature"]
st.session_state["resettable"] = False
st.rerun()
# ---------- RESOURCES (TOP) ----------
st.markdown(
"<div class='sidebar-header'>Resources</div>", unsafe_allow_html=True
)
st.markdown(
"""
<div class="sidebar-card">
<a class="sidebar-link" href="https://doi.org/10.24963/ijcai.2024/1014" target="_blank">
<span style="font-size:1.2rem;">📄</span>
<div>
<span class="card-text-main">ProMoAI Paper</span>
<span class="card-text-sub">IJCAI 2024</span>
</div>
</a>
</div>
""",
unsafe_allow_html=True,
)
st.markdown(
"""
<div class="sidebar-card">
<a class="sidebar-link" href="https://doi.org/10.48550/arXiv.2603.15351" target="_blank">
<span style="font-size:1.2rem;">📄</span>
<div>
<span class="card-text-main">PMAx Paper</span>
<span class="card-text-sub">Pre-Print</span>
</div>
</a>
</div>
""",
unsafe_allow_html=True,
)
st.markdown(
"""
<div class='sidebar-header'>Support</div>
<div class="sidebar-card">
<a class="sidebar-link" href="mailto:humam.kourani@fit.fraunhofer.de;a.berti@pads.rwth-aachen.de;anton.antonov@fit.fraunhofer.de?subject=ProMoAI Inquiry">
<span style="font-size:1.2rem;">✉️</span>
<div>
<span class="card-text-main">Contact Developers</span>
</div>
</a>
</div>
<div class='sidebar-header'>Developed at</div>
<a href="https://www.fit.fraunhofer.de/" target="_blank" class="branding-badge">
<img src="https://www.fit.fraunhofer.de/content/dam/fit/fit.svg">
<div class="branding-text">
Fraunhofer Institute for Applied<br>Information Technology FIT
</div>
</a>
""",
unsafe_allow_html=True,
)
if __name__ == "__main__":
if get_script_run_ctx() is None:
_launch_via_streamlit()
inject_css()
st.set_page_config(page_title="ProMoAI", page_icon="🤖")
sidebar_info()
run_app()