TeahReichenbaum commited on
Commit
5e35fd7
·
verified ·
1 Parent(s): 84217a6

NewApp.py

Browse files
Files changed (1) hide show
  1. app.py +25 -11
app.py CHANGED
@@ -1,18 +1,32 @@
1
  import gradio as gr
2
  import random
 
3
 
4
- # def echo (message, hisotry)
5
- # return (message)
6
 
7
- # def yesNoRandom(message,history):
8
- # repsonse=["yes","no"]
9
- # return random.choice(repsonse)
10
 
11
- # chatbot = gr.ChatInterface(yesNoRandom, type = "messages", title = "Yes or No Bot", description = "This chatbot randomly repsonds to questions with yes or no.")
12
 
13
- def magicEightBall(message,history):
14
- response=["It's certain", "Try Again", "Chances are low", "Yes", "no", "Unlikley", "likley","Ask later"]
15
- return random.choice(response)
16
- chatbot=gr.ChatInterface(magicEightBall, type="messages", title,"Magic eight Ball",theme='d8ahazard/material_design_rd')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- chatbot.launch()
 
1
  import gradio as gr
2
  import random
3
+ import os
4
 
5
+ from huggingface_hub import InferenceClient
 
6
 
 
 
 
7
 
 
8
 
9
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
10
+
11
+
12
+ def respond(message,history):
13
+ messages = [{"role":"system","You are a friendly chatbot!"}]
14
+
15
+ if history:
16
+ messages.extend(history)
17
+ messages.append({"role":"user","content":messages})
18
+
19
+ response = client.chat_completion(
20
+ mesages,
21
+ max_token=100)
22
+ return response ['choices'][0]['message']['content'].strip()
23
+
24
+
25
+
26
+
27
+ chatbot = gr.ChatInterface(repsond, type = "messages")
28
+
29
+ chatbot.launch()
30
+
31
+
32