adrinavaz commited on
Commit
6bc0bee
·
verified ·
1 Parent(s): db542d5
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -1,23 +1,21 @@
1
- import gradio as gr
2
-
3
- import random
4
-
5
  from huggingface_hub import InferenceClient
 
6
  client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
7
- def respond(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
- HF_TOKEN=100
18
  )
 
19
  return response.choices[0].message.content.strip()
20
 
21
  chatbot = gr.ChatInterface(respond)
22
-
23
  chatbot.launch()
 
1
+ import gradio as gr
 
 
 
2
  from huggingface_hub import InferenceClient
3
+
4
  client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
 
 
5
 
6
+ def respond(message, history):
7
+ messages = [
8
+ {"role": "system", "content": "You are a friendly chatbot"}
9
+ ]
10
 
11
+ messages.append({"role": "user", "content": message})
12
 
13
+ response = client.chat_completion(
14
+ messages=messages,
15
+ max_tokens=100
16
  )
17
+
18
  return response.choices[0].message.content.strip()
19
 
20
  chatbot = gr.ChatInterface(respond)
 
21
  chatbot.launch()