awacke1 commited on
Commit
f1346e4
Β·
1 Parent(s): dc74f0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -111
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="Homunculus - The Human Body Reasoner", layout="wide")
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
- # Homunculus parts and their corresponding emojis
202
- homunculus_parts = {
203
- "Head": "🧠", "Brain": "🧠", "Left Eye": "πŸ‘οΈ", "Right Eye": "πŸ‘οΈ",
204
- "Left Eyebrow": "🀨", "Right Eyebrow": "🀨", "Nose": "πŸ‘ƒ",
205
- "Mouth": "πŸ‘„", "Neck": "🧣", "Left Shoulder": "πŸ’ͺ",
206
- "Right Shoulder": "πŸ’ͺ", "Left Upper Arm": "πŸ’ͺ",
207
- "Right Upper Arm": "πŸ’ͺ", "Left Elbow": "πŸ’ͺ",
208
- "Right Elbow": "πŸ’ͺ", "Left Forearm": "πŸ’ͺ",
209
- "Right Forearm": "πŸ’ͺ", "Left Wrist": "✊",
210
- "Right Wrist": "✊", "Left Hand": "🀲",
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
- homunculus_parts_extended = {
219
- "Head": "🧠 (Center of Thought and Control)",
220
- "Brain": "🧠 (Organ of Intelligence and Processing)",
221
- "Left Eye": "πŸ‘οΈ (Vision and Perception - Left)",
222
- "Right Eye": "πŸ‘οΈ (Vision and Perception - Right)",
223
- "Left Eyebrow": "🀨 (Facial Expression - Left Eyebrow)",
224
- "Right Eyebrow": "🀨 (Facial Expression - Right Eyebrow)",
225
- "Nose": "πŸ‘ƒ (Smell and Breathing)",
226
- "Mouth": "πŸ‘„ (Speech and Eating)",
227
- "Neck": "🧣 (Support and Movement of Head)",
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
- with st.expander(f"Brain ({homunculus_parts['Brain']})", expanded=False):
269
- brain_parts = {
270
- "Neocortex": "πŸŒ€ - Involved in higher-order brain functions such as sensory perception, cognition, and spatial reasoning.",
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
- # Homunculus
317
- page = st.sidebar.radio("Choose a page:", ["Detailed Homunculus Model"])
318
- if page == "Detailed Homunculus Model":
319
- display_homunculus_parts()
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