diff --git a/langfuse/api/legacy/observations_v1/client.py b/langfuse/api/legacy/observations_v1/client.py index 871191ee5..fc7f37b48 100644 --- a/langfuse/api/legacy/observations_v1/client.py +++ b/langfuse/api/legacy/observations_v1/client.py @@ -35,6 +35,7 @@ def get( self, observation_id: str, *, + start_time: typing.Optional[dt.datetime] = None, request_options: typing.Optional[RequestOptions] = None, ) -> ObservationsViewSingle: """ @@ -45,6 +46,9 @@ def get( observation_id : str The unique langfuse identifier of an observation, can be an event, span or generation + start_time : typing.Optional[dt.datetime] + The start time of the observation (ISO 8601 with offset, e.g. 2024-01-01T00:00:00Z). When provided, the lookup is restricted to the observation's start day, which makes the request substantially faster. Omit it to look up the observation without a time bound. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -69,7 +73,7 @@ def get( ) """ _response = self._raw_client.get( - observation_id, request_options=request_options + observation_id, start_time=start_time, request_options=request_options ) return _response.data @@ -291,6 +295,7 @@ async def get( self, observation_id: str, *, + start_time: typing.Optional[dt.datetime] = None, request_options: typing.Optional[RequestOptions] = None, ) -> ObservationsViewSingle: """ @@ -301,6 +306,9 @@ async def get( observation_id : str The unique langfuse identifier of an observation, can be an event, span or generation + start_time : typing.Optional[dt.datetime] + The start time of the observation (ISO 8601 with offset, e.g. 2024-01-01T00:00:00Z). When provided, the lookup is restricted to the observation's start day, which makes the request substantially faster. Omit it to look up the observation without a time bound. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -333,7 +341,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._raw_client.get( - observation_id, request_options=request_options + observation_id, start_time=start_time, request_options=request_options ) return _response.data diff --git a/langfuse/api/legacy/observations_v1/raw_client.py b/langfuse/api/legacy/observations_v1/raw_client.py index 73343c130..9023dce56 100644 --- a/langfuse/api/legacy/observations_v1/raw_client.py +++ b/langfuse/api/legacy/observations_v1/raw_client.py @@ -34,6 +34,7 @@ def get( self, observation_id: str, *, + start_time: typing.Optional[dt.datetime] = None, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[ObservationsViewSingle]: """ @@ -44,6 +45,9 @@ def get( observation_id : str The unique langfuse identifier of an observation, can be an event, span or generation + start_time : typing.Optional[dt.datetime] + The start time of the observation (ISO 8601 with offset, e.g. 2024-01-01T00:00:00Z). When provided, the lookup is restricted to the observation's start day, which makes the request substantially faster. Omit it to look up the observation without a time bound. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -54,6 +58,11 @@ def get( _response = self._client_wrapper.httpx_client.request( f"api/public/observations/{jsonable_encoder(observation_id)}", method="GET", + params={ + "startTime": serialize_datetime(start_time) + if start_time is not None + else None, + }, request_options=request_options, ) try: @@ -411,6 +420,7 @@ async def get( self, observation_id: str, *, + start_time: typing.Optional[dt.datetime] = None, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[ObservationsViewSingle]: """ @@ -421,6 +431,9 @@ async def get( observation_id : str The unique langfuse identifier of an observation, can be an event, span or generation + start_time : typing.Optional[dt.datetime] + The start time of the observation (ISO 8601 with offset, e.g. 2024-01-01T00:00:00Z). When provided, the lookup is restricted to the observation's start day, which makes the request substantially faster. Omit it to look up the observation without a time bound. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -431,6 +444,11 @@ async def get( _response = await self._client_wrapper.httpx_client.request( f"api/public/observations/{jsonable_encoder(observation_id)}", method="GET", + params={ + "startTime": serialize_datetime(start_time) + if start_time is not None + else None, + }, request_options=request_options, ) try: