Spaces:
Runtime error
Runtime error
yizhangliu
commited on
Commit
•
626d1e7
1
Parent(s):
9f9aee0
Update app.py
Browse files
app.py
CHANGED
@@ -19,12 +19,22 @@ def get_response_from_chatbot(text):
|
|
19 |
response = "Sorry, I'm am tired."
|
20 |
return response
|
21 |
|
22 |
-
def chat(message, history):
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
start_work = """async() => {
|
29 |
function isMobile() {
|
30 |
try {
|
@@ -127,16 +137,17 @@ with gr.Blocks(title='Text to Image') as demo:
|
|
127 |
|
128 |
with gr.Group(elem_id="page_2", visible=False) as page_2:
|
129 |
with gr.Row(elem_id="prompt_row"):
|
130 |
-
chatbot = gr.Chatbot(elem_id="chat_bot").style(color_map=("green", "gray"))
|
131 |
-
prompt_input0 = gr.Textbox(lines=4, label="prompt")
|
132 |
with gr.Row():
|
|
|
|
|
133 |
submit_btn = gr.Button(value = "submit",elem_id="erase-btn").style(
|
134 |
margin=True,
|
135 |
rounded=(True, True, True, True),
|
136 |
)
|
137 |
submit_btn.click(fn=chat,
|
138 |
-
inputs=[prompt_input0,
|
139 |
-
outputs=[chatbot,
|
140 |
)
|
141 |
|
142 |
# chatbot = gr.Chatbot(elem_id="chat_bot").style(color_map=("green", "gray"))
|
|
|
19 |
response = "Sorry, I'm am tired."
|
20 |
return response
|
21 |
|
22 |
+
# def chat(message, history):
|
23 |
+
# history = history or []
|
24 |
+
# response = get_response_from_chatbot(message)
|
25 |
+
# history.append((message, response))
|
26 |
+
# return history, history
|
27 |
|
28 |
+
def chat(message, chat_history):
|
29 |
+
split_mark = 'CHCHCHCHCHCH'
|
30 |
+
if chat_history == '':
|
31 |
+
chat_history = []
|
32 |
+
else:
|
33 |
+
chat_history = chat_history.split(split_mark)
|
34 |
+
response = get_response_from_chatbot(message)
|
35 |
+
chat_history.append((message, response))
|
36 |
+
return chat_history, split_mark.join(chat_history)
|
37 |
+
|
38 |
start_work = """async() => {
|
39 |
function isMobile() {
|
40 |
try {
|
|
|
137 |
|
138 |
with gr.Group(elem_id="page_2", visible=False) as page_2:
|
139 |
with gr.Row(elem_id="prompt_row"):
|
140 |
+
chatbot = gr.Chatbot(elem_id="chat_bot").style(color_map=("green", "gray"))
|
|
|
141 |
with gr.Row():
|
142 |
+
prompt_input0 = gr.Textbox(lines=2, label="prompt")
|
143 |
+
chat_history = gr.Textbox(lines=2, label="prompt", visible=False)
|
144 |
submit_btn = gr.Button(value = "submit",elem_id="erase-btn").style(
|
145 |
margin=True,
|
146 |
rounded=(True, True, True, True),
|
147 |
)
|
148 |
submit_btn.click(fn=chat,
|
149 |
+
inputs=[prompt_input0, chat_history],
|
150 |
+
outputs=[chatbot, chat_history],
|
151 |
)
|
152 |
|
153 |
# chatbot = gr.Chatbot(elem_id="chat_bot").style(color_map=("green", "gray"))
|