Nexchan commited on
Commit
f496df2
·
verified ·
1 Parent(s): 75bef96

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -16
app.py CHANGED
@@ -58,23 +58,16 @@ def api_chat(chat_history: List[Dict[str, str]]):
58
 
59
  # Mengatur antarmuka Gradio
60
  with gr.Blocks() as demo:
61
- gr.Markdown("## Chat Demo")
62
- with gr.Row():
63
- with gr.Column():
64
- # Bagian Antarmuka Pengguna
65
- chatbot = gr.Chatbot()
66
- msg = gr.Textbox(placeholder="Type your message here...", interactive=True)
67
- with gr.Row():
68
- clear = gr.ClearButton([msg, chatbot], icon="https://img.icons8.com/?size=100&id=Xnx8cxDef16O&format=png&color=000000")
69
- send_btn = gr.Button("Send", variant='primary', icon="https://img.icons8.com/?size=100&id=g8ltXTwIfJ1n&format=png&color=000000")
70
- msg.submit(fn=chat_mem, inputs=[msg, chatbot], outputs=[msg, chatbot])
71
- send_btn.click(fn=chat_mem, inputs=[msg, chatbot], outputs=[msg, chatbot])
72
 
73
- gr.Markdown("## API Endpoint for Testing")
74
- gr.Markdown("### Send a POST request to `/api/chat` with the following JSON body:")
75
- gr.Markdown("```json\n[ { \"role\": \"user\", \"content\": \"Hello, how are you?\" }, { \"role\": \"assistant\", \"content\": \"I'm fine, thank you! How can I assist you today?\" }, { \"role\": \"user\", \"content\": \"Can you tell me a joke?\" } ]\n```")
76
- gr.Markdown("### API Response:")
77
- gr.Interface(fn=api_chat, inputs="json", outputs="json").launch()
78
 
79
  if __name__ == "__main__":
80
  demo.launch()
 
58
 
59
  # Mengatur antarmuka Gradio
60
  with gr.Blocks() as demo:
61
+ with gr.Row():
62
+ with gr.Column():
63
+ chatbot = gr.Chatbot()
64
+ msg = gr.Textbox(interactive=True, )
65
+ with gr.Row():
66
+ clear = gr.ClearButton([msg, chatbot], icon="https://img.icons8.com/?size=100&id=Xnx8cxDef16O&format=png&color=000000")
67
+ send_btn = gr.Button("Send", variant='primary', icon="https://img.icons8.com/?size=100&id=g8ltXTwIfJ1n&format=png&color=000000")
68
+ msg.submit(fn=chat_mem, inputs=[msg, chatbot], outputs=[msg, chatbot])
69
+ send_btn.click(fn=chat_mem, inputs=[msg, chatbot], outputs=[msg, chatbot])
 
 
70
 
 
 
 
 
 
71
 
72
  if __name__ == "__main__":
73
  demo.launch()