Bea4uty commited on
Commit
bb9ca0c
·
verified ·
1 Parent(s): f6cb0e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -1,9 +1,22 @@
1
- import gradio as gr
2
  import random
 
 
 
 
3
 
4
  def random_response(message,history):
5
- response_options = ["yes", "no", "maybe", "try again later.", "most definitely.", "definitely no.", "you choose your own destiny."]
6
- return random.choice(response_options)
 
 
 
 
 
 
 
 
 
 
7
 
8
 
9
  chatbot = gr.ChatInterface(random_response, title = "Magic 8 Ball Chatbot")
 
 
1
  import random
2
+ import gradio as gr
3
+ from huggingface_hub import IntferenceClient
4
+
5
+ client = IntferenceClient("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.extend(history)
12
+
13
+ messages.append({"role":"user", "content": messages})
14
+
15
+ response = client.chat_completion(
16
+ messages,
17
+ max_tokens=100
18
+ )
19
+ return response.choices[0].message.content.strip()
20
 
21
 
22
  chatbot = gr.ChatInterface(random_response, title = "Magic 8 Ball Chatbot")