Sope006 commited on
Commit
bed5ef9
·
1 Parent(s): 652e6cb

Update Space

Browse files
Files changed (2) hide show
  1. app.py +40 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+
5
+
6
+ def chatbot_qwen(prompt,history):
7
+ url = "https://qwen-3.p.rapidapi.com/chat/completions"
8
+
9
+ payload = {
10
+ "model": "qwen3-14b",
11
+ "messages": [
12
+ {
13
+ "role": "user",
14
+ "content": prompt
15
+ }
16
+ ]
17
+ }
18
+ headers = {
19
+ "x-rapidapi-key": "3d66bcf268mshb7e2600a51aa227p1c07cajsn59f71d743737",
20
+ "x-rapidapi-host": "qwen-3.p.rapidapi.com",
21
+ "Content-Type": "application/json"
22
+ }
23
+
24
+ response = requests.post(url, json=payload, headers=headers)
25
+ output = response.json()
26
+
27
+ return output['choices'][0]['message']['content']
28
+
29
+ def vote(data: gr.LikeData):
30
+ if data.liked:
31
+ print("You upvoted this response: " + data.value["value"])
32
+ else:
33
+ print("You downvoted this response: " + data.value["value"])
34
+
35
+ with gr.Blocks() as demo:
36
+ chatbot = gr.Chatbot(placeholder="<strong>Qwen Chatbot</strong><br>Ask Me Anything")
37
+ chatbot.like(vote, None, None)
38
+ gr.ChatInterface(fn=chatbot_qwen,chatbot=chatbot)
39
+
40
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ requests