Yuvalamitay commited on
Commit
6d97c78
·
verified ·
1 Parent(s): 4b62396

Update app.py

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