Skyhighque commited on
Commit
f672190
·
verified ·
1 Parent(s): b98a4ef

Updated Chatbot for HF

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -1,10 +1,22 @@
1
  import gradio as gr
2
- import random
3
 
4
- def magic_eight_ball(message, history):
5
- response_options = ["Signs point to yes", "Outlook not so good", "It is certain", "Ask again later", "Don't try it"]
6
- return random.choice(response_options)
7
 
8
- chatbot = gr.ChatInterface(magic_eight_ball, title = "Magic 8 Ball")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  chatbot.launch()
 
1
  import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
 
4
+ client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
 
 
5
 
6
+ def respond(message, history):
7
+ messages = [{"role": "system", "content": "You are a friendly chatbot."}]
8
+
9
+ if history:
10
+ messages.extend(history)
11
+
12
+ messages.append({"role": "user", "content": message})
13
+
14
+ response = client.chat_completion(
15
+ messages,
16
+ max_tokens=100
17
+ )
18
+ return response.choices[0].message.content.strip()
19
+
20
+ chatbot = gr.ChatInterface(respond, title = "Magic 8 Ball")
21
 
22
  chatbot.launch()