Maddiew1314 commited on
Commit
a891aca
·
verified ·
1 Parent(s): 0b8bfed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -2
app.py CHANGED
@@ -1,12 +1,31 @@
1
  import gradio as gr
2
  import random
 
3
 
4
- def echo(message, history):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  choices = ["yes", "no","No, you're not eating", "Yes, ate down diva", "No, you're not slick","Not today hunny", "Yes, level 100 gyatt","Naur, Bad girl", "Naur, Bad boy","Oui,good girl","Oui, good boy"]
6
  #use random to select one of those messages
7
  random_word = random.choice(choices)
8
  return random_word
9
 
10
- chatbot = gr.ChatInterface(echo, type = "messages")
11
 
12
  chatbot.launch()
 
1
  import gradio as gr
2
  import random
3
+ from huggingface_hub import InferenceClient
4
 
5
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
6
+
7
+ def respond(message, history):
8
+
9
+
10
+ messages = [{"role": "system", "content": "You are a friendly chatbot."}]
11
+ if history:
12
+ messages.extend(history)
13
+
14
+ messages.append({"role" : "user", "content" : message})
15
+
16
+ response = client.chat_completion(messages, max_toxens = 100)
17
+
18
+ print(response['choices'][0]['message']['content'].strip())
19
+
20
+
21
+ return response['choices'][0]['message']['content'].strip()
22
+
23
+ def echo(message, history):
24
  choices = ["yes", "no","No, you're not eating", "Yes, ate down diva", "No, you're not slick","Not today hunny", "Yes, level 100 gyatt","Naur, Bad girl", "Naur, Bad boy","Oui,good girl","Oui, good boy"]
25
  #use random to select one of those messages
26
  random_word = random.choice(choices)
27
  return random_word
28
 
29
+ chatbot = gr.ChatInterface(respond, type = "messages")
30
 
31
  chatbot.launch()