Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| def chat(messages): | |
| user_msg = "" | |
| for m in reversed(messages): | |
| if m["role"] == "user": | |
| user_msg = m["content"] | |
| break | |
| return { | |
| "choices": [ | |
| { | |
| "message": { | |
| "role": "assistant", | |
| "content": "Echo: " + user_msg | |
| } | |
| } | |
| ] | |
| } | |
| demo = gr.Interface( | |
| fn=chat, | |
| inputs=gr.JSON(), | |
| outputs=gr.JSON(), | |
| api_name="chat" | |
| ) | |
| demo.launch() |