AriniR commited on
Commit
1786fdc
·
verified ·
1 Parent(s): 16e86e7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -4,12 +4,21 @@ from huggingface_hub import InferenceClient
4
 
5
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
6
 
 
 
 
 
 
 
 
 
 
7
  def random_message (message, history):
8
  choices = ('yes','no','i dont think so','be so for real','yep', 'woooow', 'hmmmm', 'idk', 'idc', 'yaaay', 'why would i know')
9
  wow = random.choice(choices)
10
  theme = soft
11
  return wow
12
- chatbot = gr.ChatInterface(random_message, type = "messages", title = "chatty")
13
 
14
 
15
 
 
4
 
5
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
6
 
7
+ def respond():
8
+ messages = [{"role":"system","content":"You are a friendly chatbot"}]
9
+ if history :
10
+ messages.extend(history)
11
+ messages.append{["role":"user","content": message]}
12
+ response = client.chat_completion(messages, max_tokens = 100)
13
+ return response["choices"][o]["message"]["content"].strip()
14
+
15
+
16
  def random_message (message, history):
17
  choices = ('yes','no','i dont think so','be so for real','yep', 'woooow', 'hmmmm', 'idk', 'idc', 'yaaay', 'why would i know')
18
  wow = random.choice(choices)
19
  theme = soft
20
  return wow
21
+ chatbot = gr.ChatInterface(respond, type = "messages", title = "chatty")
22
 
23
 
24