ishrat5e commited on
Commit
ccc1882
·
verified ·
1 Parent(s): 9c92ea3

Updates to include responses

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -1,11 +1,22 @@
1
  import gradio as gr
2
  import random
 
 
 
3
 
4
  def random_response(message, history):
5
- response_options = ["Points to a big yes!", "Error 404: Answer not found", "Not close", "Ask again", "You have got this!", "Better to pivot your plans", "The stars align for you", "Look forward to it!"]
6
- return random.choice(response_options)
 
 
 
 
 
 
 
7
 
8
- chatbot = gr.ChatInterface(random_response, title = "Magic 8 Ball 🔮")
9
 
 
10
  chatbot.launch()
11
 
 
1
  import gradio as gr
2
  import random
3
+ from huggingface_hub import InferenceClient
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
+ if history:
10
+ messages.extend(history)
11
+ messages.appened({"role": "user", "content": message})
12
+
13
+ response = client.chat_completion(
14
+ messages,
15
+ max_tokens = 100
16
+ )
17
 
18
+ return response.choice[0].message.content.strip()
19
 
20
+ chatbot = gr.ChatInterface(respond)
21
  chatbot.launch()
22