From 15c19173895bc8d39259bf9343d1452aa3023ca1 Mon Sep 17 00:00:00 2001 From: TimHoogervorst Date: Sun, 10 May 2026 16:04:13 +0200 Subject: [PATCH] Add chat_completions endpoint to handle chat requests with message array --- agent_api/main.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/agent_api/main.py b/agent_api/main.py index 7612a16..e3374b1 100644 --- a/agent_api/main.py +++ b/agent_api/main.py @@ -41,4 +41,25 @@ def chat(req: ChatRequest): return { "response": response, "session_id": req.session_id + } + +@app.post("/v1/chat/completions") +def chat_completions(req: dict): + messages = req["messages"] + user_message = messages[-1]["content"] + + response = run_agent(user_message) + + return { + "id": "chatcmpl-local", + "object": "chat.completion", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": response + } + } + ] } \ No newline at end of file