aashnaj commited on
Commit
c6b0272
·
verified ·
1 Parent(s): 2aeaf53

adding huggingface and transitioning to a generative AI model

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -1,9 +1,21 @@
1
  import gradio as gr
2
- import random
3
 
4
- def magic_eight_ball(message, history):
5
- responses=["Yes!","No.","Yes, definetely!", "Most Likely."]
6
- return random.choice(responses)
7
 
8
- chatbot = gr.ChatInterface(magic_eight_ball, type="messages",title="Magic 8 Ball",description="Ask me your most pressing questions.", theme='shivi/calm_seafoam')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  chatbot.launch()
 
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 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(
14
+ messages,
15
+ max_toxens=100
16
+ temperature=0.2
17
+ )
18
+ return response['choices'][0]['message']['content'].strip()
19
+
20
+ chatbot = gr.ChatInterface(magic_eight_ball, type="messages")
21
  chatbot.launch()