From c24e2621aad968d14f34984b1c32163881af63a4 Mon Sep 17 00:00:00 2001 From: Julep Developers Date: Mon, 16 Sep 2024 08:48:10 +0000 Subject: [PATCH] hotfix: Apply a temp hotfix for sessions.chat --- agents-api/agents_api/routers/sessions/chat.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/agents-api/agents_api/routers/sessions/chat.py b/agents-api/agents_api/routers/sessions/chat.py index 87713c56b..ee5eec7f7 100644 --- a/agents-api/agents_api/routers/sessions/chat.py +++ b/agents-api/agents_api/routers/sessions/chat.py @@ -72,6 +72,17 @@ async def chat( # messages = messages[-settings["max_tokens"] :] raise NotImplementedError("Truncation is not yet implemented") + # FIXME: Hotfix for datetime not serializable. Needs investigation + messages = [ + msg.model_dump() if hasattr(msg, "model_dump") else msg + for msg in messages + ] + + messages = [ + dict(role=m["role"], content=m["content"], user=m.get("user")) + for m in messages + ] + # Get the response from the model model_response = await litellm.acompletion( messages=messages,