Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,7 +38,7 @@ def save_memory(memory):
|
|
| 38 |
memory = load_memory()
|
| 39 |
|
| 40 |
# 💬 Chat function
|
| 41 |
-
def chat_with_model(message, history, context
|
| 42 |
if not isinstance(history, list):
|
| 43 |
history = []
|
| 44 |
|
|
@@ -50,11 +50,6 @@ def chat_with_model(message, history, context, file_input=None):
|
|
| 50 |
save_memory(history)
|
| 51 |
return history, history
|
| 52 |
|
| 53 |
-
# 📂 If file is uploaded
|
| 54 |
-
if file_input:
|
| 55 |
-
file_name = file_input.name
|
| 56 |
-
message += f"\n\n📎 (User uploaded a file named '{file_name}')"
|
| 57 |
-
|
| 58 |
# 🧠 Build conversation
|
| 59 |
conversation = [
|
| 60 |
{"role": "system", "content": (
|
|
@@ -164,14 +159,13 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="violet")) as iface:
|
|
| 164 |
latex_delimiters=[{"left": "$$", "right": "$$", "display": True}, {"left": "\\[", "right": "\\]", "display": True}]
|
| 165 |
)
|
| 166 |
msg = gr.Textbox(label="Ask EduAI:")
|
| 167 |
-
file_input = gr.File(label="📂 Upload a study file (PDF, DOCX, or image):")
|
| 168 |
send = gr.Button("Send ✈️")
|
| 169 |
|
| 170 |
# 🪄 Event handlers
|
| 171 |
subj.change(update_context, inputs=subj, outputs=context_display)
|
| 172 |
planner.change(update_context, inputs=planner, outputs=context_display)
|
| 173 |
lang.change(update_context, inputs=lang, outputs=context_display)
|
| 174 |
-
send.click(chat_with_model, inputs=[msg, chatbot, context_display
|
| 175 |
clear_btn.click(clear_memory, outputs=[chatbot, context_display])
|
| 176 |
|
| 177 |
-
iface.launch()
|
|
|
|
| 38 |
memory = load_memory()
|
| 39 |
|
| 40 |
# 💬 Chat function
|
| 41 |
+
def chat_with_model(message, history, context):
|
| 42 |
if not isinstance(history, list):
|
| 43 |
history = []
|
| 44 |
|
|
|
|
| 50 |
save_memory(history)
|
| 51 |
return history, history
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
# 🧠 Build conversation
|
| 54 |
conversation = [
|
| 55 |
{"role": "system", "content": (
|
|
|
|
| 159 |
latex_delimiters=[{"left": "$$", "right": "$$", "display": True}, {"left": "\\[", "right": "\\]", "display": True}]
|
| 160 |
)
|
| 161 |
msg = gr.Textbox(label="Ask EduAI:")
|
|
|
|
| 162 |
send = gr.Button("Send ✈️")
|
| 163 |
|
| 164 |
# 🪄 Event handlers
|
| 165 |
subj.change(update_context, inputs=subj, outputs=context_display)
|
| 166 |
planner.change(update_context, inputs=planner, outputs=context_display)
|
| 167 |
lang.change(update_context, inputs=lang, outputs=context_display)
|
| 168 |
+
send.click(chat_with_model, inputs=[msg, chatbot, context_display], outputs=[chatbot, chatbot])
|
| 169 |
clear_btn.click(clear_memory, outputs=[chatbot, context_display])
|
| 170 |
|
| 171 |
+
iface.launch()
|