Pengi5659 commited on
Commit
797e0f7
·
verified ·
1 Parent(s): d733c1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -8
app.py CHANGED
@@ -1,11 +1,37 @@
1
- with gr.Blocks(css=".chatbox-custom .chatbot {background-color: #e6ffe6;}") as demo:
2
- with gr.Column(elem_classes="chatbox-custom"):
3
- chatbot = gr.Chatbot()
4
- msg = gr.Textbox()
5
 
6
- def respond(message, chat_history):
7
- return "", chat_history + [(message, "Hi there!")]
8
 
9
- msg.submit(respond, [msg, chatbot], [msg, chatbot])
10
 
11
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random as rd
3
+ from huggingface_hub import InferenceClient
 
4
 
 
 
5
 
 
6
 
7
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
+ def respond (message, history):
9
+ messages = [{"role": "system", "content": "You are a friendly chatbot."}]
10
+ if history:
11
+ messages.extend(history)
12
+ messages.append({"role": "user", "content": message})
13
+ response = client.chat_completion(
14
+ messages,
15
+ max_tokens=100
16
+
17
+ )
18
+ print(response['choices'][0]['message']['content'].strip())
19
+ return response['choices'][0]['message']['content'].strip()
20
+
21
+
22
+
23
+ def echo (message, history):
24
+ eight_ball_answers = ["yes","no","ehhh probably not the best idea","Sure why not!","idk","i seems not","hahahaha... no","yes of course!"]
25
+ random_choice = rd.choice(eight_ball_answers)
26
+ return random_choice
27
+
28
+
29
+
30
+ chatbot = gr.ChatInterface(respond, type = "messages")
31
+ chatbot - grchaybot.launvh(
32
+ chatbot.launch(True))
33
+
34
+
35
+
36
+
37
+