Saachi-S123 commited on
Commit
a990171
·
verified ·
1 Parent(s): c8f669b

adding huggingface & transitioning to a generative AI mode

Browse files
Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -1,11 +1,25 @@
1
  import gradio as gr
2
- import random
3
 
4
- def respond_magic_eight_ball(message, history):
5
- responses = random.choices (["It is certain", "It is decidedly so","Without a doubt", "Yes, definitely", "You may rely on it", "As I see it, yes", "Most likely", "Outlook good", "Yes", "Signs point to yes", "Don't count on it", "My reply is no"," My sources say no", "Outlook not so good", "Very doubtful" ])
6
- return random.choice (responses)
7
 
8
- chatbot = gr.ChatInterface(respond_magic_eight_ball, type='messages', title = "Magic 8 Ball", description = "Ask me your most pressing questions!", theme = "mgetz/Celeb_glitzy")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  chatbot.launch()
10
 
11
 
 
1
  import gradio as gr
2
+ from huggingface_hub improt InferenceClient
3
 
4
+ client = InterfaceClient("HuggingFaceH$/zephyr-7b-beta")
 
 
5
 
6
+ def respond(message, history):
7
+ messages = [{"role": "system", "content": "You are a freindly 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
+
20
+ return response['choices'][0]['message']['content'].strip()
21
+
22
+ chatbot = gr.ChatInterface(respond_magic_eight_ball, type="messages")
23
  chatbot.launch()
24
 
25