kaitwithkwk commited on
Commit
a3b4cc3
·
verified ·
1 Parent(s): 6bc92f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -1,10 +1,20 @@
1
  import gradio as gr
2
- import random
 
 
3
 
4
  def respond(message, history):
5
- responses = ["Yes", "No"]
6
- print(history)
7
- return random.choice(responses)
 
 
 
 
 
 
 
 
8
 
9
  chatbot = gr.ChatInterface(respond, type="messages")
10
 
 
1
  import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
+
4
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
5
 
6
  def respond(message, history):
7
+ messages = []
8
+
9
+ if history:
10
+ messages.extend(history)
11
+
12
+ messages.append({"role": "user", "content": message})
13
+
14
+ response = client.chat_completion(messages)
15
+
16
+ return response['choices'][0]['message']['content'].strip()
17
+
18
 
19
  chatbot = gr.ChatInterface(respond, type="messages")
20