Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -68,3 +68,40 @@ with gr.Blocks() as demo:
|
|
| 68 |
|
| 69 |
if __name__ == "__main__":
|
| 70 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
if __name__ == "__main__":
|
| 70 |
demo.launch()
|
| 71 |
+
import gradio as gr
|
| 72 |
+
|
| 73 |
+
# Existing study_helper function
|
| 74 |
+
def study_helper(subject, question):
|
| 75 |
+
if subject == "Physics":
|
| 76 |
+
return f"Physics Answer:\n\n{question}\n\n(Explain concept, formula, and example here)"
|
| 77 |
+
elif subject == "Math":
|
| 78 |
+
return f"Math Answer:\n\n{question}\n\n(Step by step solution here)"
|
| 79 |
+
elif subject == "English":
|
| 80 |
+
return f"English Answer:\n\n{question}\n\n(Explanation with examples)"
|
| 81 |
+
else:
|
| 82 |
+
return "Please select a subject"
|
| 83 |
+
|
| 84 |
+
# New function to show image
|
| 85 |
+
def show_image(image_name):
|
| 86 |
+
# Image should be in same folder as app.py or URL link
|
| 87 |
+
return f"Image selected: {image_name}", f"{image_name}"
|
| 88 |
+
|
| 89 |
+
# Interface
|
| 90 |
+
with gr.Blocks() as demo:
|
| 91 |
+
gr.Markdown("## 📘 Study Website with Images")
|
| 92 |
+
|
| 93 |
+
with gr.Tab("Q&A"):
|
| 94 |
+
subject = gr.Dropdown(["Physics", "Math", "English"], label="Select Subject")
|
| 95 |
+
question = gr.Textbox(lines=3, placeholder="Enter your question here")
|
| 96 |
+
answer = gr.Textbox(label="Answer")
|
| 97 |
+
submit_btn = gr.Button("Get Answer")
|
| 98 |
+
submit_btn.click(study_helper, inputs=[subject, question], outputs=answer)
|
| 99 |
+
|
| 100 |
+
with gr.Tab("Images"):
|
| 101 |
+
img_name = gr.Dropdown(["physics.png", "math.png", "english.png"], label="Select Image")
|
| 102 |
+
img_output_text = gr.Textbox(label="Selected Image")
|
| 103 |
+
img_output = gr.Image(label="Image Display")
|
| 104 |
+
img_btn = gr.Button("Show Image")
|
| 105 |
+
img_btn.click(show_image, inputs=img_name, outputs=[img_output_text, img_output])
|
| 106 |
+
|
| 107 |
+
demo.launch()
|