Nexchan commited on
Commit
e3172a9
·
verified ·
1 Parent(s): 9baa4cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -17
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
- with gr.Blocks() as demo:
49
- with gr.Row():
50
- with gr.Column():
51
- chatbot = gr.Chatbot()
52
- msg = gr.Textbox(interactive=True)
53
- with gr.Row():
54
- clear = gr.ClearButton([msg, chatbot])
55
- send_btn = gr.Button("Send", variant='primary')
56
- msg.submit(fn=chat_mem, inputs=[msg, chatbot], outputs=[msg, chatbot])
57
- send_btn.click(fn=chat_mem, inputs=[msg, chatbot], outputs=[msg, chatbot])
58
-
59
- with gr.Column():
60
- json_input = gr.Textbox(placeholder='Input JSON here...', interactive=True, lines=10)
61
- json_output = gr.Textbox(label='Output JSON', interactive=False, lines=10)
62
- process_btn = gr.Button("Process JSON", variant='primary')
63
- process_btn.click(fn=process_json, inputs=json_input, outputs=[json_output])
 
64
 
65
- # Jalankan antarmuka Gradio dan sediakan API
 
 
 
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)