Tram-Anh commited on
Commit
ba509f6
·
verified ·
1 Parent(s): a964423

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -1,7 +1,29 @@
 
 
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
+ cliet = 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
+
28
  chatbot = gr.ChatInterface(respond, type="messages")
29
  chatbot.launch()