@@ -48,6 +48,10 @@ class QueryStatus(Enum):
4848 CANCELLED = "cancelled"
4949
5050
51+ _OUTPUT_DICT_TYPE = dict [str , str | list [str ]]
52+ _OUTPUT_RESULT_TYPE = str | tuple [str , ...] | _OUTPUT_DICT_TYPE | None
53+
54+
5155class Query (msgspec .Struct , kw_only = True ):
5256 """Represents a single inference query to be sent to an endpoint.
5357
@@ -105,10 +109,10 @@ class QueryResult(msgspec.Struct, tag="query_result", kw_only=True, frozen=True)
105109 """
106110
107111 id : str = ""
108- response_output : str | tuple [ str , ...] | None = None
112+ response_output : _OUTPUT_RESULT_TYPE = None
109113 metadata : dict [str , Any ] = msgspec .field (default_factory = dict )
110114 error : str | None = None
111- completed_at : float = msgspec .UNSET
115+ completed_at : int = msgspec .UNSET
112116
113117 def __post_init__ (self ):
114118 """Set completion timestamp automatically.
@@ -122,6 +126,9 @@ def __post_init__(self):
122126 """
123127 # Disallow user setting completed_at time to prevent cheating.
124128 # Timestamp must be generated internally
129+ # Note that this will also be regenerated during encode+decode. This is
130+ # intentional, since timestamps in child and parent processes may be different
131+ # due to how monotonic_ns works.
125132 msgspec .structs .force_setattr (self , "completed_at" , time .monotonic_ns ())
126133
127134 # A list can be passed on, but we need to convert it to a tuple to maintain immutability,
0 commit comments