Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -106,33 +106,30 @@ def handle_user_message(user_text, chat_history, state):
|
|
| 106 |
def suggestion_click(text, chat_history, state):
|
| 107 |
return handle_user_message(text, chat_history, state)
|
| 108 |
|
| 109 |
-
with gr.Blocks(title="SysLink Food System
|
| 110 |
state = gr.State(init_state())
|
|
|
|
| 111 |
gr.Markdown("## SysLink Food System Assistant")
|
| 112 |
-
|
|
|
|
| 113 |
|
| 114 |
with gr.Row():
|
| 115 |
-
s1 = gr.Button(visible=False)
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
user_in = gr.Textbox(placeholder="Type your message...", label="Message")
|
| 119 |
send_btn = gr.Button("Send")
|
| 120 |
open_btn = gr.Button("Open Chat")
|
| 121 |
|
| 122 |
-
open_btn.click(on_open, inputs=[
|
| 123 |
-
send_btn.click(handle_user_message, inputs=[user_in,
|
| 124 |
-
user_in.submit(handle_user_message, inputs=[user_in,
|
| 125 |
|
| 126 |
for b in [s1, s2, s3, s4, s5, s6]:
|
| 127 |
-
b.click(suggestion_click, inputs=[b,
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
app = gr.mount_gradio_app(api, demo, path="/")
|
| 131 |
-
|
| 132 |
-
if __name__ == "__main__":
|
| 133 |
-
demo.queue()
|
| 134 |
-
demo.launch(
|
| 135 |
-
server_name="0.0.0.0",
|
| 136 |
-
server_port=int(os.environ.get("PORT", 7860)),
|
| 137 |
-
show_error=True,
|
| 138 |
-
)
|
|
|
|
| 106 |
def suggestion_click(text, chat_history, state):
|
| 107 |
return handle_user_message(text, chat_history, state)
|
| 108 |
|
| 109 |
+
with gr.Blocks(title="SysLink Food System Chatbot") as demo:
|
| 110 |
state = gr.State(init_state())
|
| 111 |
+
|
| 112 |
gr.Markdown("## SysLink Food System Assistant")
|
| 113 |
+
|
| 114 |
+
chat = gr.Chatbot(height=420)
|
| 115 |
|
| 116 |
with gr.Row():
|
| 117 |
+
s1 = gr.Button(visible=False)
|
| 118 |
+
s2 = gr.Button(visible=False)
|
| 119 |
+
s3 = gr.Button(visible=False)
|
| 120 |
+
s4 = gr.Button(visible=False)
|
| 121 |
+
s5 = gr.Button(visible=False)
|
| 122 |
+
s6 = gr.Button(visible=False)
|
| 123 |
|
| 124 |
user_in = gr.Textbox(placeholder="Type your message...", label="Message")
|
| 125 |
send_btn = gr.Button("Send")
|
| 126 |
open_btn = gr.Button("Open Chat")
|
| 127 |
|
| 128 |
+
open_btn.click(on_open, inputs=[chat, state], outputs=[chat, state, s1, s2, s3, s4, s5, s6])
|
| 129 |
+
send_btn.click(handle_user_message, inputs=[user_in, chat, state], outputs=[user_in, chat, state, s1, s2, s3, s4, s5, s6])
|
| 130 |
+
user_in.submit(handle_user_message, inputs=[user_in, chat, state], outputs=[user_in, chat, state, s1, s2, s3, s4, s5, s6])
|
| 131 |
|
| 132 |
for b in [s1, s2, s3, s4, s5, s6]:
|
| 133 |
+
b.click(suggestion_click, inputs=[b, chat, state], outputs=[user_in, chat, state, s1, s2, s3, s4, s5, s6])
|
| 134 |
+
|
| 135 |
+
app = demo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|