mingbaer commited on
Commit
a67e835
·
verified ·
1 Parent(s): 3b24447

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = [{"role": "system", "content": "You are a friendly chatbot."}]
8
+ if history:
9
+ messages.extend(history)
10
+ messages.append({"role": "user", "content": message})
11
+
12
+ response = client.chat_completion(
13
+ messages,
14
+ max_tokens=100
15
+ )
16
+ return response.choices[0].message.content.strip()
17
+
18
+ chatbot = gr.ChatInterface(respond)
19
+
20
+ chatbot.launch()