From ef99be147238c7b4ca23e83a09da49ab1d513663 Mon Sep 17 00:00:00 2001 From: Ahmad Haidar Date: Sun, 5 Jan 2025 16:10:37 +0300 Subject: [PATCH] fix(agents-api): Fix timestamp type in entries --- agents-api/agents_api/autogen/Entries.py | 2 +- agents-api/agents_api/autogen/openapi_model.py | 2 +- agents-api/agents_api/queries/entries/create_entries.py | 2 +- integrations-service/integrations/autogen/Entries.py | 2 +- typespec/entries/models.tsp | 3 +-- typespec/tsp-output/@typespec/openapi3/openapi-1.0.0.yaml | 4 ++-- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/agents-api/agents_api/autogen/Entries.py b/agents-api/agents_api/autogen/Entries.py index 867b10192..164a37b28 100644 --- a/agents-api/agents_api/autogen/Entries.py +++ b/agents-api/agents_api/autogen/Entries.py @@ -69,7 +69,7 @@ class BaseEntry(BaseModel): """ The tool call id of the tool call this message is a response to """ - timestamp: Annotated[float, Field(ge=0.0)] + timestamp: AwareDatetime """ This is the time that this event refers to. """ diff --git a/agents-api/agents_api/autogen/openapi_model.py b/agents-api/agents_api/autogen/openapi_model.py index ffcf9caf9..06f62fb28 100644 --- a/agents-api/agents_api/autogen/openapi_model.py +++ b/agents-api/agents_api/autogen/openapi_model.py @@ -372,7 +372,7 @@ class CreateTransitionRequest(Transition): class CreateEntryRequest(BaseEntry): - timestamp: Annotated[float, Field(ge=0.0, default_factory=lambda: utcnow().timestamp())] + timestamp: Annotated[AwareDatetime, Field(default_factory=lambda: utcnow())] @classmethod def from_model_input( diff --git a/agents-api/agents_api/queries/entries/create_entries.py b/agents-api/agents_api/queries/entries/create_entries.py index defd15e0e..b9cb33011 100644 --- a/agents-api/agents_api/queries/entries/create_entries.py +++ b/agents-api/agents_api/queries/entries/create_entries.py @@ -104,7 +104,7 @@ async def create_entries( item.get("token_count"), # $11 select_tokenizer(item.get("model"))["type"], # $12 item.get("created_at") or utcnow(), # $13 - utcnow().timestamp(), # $14 + utcnow(), # $14 ] for item in data_dicts ] diff --git a/integrations-service/integrations/autogen/Entries.py b/integrations-service/integrations/autogen/Entries.py index 867b10192..164a37b28 100644 --- a/integrations-service/integrations/autogen/Entries.py +++ b/integrations-service/integrations/autogen/Entries.py @@ -69,7 +69,7 @@ class BaseEntry(BaseModel): """ The tool call id of the tool call this message is a response to """ - timestamp: Annotated[float, Field(ge=0.0)] + timestamp: AwareDatetime """ This is the time that this event refers to. """ diff --git a/typespec/entries/models.tsp b/typespec/entries/models.tsp index d7eae55e7..597d9b189 100644 --- a/typespec/entries/models.tsp +++ b/typespec/entries/models.tsp @@ -116,8 +116,7 @@ model BaseEntry { tool_call_id?: string | null = null; /** This is the time that this event refers to. */ - @minValue(0) - timestamp: float; + timestamp: utcDateTime; } model Entry extends BaseEntry { diff --git a/typespec/tsp-output/@typespec/openapi3/openapi-1.0.0.yaml b/typespec/tsp-output/@typespec/openapi3/openapi-1.0.0.yaml index 1d3989810..f9ad4aa86 100644 --- a/typespec/tsp-output/@typespec/openapi3/openapi-1.0.0.yaml +++ b/typespec/tsp-output/@typespec/openapi3/openapi-1.0.0.yaml @@ -3350,8 +3350,8 @@ components: description: The tool call id of the tool call this message is a response to default: null timestamp: - type: number - minimum: 0 + type: string + format: date-time description: This is the time that this event refers to. Entries.ChatMLRole: type: string