ehioko commited on
Commit
abe0094
·
verified ·
1 Parent(s): 7795900

adding hugging face & transitioning to a generative AI model

Browse files
Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -1,10 +1,24 @@
1
- import random
2
  import gradio as gr
 
3
 
4
- def magic_eight(message, answers):
5
- answers = ["your heart knows the answer", "trust your gut", "the truth lies before you", "follow the wind", "danger lurks around", "be brave and take the risk", "don't be afraid of falling short", "try again"]
6
- return random.choice(answers)
7
 
8
- chatbot = gr.ChatInterface(magic_eight, type = 'messages', title = "Magic 8-Ball 🎱", description = "Ask Me Anything ", theme = "mgetz/Celeb_glitzy")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  chatbot.launch()
10
 
 
 
1
  import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
 
4
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
 
 
5
 
6
+ def respond(message, history):
7
+ messages = [{"role": "system", "content": "You're a friendly chatbot"}]
8
+
9
+ if history:
10
+ messages.extend(history)
11
+
12
+ messages.append({"role": "user", "content": message})
13
+
14
+ response = client.chat_completiion(
15
+ messages,
16
+ max_tokens = 100,
17
+ temperature = 0.2
18
+ )
19
+
20
+ return response['choices'][0]['message']['content'].strip()
21
+
22
+ chatbot = gr.ChatInterface(magic_eight, type = 'messages')
23
  chatbot.launch()
24