Add chat_completions endpoint to handle chat requests with message array
Build and Push Agent API / build (push) Successful in 5s
Build and Push Agent API / build (push) Successful in 5s
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user