Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
|
|
10 |
from streamlit_tags import st_tags
|
11 |
from streamlit_vertical_slider import vertical_slider
|
12 |
import pdf_generator
|
|
|
13 |
|
14 |
# Set page config
|
15 |
st.set_page_config(
|
@@ -54,12 +55,17 @@ if 'current_page' not in st.session_state:
|
|
54 |
if 'answers' not in st.session_state:
|
55 |
st.session_state.answers = {
|
56 |
'workload_scope': {
|
57 |
-
'
|
58 |
-
'
|
59 |
-
'
|
|
|
|
|
|
|
60 |
},
|
61 |
'useful_assets': {
|
62 |
-
'
|
|
|
|
|
63 |
},
|
64 |
'pilot_evaluation': {
|
65 |
'metrics': []
|
@@ -77,7 +83,7 @@ pages = [
|
|
77 |
'input_type': 'custom'
|
78 |
},
|
79 |
{
|
80 |
-
'title': "
|
81 |
'content': """
|
82 |
Discuss the useful assets and libraries that can be utilized for the project. Consider Langchain, Langflow, ChromaDB, Jupyter Notebooks, etc.
|
83 |
""",
|
@@ -130,62 +136,67 @@ if 'input_key' in current_page and current_page['input_key'] is not None:
|
|
130 |
st.subheader("Workload Scope")
|
131 |
col1, col2, col3 = st.columns(3)
|
132 |
with col1:
|
133 |
-
st.session_state.answers['workload_scope']['
|
134 |
-
"Time Commitments:",
|
135 |
-
value=st.session_state.answers['workload_scope'].get('time_commitments', ""),
|
136 |
-
key="time_commitments",
|
137 |
-
height=150
|
138 |
-
)
|
139 |
with col2:
|
140 |
-
st.session_state.answers['workload_scope']['
|
141 |
-
"Deadlines:",
|
142 |
-
value=st.session_state.answers['workload_scope'].get('deadlines', ""),
|
143 |
-
key="deadlines",
|
144 |
-
height=150
|
145 |
-
)
|
146 |
with col3:
|
147 |
-
st.session_state.answers['workload_scope']['
|
148 |
-
|
149 |
-
value=st.session_state.answers['workload_scope'].get('feature_prioritization', ""),
|
150 |
-
key="feature_prioritization",
|
151 |
-
height=150
|
152 |
-
)
|
153 |
|
154 |
elif current_page['input_key'] == 'useful_assets':
|
155 |
-
st.
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
value=st.session_state.answers['useful_assets']
|
160 |
-
|
161 |
-
maxtags=5,
|
162 |
-
key='useful_assets'
|
163 |
-
)
|
164 |
-
st.session_state.answers['useful_assets']['assets'] = assets
|
165 |
|
166 |
elif current_page['input_key'] == 'pilot_evaluation':
|
167 |
-
st.subheader("
|
168 |
-
|
169 |
-
|
170 |
-
text='Press enter to add more',
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
# Generate PDF button (only on the last page)
|
179 |
if st.session_state.current_page == len(pages) - 1:
|
180 |
if st.button("Generate and Download PDF", use_container_width=True):
|
181 |
pdf = pdf_generator.generate_pdf(st.session_state)
|
182 |
-
st.download_button(
|
183 |
-
label="Download PDF",
|
184 |
-
data=pdf,
|
185 |
-
file_name="Pilot_Drafting.pdf",
|
186 |
-
mime="application/pdf",
|
187 |
-
use_container_width=True
|
188 |
-
)
|
189 |
|
190 |
# Display progress
|
191 |
st.progress((st.session_state.current_page + 1) / len(pages))
|
|
|
10 |
from streamlit_tags import st_tags
|
11 |
from streamlit_vertical_slider import vertical_slider
|
12 |
import pdf_generator
|
13 |
+
import datetime
|
14 |
|
15 |
# Set page config
|
16 |
st.set_page_config(
|
|
|
55 |
if 'answers' not in st.session_state:
|
56 |
st.session_state.answers = {
|
57 |
'workload_scope': {
|
58 |
+
'feature_prioritization': ['', '', '', '', ''],
|
59 |
+
'preferred_start_period': '',
|
60 |
+
'team_composition': {
|
61 |
+
'partner': '',
|
62 |
+
'ibm': ''
|
63 |
+
}
|
64 |
},
|
65 |
'useful_assets': {
|
66 |
+
'solution_elements': [],
|
67 |
+
'ibm_software': [],
|
68 |
+
'open_source_supports': []
|
69 |
},
|
70 |
'pilot_evaluation': {
|
71 |
'metrics': []
|
|
|
83 |
'input_type': 'custom'
|
84 |
},
|
85 |
{
|
86 |
+
'title': "Solution Elements",
|
87 |
'content': """
|
88 |
Discuss the useful assets and libraries that can be utilized for the project. Consider Langchain, Langflow, ChromaDB, Jupyter Notebooks, etc.
|
89 |
""",
|
|
|
136 |
st.subheader("Workload Scope")
|
137 |
col1, col2, col3 = st.columns(3)
|
138 |
with col1:
|
139 |
+
st.session_state.answers['workload_scope']['feature_prioritization'] = [st.text_area(f"Feature Prioritization {i+1}", value=st.session_state.answers['workload_scope']['feature_prioritization'][i], height=100) for i in range(5)]
|
|
|
|
|
|
|
|
|
|
|
140 |
with col2:
|
141 |
+
st.session_state.answers['workload_scope']['preferred_start_period'] = st.date_input("Preferred Start Period", value=(datetime.date.today(), datetime.date.today() + datetime.timedelta(days=30)))
|
|
|
|
|
|
|
|
|
|
|
142 |
with col3:
|
143 |
+
st.session_state.answers['workload_scope']['team_composition']['partner'] = st.text_area("Partner", value=st.session_state.answers['workload_scope']['team_composition']['partner'], height=150)
|
144 |
+
st.session_state.answers['workload_scope']['team_composition']['ibm'] = st.text_area("IBM", value=st.session_state.answers['workload_scope']['team_composition']['ibm'], height=150)
|
|
|
|
|
|
|
|
|
145 |
|
146 |
elif current_page['input_key'] == 'useful_assets':
|
147 |
+
st.info(st.session_state.answers['workload_scope']['feature_prioritization'])
|
148 |
+
st.subheader("Solution Elements")
|
149 |
+
col1, col2 = st.columns(2)
|
150 |
+
with col1:
|
151 |
+
st.session_state.answers['useful_assets']['ibm_software'] = st_tags(label='Enter IBM Software:', text='Press enter to add more', value=st.session_state.answers['useful_assets']['ibm_software'], suggestions=[], maxtags=5, key='ibm_software')
|
152 |
+
with col2:
|
153 |
+
st.session_state.answers['useful_assets']['open_source_supports'] = st_tags(label='Enter Open Source Supports:', text='Press enter to add more', value=st.session_state.answers['useful_assets']['open_source_supports'], suggestions=[], maxtags=5, key='open_source_supports')
|
|
|
|
|
|
|
154 |
|
155 |
elif current_page['input_key'] == 'pilot_evaluation':
|
156 |
+
st.subheader("Evaluation Criteria")
|
157 |
+
col1, col2 = st.columns(2)
|
158 |
+
with col1:
|
159 |
+
qualitative_criteria = st_tags(label='Enter Qualitative Criteria:', text='Press enter to add more', value=st.session_state.answers['useful_assets'].get('qualitative', []), suggestions=[], maxtags=5, key='qualitative_criteria')
|
160 |
+
st.session_state.answers['useful_assets']['qualitative'] = qualitative_criteria
|
161 |
+
|
162 |
+
# Add description fields for each qualitative criterion
|
163 |
+
for i, criterion in enumerate(qualitative_criteria):
|
164 |
+
description_key = f'qual_desc_{i}'
|
165 |
+
description = st.text_area(f"Description for {criterion}:", value=st.session_state.answers['useful_assets'].get(description_key, ""), key=description_key, height=100)
|
166 |
+
st.session_state.answers['useful_assets'][description_key] = description
|
167 |
+
|
168 |
+
with col2:
|
169 |
+
quantitative_criteria = st_tags(label='Enter Quantitative Criteria:', text='Use format: CriteriaName[min - max] (can use %, floats, or integers)', value=st.session_state.answers['useful_assets'].get('quantitative', []), suggestions=[], maxtags=5, key='quantitative_criteria')
|
170 |
+
st.session_state.answers['useful_assets']['quantitative'] = quantitative_criteria
|
171 |
+
|
172 |
+
if quantitative_criteria:
|
173 |
+
slider_cols = st.columns(len(quantitative_criteria))
|
174 |
+
for i, (criterion, slider_col) in enumerate(zip(quantitative_criteria, slider_cols)):
|
175 |
+
parsed = pdf_generator.parse_quantitative_criteria(criterion)
|
176 |
+
if parsed:
|
177 |
+
name, min_val, max_val, is_percentage, is_integer = parsed
|
178 |
+
current_value = st.session_state.answers['useful_assets'].get(f'quant_value_{i}', min_val)
|
179 |
+
|
180 |
+
with slider_col:
|
181 |
+
value = vertical_slider(label=name, key=f"quant_slider_{i}", min_value=min_val, max_value=max_val, step=(max_val - min_val) / 100, default_value=current_value, height=200, thumb_shape="circle", thumb_color="#9999FF", slider_color=('green', 'orange'), value_always_visible=True)
|
182 |
+
|
183 |
+
st.session_state.answers['useful_assets'][f'quant_value_{i}'] = value
|
184 |
+
|
185 |
+
if is_percentage:
|
186 |
+
st.markdown(f"**{name}: {value*100:.1f}%**")
|
187 |
+
elif is_integer:
|
188 |
+
st.markdown(f"**{name}: {int(value)}**")
|
189 |
+
else:
|
190 |
+
st.markdown(f"**{name}: {value:.2f}**")
|
191 |
+
else:
|
192 |
+
st.warning(f"Invalid format for quantitative criterion: {criterion}")
|
193 |
+
|
194 |
|
195 |
# Generate PDF button (only on the last page)
|
196 |
if st.session_state.current_page == len(pages) - 1:
|
197 |
if st.button("Generate and Download PDF", use_container_width=True):
|
198 |
pdf = pdf_generator.generate_pdf(st.session_state)
|
199 |
+
st.download_button(label="Download PDF", data=pdf, file_name="Pilot_Drafting.pdf", mime="application/pdf", use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
|
201 |
# Display progress
|
202 |
st.progress((st.session_state.current_page + 1) / len(pages))
|