ishaandtotoro commited on
Commit
aade108
·
verified ·
1 Parent(s): 9abae11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -2
app.py CHANGED
@@ -1,7 +1,32 @@
 
 
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
+
7
+ # Making requests to the model to generate responses:
8
+ client = InferenceClient('HuggingFaceH4/zephyr-7b-beta')
9
+
10
+
11
  def respond(message, history):
12
+ #responses = ["Yes", "No"]
13
+ #return random.choice(responses)
14
+
15
+
16
+ messages = [{'role':'system', 'content': 'You are a mean chatbot'}]
17
+
18
+
19
+
20
+ if history:
21
+ messages.extend(history)
22
+
23
+
24
+
25
+ response = client.chat_completion(messages, max_tokens=100)
26
+
27
+ return response['choice'][0]['message']['content'].strip()
28
+
29
+
30
+
31
  chatbot = gr.ChatInterface(respond, type="messages")
32
  chatbot.launch()