riyamalshe commited on
Commit
410fe98
·
verified ·
1 Parent(s): c96fc09

adding huggingface & transitioning to a generative AI model

Browse files
Files changed (1) hide show
  1. app.py +17 -10
app.py CHANGED
@@ -1,16 +1,23 @@
1
- import random
2
  import gradio as gr
 
3
 
4
- def echo(message, history):
5
- print(message)
6
- print(history)
7
- return message
8
 
9
- def random_response(message, history):
10
- return random.choice(["Yes", "No"])
11
 
12
- def magic_8_ball(message, history):
13
- return random.choice(["It is certain", "Most likely", "Yes", "You may rely on it", "Ask again later", "Don't count on it", "My sources say no", "Cannot predict now", "Outlook not so good"])
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- chatbot = gr.ChatInterface(magic_8_ball, type = 'messages', title = 'Magic 8 Ball', description = "Ask me your most pressing questions!", theme = "mgetz/Celeb_glitzy")
16
  chatbot.launch()
 
 
1
  import gradio as gr
2
+ from huggingface_hub import InferenceCLient
3
 
4
+ client = InterfaceClient("HuggingFaceH4/zephyr-7b-beta")
 
 
 
5
 
6
+ def respond(message, history):
7
+ messages = [{"role": "system", "content": "You are friend chatbot"}]\
8
 
9
+ if history:
10
+ messages.extend(history)
11
+
12
+ messages.append({"role": "user", "content": message})
13
+
14
+ response = client.chat_completion(
15
+ messages,
16
+ max_tokens = 100,
17
+ temperature = 0.2
18
+ )
19
+ return response['choices'][0]['message']['content'].strip()
20
+
21
+ chatbot = gr.ChatInterface(, type = 'messages')
22
 
 
23
  chatbot.launch()