c4r-sty commited on
Commit
853236c
·
verified ·
1 Parent(s): 6eed5fe

updated chatbot

Browse files
Files changed (1) hide show
  1. app.py +29 -4
app.py CHANGED
@@ -1,9 +1,34 @@
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import random
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- def chance(message, history):
5
- response_options = ["yes", "no", "maybe", "potentially", "your future is blurred"]
6
- return random.choice(response_options)
 
 
 
 
7
 
8
- chatbot = gr.ChatInterface(chance, title = "Magic 8-Ball Chatbot")
9
  chatbot.launch()
 
1
+ # import gradio as gr
2
+ # import random
3
+
4
+ # def chance(message, history):
5
+ # response_options = ["yes", "no", "maybe", "potentially", "your future is blurred"]
6
+ # return random.choice(response_options)
7
+
8
+ # chatbot = gr.ChatInterface(chance, title = "Magic 8-Ball Chatbot")
9
+ # chatbot.launch()
10
+
11
  import gradio as gr
12
  import random
13
+ from huggingface_hub import InferenceClient
14
+
15
+ client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
16
+
17
+ def respond(message, history):
18
+ messages = [{"role": "system", "content": "You are a friendly chatbot."}]
19
+
20
+ if history:
21
+ messages.extend(history)
22
+
23
+ messages.append({"role": "user", "content": message})
24
 
25
+ response = client.chat_completion (
26
+ messages,
27
+ max_tokens = 100
28
+ )
29
+
30
+ return random.choice[0].message.content.strip()
31
+
32
 
33
+ chatbot = gr.ChatInterface(respond)
34
  chatbot.launch()