sarahrobe commited on
Commit
642e27d
·
verified ·
1 Parent(s): 79ba964

Added in InferenceClient

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -1,9 +1,23 @@
 
1
  import gradio as gr
2
  import random
3
 
 
 
4
  def respond(message, history):
5
- answers = ["Maybe", "Absolutely", "Probs Not", "Unlikely", "It is decidedly so", "Signs point to no"]
6
- return random.choice(answers)
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  chatbot = gr.ChatInterface(respond)
9
 
 
1
+ from huggingface_hub import InferenceClient
2
  import gradio as gr
3
  import random
4
 
5
+ client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
6
+
7
  def respond(message, history):
8
+ #answers = ["Maybe", "Absolutely", "Probs Not", "Unlikely", "It is decidedly so", "Signs point to no"]
9
+ messages = [{"role": "system", "content": "You are a friendly chatbot."}]
10
+
11
+ if history:
12
+ messages.extend(history)
13
+
14
+ messages.append({"role": "user", "content": message})
15
+
16
+ response = client.chat_completion(
17
+ messages,
18
+ max_tokens=100
19
+ )
20
+ return response.choices[0].message.content.strip()
21
 
22
  chatbot = gr.ChatInterface(respond)
23