1414
1515"""Stream message formatters for agent responses."""
1616
17+ import time
1718from typing import Any , Dict , List
1819
19- from aperag .utils .utils import now_unix_milliseconds
20-
2120from .i18n import ERROR_MESSAGES
2221from .response_types import (
2322 AgentErrorResponse ,
@@ -50,7 +49,7 @@ def format_i18n_error(error_key: str, language: str = "en-US", **kwargs) -> Agen
5049 type = "error" ,
5150 id = "error" ,
5251 data = error_message ,
53- timestamp = now_unix_milliseconds ( ),
52+ timestamp = int ( time . time () ),
5453 )
5554
5655
@@ -60,7 +59,7 @@ def format_stream_start(msg_id: str) -> AgentStartResponse:
6059 return AgentStartResponse (
6160 type = "start" ,
6261 id = msg_id ,
63- timestamp = now_unix_milliseconds ( ),
62+ timestamp = int ( time . time () ),
6463 )
6564
6665
@@ -70,7 +69,7 @@ def format_stream_content(msg_id: str, content: str) -> AgentMessageResponse:
7069 type = "message" ,
7170 id = msg_id ,
7271 data = content ,
73- timestamp = now_unix_milliseconds ( ),
72+ timestamp = int ( time . time () ),
7473 )
7574
7675
@@ -88,7 +87,7 @@ def format_stream_end(
8887 id = msg_id ,
8988 data = references ,
9089 urls = urls ,
91- timestamp = now_unix_milliseconds ( ),
90+ timestamp = int ( time . time () ),
9291 )
9392
9493
@@ -98,7 +97,7 @@ def format_thinking(msg_id: str, content: str) -> AgentThinkingResponse:
9897 type = "thinking" ,
9998 id = msg_id ,
10099 data = content ,
101- timestamp = now_unix_milliseconds ( ),
100+ timestamp = int ( time . time () ),
102101 )
103102
104103
@@ -109,7 +108,7 @@ def format_tool_call_result(msg_id: str, data: str, tool_name: str, result: Any)
109108 data = data ,
110109 tool_name = tool_name ,
111110 result = result ,
112- timestamp = now_unix_milliseconds ( ),
111+ timestamp = int ( time . time () ),
113112 )
114113
115114
@@ -119,7 +118,7 @@ def format_agent_start_message(trace_id: str, language: str = "en-US") -> Dict[s
119118 return {
120119 "type" : "start" ,
121120 "id" : trace_id ,
122- "timestamp" : now_unix_milliseconds ( ),
121+ "timestamp" : int ( time . time () ),
123122 }
124123
125124
@@ -130,7 +129,7 @@ def format_agent_stop_message(trace_id: str, references: list = None, urls: list
130129 "id" : trace_id ,
131130 "data" : references or [],
132131 "urls" : urls or [],
133- "timestamp" : now_unix_milliseconds ( ),
132+ "timestamp" : int ( time . time () ),
134133 }
135134
136135
@@ -140,7 +139,7 @@ def format_agent_thinking_message(trace_id: str, thinking_content: str) -> Dict[
140139 "type" : "thinking" ,
141140 "id" : trace_id ,
142141 "data" : thinking_content ,
143- "timestamp" : now_unix_milliseconds ( ),
142+ "timestamp" : int ( time . time () ),
144143 }
145144
146145
@@ -150,5 +149,5 @@ def format_agent_message(trace_id: str, content: str) -> Dict[str, Any]:
150149 "type" : "message" ,
151150 "id" : trace_id ,
152151 "data" : content ,
153- "timestamp" : now_unix_milliseconds ( ),
152+ "timestamp" : int ( time . time () ),
154153 }
0 commit comments