kaitwithkwk commited on
Commit
ed07cc6
·
verified ·
1 Parent(s): daf3c58

Create app.py

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