abi-codes commited on
Commit
88563c7
·
verified ·
1 Parent(s): 95a9cac

Update app.py

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