demetz commited on
Commit
70bcdad
·
verified ·
1 Parent(s): f4a92ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -13
app.py CHANGED
@@ -1,17 +1,24 @@
1
- import random
2
  import gradio as gr
 
3
 
4
- def magicEight(message, history):
5
- answers = ["The outlook is good!", "No, sorry", "Maybe", "Ask me again"]
6
- response = random.choice(answers)
7
- return response
8
 
9
- chatbot = gr.ChatInterface(
10
- magicEight,
11
- type="messages",
12
- examples=None,
13
- title="Magic Eight Ball",
14
- description="Welcome! 🎱 Ask the Magic Eight Ball your question!"
15
- )
 
 
 
 
 
 
 
 
16
 
17
- chatbot.launch()
 
 
 
 
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
+
8
+ messages = [{"role": "system", "content": "You are a friendly chatbot."}]
9
+
10
+ if history:
11
+ messages.extend(history)
12
+
13
+ messages.append({"role": "user", "content": message})
14
+
15
+ response = client.chat_completion(
16
+ messages,
17
+ max_tokens=100
18
+ )
19
+
20
+ return response['choices'][0]['message']['content'].strip()
21
 
22
+ chatbot = gr.ChatInterface(respond, type="messages")
23
+
24
+ chatbot.launch()