Pengi5659 commited on
Commit
d733c1e
·
verified ·
1 Parent(s): 646f983

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -24
app.py CHANGED
@@ -1,27 +1,11 @@
1
- import gradio as gr
2
- import random as rd
3
- from huggingface_hub import InferenceClient
 
4
 
5
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
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(
12
- messages,
13
- max_tokens=100
14
-
15
- )
16
- print(response['choices'][0]['message']['content'].strip())
17
- return response['choices'][0]['message']['content'].strip()
18
 
19
- def echo (message, history):
20
- eight_ball_answers = ["yes","no","ehhh probably not the best idea","Sure why not!","idk","i seems not","hahahaha... no","yes of course!"]
21
- random_choice = rd.choice(eight_ball_answers)
22
- return random_choice
23
 
24
- chatbot = gr.ChatInterface(respond, type = "messages")
25
-
26
- chatbot.launch()
27
-
 
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()