sharvanid commited on
Commit
e35ed1b
·
verified ·
1 Parent(s): 0c75f77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -2
app.py CHANGED
@@ -1,7 +1,30 @@
 
 
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
+
13
+ messages = [
14
+ {"role":"system",
15
+ "content":"You are a friendly chatbot!"
16
+ }
17
+ ]
18
+
19
+ if history:
20
+ messages.extend(history)
21
+
22
+ response = client.chat_completion(
23
+ messages, max_tokens = 100
24
+ )
25
+
26
+
27
+ return response['choices'][0]['message']['content'].strip()
28
+
29
  chatbot = gr.ChatInterface(respond, type="messages")
30
  chatbot.launch()