KittyMona commited on
Commit
9a96326
Β·
verified Β·
1 Parent(s): 1b6146f

Update app.py

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