api / app.py
sbshehab200's picture
Update app.py
9c03eff verified
Raw
History Blame Contribute Delete
512 Bytes
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()