Sadmo commited on
Commit
3da3563
·
verified ·
1 Parent(s): 35d37a6

Attached the API to access the model!

Browse files
Files changed (1) hide show
  1. app.py +25 -5
app.py CHANGED
@@ -1,14 +1,34 @@
1
  import gradio as gr
2
  import random
 
3
 
4
- def random_message(message, history):
5
- choices = ["Yes", "No", "Try Again Later.", "Of course!", "Bruh.", "Wow.", "I don't know...", "... You're weird", "Obviously..?", "Duh.", "Sure", "I don't think so ha."]
6
 
7
- randomMessage = random.choice(choices)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
- return randomMessage
10
 
11
- chatbot = gr.ChatInterface(random_message, type = "messages", title = "Brutal 8Ball Fortune Teller for KWK", theme = gr.themes.Glass(), examples = ["How will lunch be today?", "How's the weather today?", "Is Trinity goofy?"])
12
 
13
  chatbot.launch()
14
 
 
1
  import gradio as gr
2
  import random
3
+ from huggingface_hub import InferenceClient
4
 
5
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
 
6
 
7
+
8
+
9
+ def respond(message, history):
10
+ messages = [{"role": "system", "content":"You are a friendly chatbot."}]
11
+ if history:
12
+ messages.extend(history)
13
+ messages.append({"role": "user", "content": message})
14
+
15
+ response = client.chat_completion(
16
+ messages,
17
+ max_tokens=100
18
+ )
19
+
20
+ return response['choices'][0]['message']['content'].strip()
21
+
22
+
23
+
24
+ #def random_message(message, history):
25
+ # choices = ["Yes", "No", "Try Again Later.", "Of course!", "Bruh.", "Wow.", "I don't know...", "... You're weird", "Obviously..?", "Duh.", "Sure", "I don't think so ha."]
26
+
27
+ # randomMessage = random.choice(choices)
28
 
29
+ # return randomMessage
30
 
31
+ chatbot = gr.ChatInterface(respond, type = "messages", title = "Brutal 8Ball Fortune Teller for KWK", theme = gr.themes.Glass(), examples = ["How will lunch be today?", "How's the weather today?", "Is Trinity goofy?"])
32
 
33
  chatbot.launch()
34