StevenMSAI commited on
Commit
e645da6
·
verified ·
1 Parent(s): ff34e1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -1
app.py CHANGED
@@ -18,6 +18,7 @@ from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
18
 
19
  # -------- Model / bot configuration --------
20
  GEN_MODEL_NAME = "MBZUAI/LaMini-Flan-T5-248M" # CPU-friendly text2text model
 
21
 
22
  DOMAIN_INSTRUCTIONS = (
23
  "You are a concise assistant about cats in ancient Egypt. "
@@ -32,6 +33,10 @@ HELP_TEXT = (
32
  "Type anything else to try the AI fallback."
33
  )
34
 
 
 
 
 
35
  # -------- Output cleanup (remove model-added fluff) --------
36
  DISCLAIMER_PATTERNS = [
37
  r"^\s*(hi|hello|hey)[,!.?\s-]*", # stray greeting
@@ -190,9 +195,28 @@ def reply(message, history):
190
  return apply_tone_prefix(base, bucket, message)
191
 
192
  # -------- UI --------
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  demo = gr.ChatInterface(
194
  fn=reply,
195
- title="😺 Cats of Ancient Egypt Chatbot 😺"
 
196
  )
197
 
198
  if __name__ == "__main__":
 
18
 
19
  # -------- Model / bot configuration --------
20
  GEN_MODEL_NAME = "MBZUAI/LaMini-Flan-T5-248M" # CPU-friendly text2text model
21
+ WELCOME_IMAGE_PATH = "assets/cat.png" # your local image
22
 
23
  DOMAIN_INSTRUCTIONS = (
24
  "You are a concise assistant about cats in ancient Egypt. "
 
33
  "Type anything else to try the AI fallback."
34
  )
35
 
36
+ WELCOME_TEXT = (
37
+ "Hi! I share facts about cats in ancient Egypt.\n\n" + HELP_TEXT
38
+ )
39
+
40
  # -------- Output cleanup (remove model-added fluff) --------
41
  DISCLAIMER_PATTERNS = [
42
  r"^\s*(hi|hello|hey)[,!.?\s-]*", # stray greeting
 
195
  return apply_tone_prefix(base, bucket, message)
196
 
197
  # -------- UI --------
198
+
199
+ # Preload a welcome message that includes your local image + short intro text.
200
+ initial_messages = [
201
+ {
202
+ "role": "assistant",
203
+ "content": [
204
+ {"type": "image", "image": WELCOME_IMAGE_PATH, "alt_text": "Stylized Bastet cat image"},
205
+ {"type": "text", "text": WELCOME_TEXT},
206
+ ],
207
+ }
208
+ ]
209
+
210
+ chatbot_component = gr.Chatbot(
211
+ type="messages", # avoids deprecated tuples format
212
+ value=initial_messages, # show welcome image + text on load
213
+ show_label=False,
214
+ )
215
+
216
  demo = gr.ChatInterface(
217
  fn=reply,
218
+ title="😺 Cats of Ancient Egypt Chatbot 😺",
219
+ chatbot=chatbot_component
220
  )
221
 
222
  if __name__ == "__main__":