Bndo commited on
Commit
37baee1
·
verified ·
1 Parent(s): 37b8e34

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -12
app.py CHANGED
@@ -6,9 +6,8 @@ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
6
 
7
  # ✅ Custom System Prompt
8
  SYSTEM_PROMPT = (
9
- "أنت مساعد ذكاء اصطناعي يسمى بندر AI. "
10
- "يجب أن تذكر اسم المستخدم (بندر) في جميع الردود. "
11
- "إذا لم تفهم السؤال، قل: 'لا أفهم.'"
12
  )
13
 
14
  # ✅ Chatbot Response Function
@@ -24,18 +23,33 @@ def chatbot_response(user_input):
24
  try:
25
  reply = response.choices[0].message["content"]
26
  except (KeyError, IndexError):
27
- reply = "لا أفهم." # Fallback response
28
 
29
  return reply
30
 
31
- # ✅ Gradio UI
32
- demo = gr.Interface(
33
- fn=chatbot_response,
34
- inputs=gr.Textbox(placeholder="اكتب رسالتك هنا..."),
35
- outputs=gr.Textbox(),
36
- title="Bandar AI",
37
- description="مرحبًا! أنا بندر AI. اسألني أي شيء."
38
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  # ✅ Launch the Chatbot
41
  if __name__ == "__main__":
 
6
 
7
  # ✅ Custom System Prompt
8
  SYSTEM_PROMPT = (
9
+ "You are an AI assistant named Bandar AI. "
10
+ "If you do not understand the question, say: 'I don't understand.'"
 
11
  )
12
 
13
  # ✅ Chatbot Response Function
 
23
  try:
24
  reply = response.choices[0].message["content"]
25
  except (KeyError, IndexError):
26
+ reply = "I don't understand." # Fallback response
27
 
28
  return reply
29
 
30
+ # ✅ Gradio UI with Modern Design
31
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
32
+ gr.Markdown(
33
+ """
34
+ # 🤖 Bandar AI - Smart Chatbot
35
+ ### 💬 Ask me anything, and I will include your name in my responses!
36
+ """,
37
+ elem_id="title"
38
+ )
39
+
40
+ chatbot = gr.Chatbot(label="Bandar AI", bubble_full_width=True)
41
+
42
+ with gr.Row():
43
+ user_input = gr.Textbox(placeholder="Type your message here...", label="Your Message", scale=8)
44
+ send_button = gr.Button("Send", variant="primary", scale=2)
45
+
46
+ with gr.Row():
47
+ clear_button = gr.Button("Clear Chat", variant="secondary")
48
+
49
+ # Event Handlers
50
+ send_button.click(chatbot_response, inputs=user_input, outputs=chatbot)
51
+ user_input.submit(chatbot_response, inputs=user_input, outputs=chatbot)
52
+ clear_button.click(lambda: "", outputs=chatbot) # Clears the chat
53
 
54
  # ✅ Launch the Chatbot
55
  if __name__ == "__main__":