codersoul commited on
Commit
ced5300
·
verified ·
1 Parent(s): 044b701

Updates the chatbot responses

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -1,9 +1,23 @@
1
  import gradio as gr
2
  import random
 
 
 
 
3
  def random_response(message, history):
4
- response_options = ["yes", "no", "I need more cosmic energy to answer.", "Very doubtful.", "Signs point to yes."]
5
- return random.choice(response_options)
 
 
 
 
 
 
 
 
 
 
6
 
7
- chatbot = gr.ChatInterface(random_response, title="Magic 🎱 Chatbot")
8
 
9
  chatbot.launch()
 
1
  import gradio as gr
2
  import random
3
+ from huggingface_hug import Inference_Client
4
+
5
+ client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
6
+
7
  def random_response(message, history):
8
+ messages = [{"role": "system", "content": "You are a friendly chatbot"}]
9
+
10
+ if history:
11
+ messages.extent(history)
12
+ messages.append({"role": "user", "content": message})
13
+
14
+ response = client.chat_completion(
15
+ messages,
16
+ max_tokens = 100
17
+ )
18
+ #response_options = ["yes", "no", "I need more cosmic energy to answer.", "Very doubtful.", "Signs point to yes."]
19
+ return random.choice[0].message.content.strip()
20
 
21
+ chatbot = gr.ChatInterface(respond, title="Chatbot")
22
 
23
  chatbot.launch()