Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 62 |
-
with gr.
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 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()
|