RithikaChalam commited on
Commit
fd92139
·
verified ·
1 Parent(s): 150cbe0

adding huggingface & transitioning to a generative AI model

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -1,12 +1,15 @@
1
  import gradio as gr
2
- import random
3
 
4
- def eight_ball(message,history):
5
- return random.choice(['It is certain', 'Reply hazy, try again', 'Don’t count on it',
6
- 'It is decidedly so', 'Ask again later', 'My reply is no',
7
- 'Without a doubt', 'Better not tell you now', 'My sources say no',
8
- 'Yes definitely', 'Cannot predict now', 'Outlook not so good',
9
- 'You may rely on it', 'Concentrate and ask again', 'Very doubtful'])
 
 
 
10
 
11
- chatbot = gr.ChatInterface(eight_ball, type="messages", title="Magic Eight Ball", description="Ask me your most pressing questions!", theme="mgetz/Celeb_glitzy")
12
  chatbot.launch()
 
1
  import gradio as gr
2
+ from huggingface_hub import Inference_Client
3
 
4
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
5
+
6
+ def respond(message,history):
7
+ messages = [{"role": "system","content":"You are a friendly chatbot"}]
8
+ if history:
9
+ messages.extend(history)
10
+ messages.append({"role":"user", "content":message})
11
+ response = client.chat_completion(messages,max_tokens=100,temperature=0.2)
12
+ return response['choices'][0]['message']['content'].strip()
13
 
14
+ chatbot = gr.ChatInterface(respond, type="messages")
15
  chatbot.launch()