Sheepbon commited on
Commit
bf135e2
·
verified ·
1 Parent(s): 2540286

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import InferenceClient
2
+
3
+ import gradio as gr
4
+ import random
5
+
6
+ with gr.Blocks() as chatbot:
7
+ gr.Image(
8
+ value="orange-banner.png",
9
+ show_label=False,
10
+ show_share_button = False,
11
+ show_download_button = False)
12
+ gr.ChatInterface(respond, type="messages")
13
+
14
+ client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")
15
+
16
+ def respond(message, history):
17
+ messages = [{"role":"system", "content":"You are a friendly chatbot! :)"}]
18
+
19
+ if history:
20
+ messages.extend(history)
21
+
22
+ messages.append({"role":"user", "content":message})
23
+
24
+ response = client.chat_completion(messages, max_tokens = 100, temperature = 1.3, top_p = 0.3) #temp & top_p control random
25
+
26
+ print(response)
27
+
28
+ return response["choices"][0]["message"]["content"].strip()
29
+
30
+ chatbot = gr.ChatInterface(respond, type="messages")
31
+
32
+ chatbot.launch()