Janec09 commited on
Commit
e5f6e9a
·
verified ·
1 Parent(s): a09c735

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -7
app.py CHANGED
@@ -1,16 +1,31 @@
1
  import gradio as gr
2
  import random
 
3
 
4
- def magic_8_ball(message, history):
5
- return random.choice(['yes', 'no', 'maybe'])
6
 
7
- #def yes_or_no(message, history):
8
- # return random.choice(['Yes', 'No'])
9
- #def echo(message, history):
10
- # return message
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  print("Hello World!")
13
- chatbot = gr.ChatInterface(magic_8_ball, title = "Magic 8 Ball", description = "Let's play magic 8 ball!", type = "messages")
14
  #defining my chatbot so users can interact and see their conversation history and send new messages!
15
 
16
  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
+ messages[{"role": "system", "content": "You are a friendly chatbot."}]
9
+
10
+ if history:
11
+ messages.extend(history)
12
+
13
+ messages.append({"role": "user", "content": message})
14
+
15
+ response = client.chat_completion(messages, max_token = 100)
16
+
17
+ return response['choices'][0]['message']['content'].strip()
18
+
19
+ #def magic_8_ball(message, history):
20
+ #return random.choice(['yes', 'no', 'maybe'])
21
+
22
+ def yes_or_no(message, history):
23
+ return random.choice(['Yes', 'No'])
24
+ def echo(message, history):
25
+ return message
26
 
27
  print("Hello World!")
28
+ chatbot = gr.ChatInterface(response, type = "messages")
29
  #defining my chatbot so users can interact and see their conversation history and send new messages!
30
 
31
  chatbot.launch()