shukdevdatta123 commited on
Commit
85c63d5
·
verified ·
1 Parent(s): bcd0ef7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +88 -1
app.py CHANGED
@@ -83,7 +83,11 @@ if openai_api_key:
83
  "Code Generator",
84
  "AI Chatbot Tutor",
85
  "AI Study Notes & Summaries",
86
- "Code Bug Fixer"
 
 
 
 
87
  ))
88
 
89
  if mode == "Course Query Assistant":
@@ -274,3 +278,86 @@ if openai_api_key:
274
  )
275
  else:
276
  st.error("Please enter some buggy code to fix.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  "Code Generator",
84
  "AI Chatbot Tutor",
85
  "AI Study Notes & Summaries",
86
+ "Code Bug Fixer",
87
+ "Mathematics Assistant", # Added option for Math
88
+ "Biology Assistant", # Added option for Biology
89
+ "Chemistry Assistant", # Added option for Chemistry
90
+ "Physics Assistant" # Added option for Physics
91
  ))
92
 
93
  if mode == "Course Query Assistant":
 
278
  )
279
  else:
280
  st.error("Please enter some buggy code to fix.")
281
+
282
+ elif mode == "Mathematics Assistant":
283
+ st.header("Mathematics Assistant")
284
+
285
+ # Display image/logo in the "Mathematics Assistant" section (optional)
286
+ math_icon = Image.open("math_icon.png") # Ensure the file is in the correct directory
287
+ st.image(math_icon, width=150) # Adjust the size as per preference
288
+
289
+ # User input for math questions
290
+ math_query = st.text_input("Ask a mathematics-related question:")
291
+
292
+ if math_query:
293
+ with st.spinner("Getting answer..."):
294
+ prompt = f"Answer the following math question: {math_query}"
295
+ response = openai.ChatCompletion.create(
296
+ model="gpt-4o-mini",
297
+ messages=[{"role": "user", "content": prompt}]
298
+ )
299
+ answer = response['choices'][0]['message']['content']
300
+ st.write(f"### Answer: {answer}")
301
+
302
+ # **New Section: Biology Assistant**
303
+ elif mode == "Biology Assistant":
304
+ st.header("Biology Assistant")
305
+
306
+ # Display image/logo in the "Biology Assistant" section (optional)
307
+ bio_icon = Image.open("bio_icon.png") # Ensure the file is in the correct directory
308
+ st.image(bio_icon, width=150) # Adjust the size as per preference
309
+
310
+ # User input for biology questions
311
+ bio_query = st.text_input("Ask a biology-related question:")
312
+
313
+ if bio_query:
314
+ with st.spinner("Getting answer..."):
315
+ prompt = f"Answer the following biology question: {bio_query}"
316
+ response = openai.ChatCompletion.create(
317
+ model="gpt-4o-mini",
318
+ messages=[{"role": "user", "content": prompt}]
319
+ )
320
+ answer = response['choices'][0]['message']['content']
321
+ st.write(f"### Answer: {answer}")
322
+
323
+ # **New Section: Chemistry Assistant**
324
+ elif mode == "Chemistry Assistant":
325
+ st.header("Chemistry Assistant")
326
+
327
+ # Display image/logo in the "Chemistry Assistant" section (optional)
328
+ chem_icon = Image.open("chem_icon.png") # Ensure the file is in the correct directory
329
+ st.image(chem_icon, width=150) # Adjust the size as per preference
330
+
331
+ # User input for chemistry questions
332
+ chem_query = st.text_input("Ask a chemistry-related question:")
333
+
334
+ if chem_query:
335
+ with st.spinner("Getting answer..."):
336
+ prompt = f"Answer the following chemistry question: {chem_query}"
337
+ response = openai.ChatCompletion.create(
338
+ model="gpt-4o-mini",
339
+ messages=[{"role": "user", "content": prompt}]
340
+ )
341
+ answer = response['choices'][0]['message']['content']
342
+ st.write(f"### Answer: {answer}")
343
+
344
+ # **New Section: Physics Assistant**
345
+ elif mode == "Physics Assistant":
346
+ st.header("Physics Assistant")
347
+
348
+ # Display image/logo in the "Physics Assistant" section (optional)
349
+ phys_icon = Image.open("phys_icon.png") # Ensure the file is in the correct directory
350
+ st.image(phys_icon, width=150) # Adjust the size as per preference
351
+
352
+ # User input for physics questions
353
+ phys_query = st.text_input("Ask a physics-related question:")
354
+
355
+ if phys_query:
356
+ with st.spinner("Getting answer..."):
357
+ prompt = f"Answer the following physics question: {phys_query}"
358
+ response = openai.ChatCompletion.create(
359
+ model="gpt-4o-mini",
360
+ messages=[{"role": "user", "content": prompt}]
361
+ )
362
+ answer = response['choices'][0]['message']['content']
363
+ st.write(f"### Answer: {answer}")