Skip to content

Commit

Permalink
fix: Remove created_at field from messages
Browse files Browse the repository at this point in the history
  • Loading branch information
whiterabbit1983 committed Sep 14, 2024
1 parent 1b3e5dd commit 151c2fb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion agents-api/agents_api/routers/sessions/chat.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from contextlib import suppress
from typing import Annotated
from uuid import UUID, uuid4

Expand Down Expand Up @@ -51,7 +52,7 @@ async def chat(
settings: dict = chat_context.settings.model_dump()
env: dict = chat_context.get_chat_environment()
settings["model"] = f"openai/{settings['model']}" # litellm proxy idiosyncracy

# Render the messages
new_raw_messages = [msg.model_dump() for msg in chat_input.messages]

Expand All @@ -64,6 +65,11 @@ async def chat(

env["docs"] = doc_references
new_messages = await render_template(new_raw_messages, variables=env)

for m in past_messages:
with suppress(KeyError):
del m["created_at"]

messages = past_messages + new_messages

# Get the tools
Expand Down

0 comments on commit 151c2fb

Please sign in to comment.