kaitwithkwk commited on
Commit
46c5fdb
·
verified ·
1 Parent(s): 1972ae4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
+
4
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
5
+
6
+ def respond(message, history):
7
+ messages = [{"role": "system", "content": "You are a friendly chatbot."}]
8
+
9
+ if history:
10
+ messages.extend(history)
11
+
12
+ messages.append({"role": "user", "content": message})
13
+
14
+ response = client.chat_completion(
15
+ messages,
16
+ max_tokens=100
17
+ )
18
+
19
+ return response['choices'][0]['message']['content'].strip()
20
+
21
+ chatbot = gr.ChatInterface(respond, type="messages")
22
+
23
+ chatbot.launch()