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