Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,6 +31,19 @@ def answer_question(text, question):
|
|
| 31 |
except Exception as e:
|
| 32 |
return f"Error in question answering: {str(e)}"
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
# Gradio Blocks for advanced UI
|
| 35 |
with gr.Blocks(
|
| 36 |
theme=gr.themes.Soft(primary_hue="teal", secondary_hue="pink"), # Use a vibrant theme
|
|
@@ -93,19 +106,6 @@ with gr.Blocks(
|
|
| 93 |
label="📚 **Examples**"
|
| 94 |
)
|
| 95 |
|
| 96 |
-
# Function to handle task selection
|
| 97 |
-
def study_assistant(text, task, question=None):
|
| 98 |
-
if task == "Summarize":
|
| 99 |
-
return summarize(text)
|
| 100 |
-
elif task == "Generate Flashcards":
|
| 101 |
-
return generate_flashcards(text)
|
| 102 |
-
elif task == "Answer Question":
|
| 103 |
-
if not question:
|
| 104 |
-
return "Please enter a question."
|
| 105 |
-
return answer_question(text, question)
|
| 106 |
-
else:
|
| 107 |
-
return "Invalid task selected."
|
| 108 |
-
|
| 109 |
# Link button to function
|
| 110 |
submit_button.click(
|
| 111 |
study_assistant,
|
|
|
|
| 31 |
except Exception as e:
|
| 32 |
return f"Error in question answering: {str(e)}"
|
| 33 |
|
| 34 |
+
# Function to handle task selection
|
| 35 |
+
def study_assistant(text, task, question=None):
|
| 36 |
+
if task == "Summarize":
|
| 37 |
+
return summarize(text)
|
| 38 |
+
elif task == "Generate Flashcards":
|
| 39 |
+
return generate_flashcards(text)
|
| 40 |
+
elif task == "Answer Question":
|
| 41 |
+
if not question:
|
| 42 |
+
return "Please enter a question."
|
| 43 |
+
return answer_question(text, question)
|
| 44 |
+
else:
|
| 45 |
+
return "Invalid task selected."
|
| 46 |
+
|
| 47 |
# Gradio Blocks for advanced UI
|
| 48 |
with gr.Blocks(
|
| 49 |
theme=gr.themes.Soft(primary_hue="teal", secondary_hue="pink"), # Use a vibrant theme
|
|
|
|
| 106 |
label="📚 **Examples**"
|
| 107 |
)
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
# Link button to function
|
| 110 |
submit_button.click(
|
| 111 |
study_assistant,
|