psuserlas commited on
Commit
d25fc2e
·
verified ·
1 Parent(s): f44bf59

adding hugging face& transitioning to a generative AI model

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -1,10 +1,18 @@
1
  import gradio as gr
2
- import random as rd
3
 
4
- def magic_eight_ball(message,history):
5
- responses = ["It is certain", "Without a doubt","Better not tell you now", "Don't count on it"]
6
- random_choose = rd.choice(responses)
7
- return random_choose
 
 
 
 
 
 
 
 
 
8
 
9
- chatbot = gr.ChatInterface(magic_eight_ball, type = 'messages', title = 'Best Friend', description = 'Ask me your most pressing questions!', theme = 'mgetz/Celeb_Glitzy')
10
  chatbot.launch()
 
1
  import gradio as gr
2
+ from huggingface_hub import InfrenceClient
3
 
4
+ client = IntferenceClient("HuggingFaceH4/zephyr-7b-beta")
5
+
6
+ def respond(message,history):
7
+ messages = [{"role":"system","content":"You are a friendly chatbot"}]
8
+
9
+ if history:
10
+ messages.extend(history)
11
+ messages.append([{"role":"user","content": message}])
12
+
13
+ response = client.chat_completion(messages,max_tokens=100,temperature=0.2)
14
+ return response['choices'][0]['message']['content'].strip()
15
+
16
+ chatbot = gr.ChatInterface(respond, type = 'messages')
17
 
 
18
  chatbot.launch()