Wfafa commited on
Commit
a6c6255
Β·
verified Β·
1 Parent(s): def0f23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -13
app.py CHANGED
@@ -15,7 +15,7 @@ def search_web(query):
15
  return data["AbstractText"]
16
  elif data.get("RelatedTopics"):
17
  topics = [t.get("Text", "") for t in data["RelatedTopics"] if "Text" in t]
18
- return " ".join(topics[:3]) # just a few results
19
  else:
20
  return "No useful information found."
21
  except Exception as e:
@@ -89,7 +89,6 @@ def chat_with_model(message, history, context):
89
  reply = reply.replace("\\[", "\n\n\\[")
90
  reply = reply.replace("\\]", "\\]\n\n")
91
 
92
- # βœ… Add Markdown + LaTeX support
93
  if "\\" in reply or "log_" in reply or "^" in reply:
94
  reply = f"{reply}"
95
 
@@ -114,9 +113,15 @@ def clear_memory():
114
  os.remove(MEMORY_FILE)
115
  return [], "🧹 Chat memory cleared! Start fresh."
116
 
117
- # 🎨 Gradio Interface
118
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="violet")) as iface:
119
- gr.Markdown("# πŸŽ“ **EduAI β€” Your Smart Study Companion**")
 
 
 
 
 
 
120
 
121
  with gr.Row():
122
  with gr.Column(scale=1, min_width=230):
@@ -144,22 +149,32 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="violet")) as iface:
144
  clear_btn = gr.Button("🧹 Clear Memory")
145
 
146
  with gr.Accordion("πŸ‘©β€πŸŽ“ About", open=False):
147
- gr.Markdown("""
148
- EduAI – developed and fine-tuned by **Wafa Fazly** using a pre-trained AI model,
149
- to help learners understand **Science, ICT, English, and more** β€”
150
- in a simple and friendly way! πŸ’¬
151
- """)
 
 
 
152
 
153
  with gr.Column(scale=4):
154
  context_display = gr.Markdown("πŸ“˜ **You are in General Mode.** Ask EduAI anything about your studies!")
155
  chatbot = gr.Chatbot(
156
- label="EduAI Chat",
157
  height=450,
158
  render_markdown=True,
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)
 
15
  return data["AbstractText"]
16
  elif data.get("RelatedTopics"):
17
  topics = [t.get("Text", "") for t in data["RelatedTopics"] if "Text" in t]
18
+ return " ".join(topics[:3])
19
  else:
20
  return "No useful information found."
21
  except Exception as e:
 
89
  reply = reply.replace("\\[", "\n\n\\[")
90
  reply = reply.replace("\\]", "\\]\n\n")
91
 
 
92
  if "\\" in reply or "log_" in reply or "^" in reply:
93
  reply = f"{reply}"
94
 
 
113
  os.remove(MEMORY_FILE)
114
  return [], "🧹 Chat memory cleared! Start fresh."
115
 
116
+ # 🎨 Gradio Interface (UI Improved)
117
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="violet")) as iface:
118
+ gr.Markdown(
119
+ """
120
+ # πŸŽ“ **EduAI β€” Your Smart Study Companion**
121
+ Welcome to **EduAI**, your friendly study assistant! πŸ’¬
122
+ Get help in **Science, ICT, English, Mathematics**, and more.
123
+ """
124
+ )
125
 
126
  with gr.Row():
127
  with gr.Column(scale=1, min_width=230):
 
149
  clear_btn = gr.Button("🧹 Clear Memory")
150
 
151
  with gr.Accordion("πŸ‘©β€πŸŽ“ About", open=False):
152
+ gr.Markdown(
153
+ """
154
+ EduAI was designed and fine-tuned by **Wafa Fazly**,
155
+ a passionate Sri Lankan student πŸ‘©β€πŸ’»
156
+ to help learners explore **Science, ICT, English, and more** β€”
157
+ in a smart and friendly way! 🌟
158
+ """
159
+ )
160
 
161
  with gr.Column(scale=4):
162
  context_display = gr.Markdown("πŸ“˜ **You are in General Mode.** Ask EduAI anything about your studies!")
163
  chatbot = gr.Chatbot(
164
+ label="πŸ’¬ EduAI Chat Window",
165
  height=450,
166
  render_markdown=True,
167
+ bubble_full_width=False,
168
+ latex_delimiters=[
169
+ {"left": "$$", "right": "$$", "display": True},
170
+ {"left": "\\[", "right": "\\]", "display": True}
171
+ ]
172
+ )
173
+ msg = gr.Textbox(
174
+ label="πŸ’­ Type your question here...",
175
+ placeholder="Ask EduAI anything about your studies..."
176
  )
177
+ send = gr.Button("✨ Send Message")
 
178
 
179
  # πŸͺ„ Event handlers
180
  subj.change(update_context, inputs=subj, outputs=context_display)