Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,22 +45,26 @@ def process_json(json_input):
|
|
| 45 |
return json.dumps(chat_history, indent=2), ""
|
| 46 |
|
| 47 |
# Definisikan antarmuka Gradio
|
| 48 |
-
|
| 49 |
-
with gr.
|
| 50 |
-
with gr.
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
| 64 |
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
| 66 |
demo.launch(server_name="0.0.0.0", server_port=7860, share=False)
|
|
|
|
| 45 |
return json.dumps(chat_history, indent=2), ""
|
| 46 |
|
| 47 |
# Definisikan antarmuka Gradio
|
| 48 |
+
def gradio_interface():
|
| 49 |
+
with gr.Blocks() as demo:
|
| 50 |
+
with gr.Row():
|
| 51 |
+
with gr.Column():
|
| 52 |
+
chatbot = gr.Chatbot()
|
| 53 |
+
msg = gr.Textbox(interactive=True)
|
| 54 |
+
with gr.Row():
|
| 55 |
+
clear = gr.ClearButton([msg, chatbot])
|
| 56 |
+
send_btn = gr.Button("Send", variant='primary')
|
| 57 |
+
msg.submit(fn=chat_mem, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
| 58 |
+
send_btn.click(fn=chat_mem, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
| 59 |
+
|
| 60 |
+
with gr.Column():
|
| 61 |
+
json_input = gr.Textbox(placeholder='Input JSON here...', interactive=True, lines=10)
|
| 62 |
+
json_output = gr.Textbox(label='Output JSON', interactive=False, lines=10)
|
| 63 |
+
process_btn = gr.Button("Process JSON", variant='primary')
|
| 64 |
+
process_btn.click(fn=process_json, inputs=json_input, outputs=[json_output])
|
| 65 |
|
| 66 |
+
return demo
|
| 67 |
+
|
| 68 |
+
# Jalankan antarmuka Gradio
|
| 69 |
+
demo = gradio_interface()
|
| 70 |
demo.launch(server_name="0.0.0.0", server_port=7860, share=False)
|