ssundus commited on
Commit
d324bcf
·
verified ·
1 Parent(s): fae3148

Update app.py

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