Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -37,7 +37,7 @@ from io import BytesIO
|
|
37 |
|
38 |
|
39 |
# page config and sidebar declares up front allow all other functions to see global class variables
|
40 |
-
st.set_page_config(page_title="
|
41 |
should_save = st.sidebar.checkbox("πΎ Save", value=True)
|
42 |
col1, col2, col3, col4 = st.columns(4)
|
43 |
with col1:
|
@@ -198,125 +198,47 @@ def link_button_with_emoji(url, title, emoji_summary):
|
|
198 |
random_emoji = random.choice(emojis)
|
199 |
st.markdown(f"[{random_emoji} {emoji_summary} - {title}]({url})")
|
200 |
|
201 |
-
#
|
202 |
-
|
203 |
-
"
|
204 |
-
"
|
205 |
-
"
|
206 |
-
"
|
207 |
-
"
|
208 |
-
"
|
209 |
-
"
|
210 |
-
"
|
211 |
-
"Right Hand": "π€²", "Chest": "π",
|
212 |
-
"Abdomen": "π", "Pelvis": "π©²",
|
213 |
-
"Left Hip": "π¦΅", "Right Hip": "π¦΅",
|
214 |
-
"Left Thigh": "π¦΅", "Right Thigh": "π¦΅",
|
215 |
-
"Left Knee": "π¦΅", "Right Knee": "π¦΅",
|
216 |
-
"Left Shin": "π¦΅", "Right Shin": "π¦΅"
|
217 |
}
|
218 |
-
|
219 |
-
|
220 |
-
"
|
221 |
-
"
|
222 |
-
"
|
223 |
-
"
|
224 |
-
"
|
225 |
-
"
|
226 |
-
"
|
227 |
-
"
|
228 |
-
"Left Shoulder": "πͺ (Arm Movement and Strength - Left)",
|
229 |
-
"Right Shoulder": "πͺ (Arm Movement and Strength - Right)",
|
230 |
-
"Left Upper Arm": "πͺ (Support and Lifting - Left Upper)",
|
231 |
-
"Right Upper Arm": "πͺ (Support and Lifting - Right Upper)",
|
232 |
-
"Left Elbow": "πͺ (Arm Bending and Flexing - Left)",
|
233 |
-
"Right Elbow": "πͺ (Arm Bending and Flexing - Right)",
|
234 |
-
"Left Forearm": "πͺ (Wrist and Hand Movement - Left)",
|
235 |
-
"Right Forearm": "πͺ (Wrist and Hand Movement - Right)",
|
236 |
-
"Left Wrist": "β (Hand Articulation and Rotation - Left)",
|
237 |
-
"Right Wrist": "β (Hand Articulation and Rotation - Right)",
|
238 |
-
"Left Hand": "π€² (Grasping and Touch - Left)",
|
239 |
-
"Right Hand": "π€² (Grasping and Touch - Right)",
|
240 |
-
"Chest": "π (Protection of Heart and Lungs)",
|
241 |
-
"Abdomen": "π (Digestive Organs and Processing)",
|
242 |
-
"Pelvis": "π©² (Support for Lower Limbs and Organs)",
|
243 |
-
"Left Hip": "𦡠(Support and Movement - Left Hip)",
|
244 |
-
"Right Hip": "𦡠(Support and Movement - Right Hip)",
|
245 |
-
"Left Thigh": "𦡠(Support and Movement - Left Thigh)",
|
246 |
-
"Right Thigh": "𦡠(Support and Movement - Right Thigh)",
|
247 |
-
"Left Knee": "𦡠(Leg Bending and Flexing - Left)",
|
248 |
-
"Right Knee": "𦡠(Leg Bending and Flexing - Right)",
|
249 |
-
"Left Shin": "𦡠(Lower Leg Support - Left)",
|
250 |
-
"Right Shin": "𦡠(Lower Leg Support - Right)",
|
251 |
-
"Left Foot": "π¦Ά (Support, Balance, and Locomotion - Left)",
|
252 |
-
"Right Foot": "π¦Ά (Support, Balance, and Locomotion - Right)"
|
253 |
}
|
254 |
|
255 |
-
# Function to display the homunculus parts with expanders and chat buttons
|
256 |
-
def display_homunculus_parts():
|
257 |
-
st.title("Homunculus Model")
|
258 |
-
|
259 |
-
with st.expander(f"Head ({homunculus_parts_extended['Head']})", expanded=False):
|
260 |
-
head_parts = ["Left Eye", "Right Eye", "Left Eyebrow", "Right Eyebrow", "Nose", "Mouth"]
|
261 |
-
for part in head_parts:
|
262 |
-
# Extracting the function/description from the extended dictionary
|
263 |
-
part_description = homunculus_parts_extended[part].split('(')[1].rstrip(')')
|
264 |
-
prompt = f"Learn about the key features and functions of the {part} - {part_description}"
|
265 |
-
if st.button(f"Explore {part}", key=part):
|
266 |
-
response = chat_with_model(prompt, part)
|
267 |
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
"Limbic System": "β€οΈ - Supports functions including emotion, behavior, motivation, long-term memory, and olfaction.",
|
272 |
-
"Brainstem": "π± - Controls basic body functions like breathing, swallowing, heart rate, blood pressure, and consciousness.",
|
273 |
-
"Cerebellum": "π§© - Coordinates voluntary movements like posture, balance, and speech, resulting in smooth muscular activity.",
|
274 |
-
"Thalamus": "π - Channels sensory and motor signals to the cerebral cortex, and regulates consciousness and sleep.",
|
275 |
-
"Hypothalamus": "π‘οΈ - Controls body temperature, hunger, thirst, fatigue, and circadian cycles.",
|
276 |
-
"Hippocampus": "π - Essential for the formation of new memories and associated with learning and emotions.",
|
277 |
-
"Frontal Lobe": "π‘ - Associated with decision making, problem solving, and planning.",
|
278 |
-
"Parietal Lobe": "π€ - Processes sensory information it receives from the outside world, mainly relating to spatial sense and navigation.",
|
279 |
-
"Temporal Lobe": "π - Involved in processing auditory information and is also important for the processing of semantics in both speech and vision.",
|
280 |
-
"Occipital Lobe": "ποΈ - Main center for visual processing."
|
281 |
-
}
|
282 |
-
|
283 |
-
for part, description in brain_parts.items():
|
284 |
-
# Formatting the prompt in markdown style for enhanced learning
|
285 |
-
prompt = f"Create a markdown outline with emojis to explain the {part} and its role in the brain: {description}"
|
286 |
-
if st.button(f"Explore {part} π§ ", key=part):
|
287 |
-
response = chat_with_model(prompt, part)
|
288 |
-
|
289 |
-
# Displaying central body parts
|
290 |
-
central_parts = ["Neck", "Chest", "Abdomen", "Pelvis"]
|
291 |
-
for part in central_parts:
|
292 |
-
with st.expander(f"{part} ({homunculus_parts_extended[part]})", expanded=False):
|
293 |
-
prompt = f"Learn about the key features and functions of the {part} - {homunculus_parts_extended[part].split(' ')[-1]}"
|
294 |
-
if st.button(f"Explore {part} π§£", key=part):
|
295 |
-
response = chat_with_model(prompt, part)
|
296 |
-
|
297 |
-
# Displaying symmetric body parts
|
298 |
-
symmetric_parts = ["Shoulder", "Upper Arm", "Elbow", "Forearm", "Wrist", "Hand", "Hip", "Thigh", "Knee", "Shin", "Foot"]
|
299 |
-
for part in symmetric_parts:
|
300 |
-
col1, col2 = st.columns(2)
|
301 |
-
with col1:
|
302 |
-
with st.expander(f"Left {part} ({homunculus_parts_extended[f'Left {part}']})", expanded=False):
|
303 |
-
prompt = f"Learn about the key features and functions of the Left {part} - {homunculus_parts_extended[f'Left {part}'].split(' ')[-1]}"
|
304 |
-
if st.button(f"Explore Left {part} πͺ", key=f"Left {part}"):
|
305 |
-
response = chat_with_model(prompt, f"Left {part}")
|
306 |
-
with col2:
|
307 |
-
with st.expander(f"Right {part} ({homunculus_parts_extended[f'Right {part}']})", expanded=False):
|
308 |
-
prompt = f"Learn about the key features and functions of the Right {part} - {homunculus_parts_extended[f'Right {part}'].split(' ')[-1]}"
|
309 |
-
if st.button(f"Explore Right {part} πͺ", key=f"Right {part}"):
|
310 |
-
response = chat_with_model(prompt, f"Right {part}")
|
311 |
|
|
|
|
|
|
|
|
|
|
|
312 |
|
313 |
# Define function to add paper buttons and links
|
314 |
def add_paper_buttons_and_links():
|
315 |
|
316 |
-
#
|
317 |
-
page = st.sidebar.radio("Choose a page:", ["
|
318 |
-
if page == "
|
319 |
-
|
320 |
|
321 |
col1, col2, col3, col4 = st.columns(4)
|
322 |
|
|
|
37 |
|
38 |
|
39 |
# page config and sidebar declares up front allow all other functions to see global class variables
|
40 |
+
st.set_page_config(page_title="Python AI Pair Programmer", layout="wide")
|
41 |
should_save = st.sidebar.checkbox("πΎ Save", value=True)
|
42 |
col1, col2, col3, col4 = st.columns(4)
|
43 |
with col1:
|
|
|
198 |
random_emoji = random.choice(emojis)
|
199 |
st.markdown(f"[{random_emoji} {emoji_summary} - {title}]({url})")
|
200 |
|
201 |
+
# Python parts and their corresponding emojis
|
202 |
+
python_parts = {
|
203 |
+
"Data Types": "π",
|
204 |
+
"Control Structures": "π",
|
205 |
+
"Functions": "π§",
|
206 |
+
"Classes": "ποΈ",
|
207 |
+
"Modules": "π¦",
|
208 |
+
"File Handling": "π",
|
209 |
+
"Exceptions": "β οΈ",
|
210 |
+
"Libraries": "π"
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
}
|
212 |
+
|
213 |
+
python_parts_extended = {
|
214 |
+
"Data Types": "π (Numbers, Strings, Lists, Tuples, Sets, Dictionaries)",
|
215 |
+
"Control Structures": "π (If, Elif, Else, Loops, Break, Continue)",
|
216 |
+
"Functions": "π§ (Defining, Calling, Parameters, Return Values)",
|
217 |
+
"Classes": "ποΈ (Creating, Inheritance, Methods, Properties)",
|
218 |
+
"Modules": "π¦ (Importing, Creating, Exploring)",
|
219 |
+
"File Handling": "π (Open, Read, Write, Close)",
|
220 |
+
"Exceptions": "β οΈ (Try, Except, Finally, Raising)",
|
221 |
+
"Libraries": "π (Numpy, Pandas, Matplotlib, TensorFlow, Requests)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
}
|
223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
|
225 |
+
# Function to display Python concepts with expanders and chat buttons
|
226 |
+
def display_python_parts():
|
227 |
+
st.title("Python Pair Programmer")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
+
for part in python_parts.keys():
|
230 |
+
with st.expander(f"{part} ({python_parts_extended[part]})", expanded=False):
|
231 |
+
prompt = f"Learn about {python_parts_extended[part]}"
|
232 |
+
if st.button(f"Explore {part}", key=part):
|
233 |
+
response = chat_with_model(prompt, part)
|
234 |
|
235 |
# Define function to add paper buttons and links
|
236 |
def add_paper_buttons_and_links():
|
237 |
|
238 |
+
# Python Pair Programmer
|
239 |
+
page = st.sidebar.radio("Choose a page:", ["Python Pair Programmer"])
|
240 |
+
if page == "Python Pair Programmer":
|
241 |
+
display_python_parts()
|
242 |
|
243 |
col1, col2, col3, col4 = st.columns(4)
|
244 |
|