From b6e1af72c8e8a2fe3006ace2ed6631ba610969b7 Mon Sep 17 00:00:00 2001 From: Max Deichmann Date: Mon, 20 Jan 2025 20:44:48 +0100 Subject: [PATCH 01/14] feat: update prompts and invalidate cache --- langfuse/api/__init__.py | 2 + langfuse/api/client.py | 44 ++-- langfuse/api/core/api_error.py | 4 +- langfuse/api/core/client_wrapper.py | 6 +- langfuse/api/core/datetime_utils.py | 4 +- langfuse/api/core/file.py | 9 +- langfuse/api/core/http_client.py | 147 +++--------- langfuse/api/core/jsonable_encoder.py | 14 +- langfuse/api/core/query_encoder.py | 10 +- langfuse/api/reference.md | 94 ++++++++ langfuse/api/resources/__init__.py | 16 +- langfuse/api/resources/comments/client.py | 140 +++--------- .../comments/types/create_comment_request.py | 25 +- .../comments/types/create_comment_response.py | 21 +- .../comments/types/get_comments_response.py | 21 +- langfuse/api/resources/commons/__init__.py | 22 +- .../api/resources/commons/errors/__init__.py | 8 +- .../api/resources/commons/types/__init__.py | 12 + .../{prompts => commons}/types/base_prompt.py | 21 +- .../api/resources/commons/types/base_score.py | 29 +-- .../resources/commons/types/boolean_score.py | 21 +- .../commons/types/categorical_score.py | 21 +- .../types/chat_message.py | 21 +- .../{prompts => commons}/types/chat_prompt.py | 21 +- .../api/resources/commons/types/comment.py | 25 +- .../commons/types/config_category.py | 21 +- .../api/resources/commons/types/dataset.py | 21 +- .../resources/commons/types/dataset_item.py | 33 +-- .../resources/commons/types/dataset_run.py | 21 +- .../commons/types/dataset_run_item.py | 25 +- .../commons/types/dataset_run_with_items.py | 25 +- .../resources/commons/types/dataset_status.py | 6 +- .../api/resources/commons/types/map_value.py | 5 +- langfuse/api/resources/commons/types/model.py | 45 +--- .../resources/commons/types/numeric_score.py | 21 +- .../resources/commons/types/observation.py | 45 +--- .../commons/types/observations_view.py | 57 ++--- .../{prompts => commons}/types/prompt.py | 42 +--- langfuse/api/resources/commons/types/score.py | 99 ++------ .../resources/commons/types/score_config.py | 33 +-- .../api/resources/commons/types/session.py | 21 +- .../commons/types/session_with_traces.py | 21 +- .../{prompts => commons}/types/text_prompt.py | 21 +- langfuse/api/resources/commons/types/trace.py | 25 +- .../commons/types/trace_with_details.py | 21 +- .../commons/types/trace_with_full_details.py | 21 +- langfuse/api/resources/commons/types/usage.py | 33 +-- .../api/resources/dataset_items/client.py | 134 +++-------- .../types/create_dataset_item_request.py | 33 +-- .../types/paginated_dataset_items.py | 21 +- .../api/resources/dataset_run_items/client.py | 54 +---- .../types/create_dataset_run_item_request.py | 29 +-- langfuse/api/resources/datasets/client.py | 216 ++++-------------- .../datasets/types/create_dataset_request.py | 21 +- .../datasets/types/paginated_dataset_runs.py | 21 +- .../datasets/types/paginated_datasets.py | 21 +- langfuse/api/resources/health/client.py | 40 +--- .../resources/health/types/health_response.py | 21 +- langfuse/api/resources/ingestion/client.py | 36 +-- .../resources/ingestion/types/base_event.py | 21 +- .../ingestion/types/create_event_body.py | 21 +- .../ingestion/types/create_event_event.py | 21 +- .../ingestion/types/create_generation_body.py | 41 +--- .../types/create_generation_event.py | 21 +- .../types/create_observation_event.py | 21 +- .../ingestion/types/create_span_body.py | 25 +- .../ingestion/types/create_span_event.py | 21 +- .../ingestion/types/ingestion_error.py | 21 +- .../ingestion/types/ingestion_event.py | 210 ++++------------- .../ingestion/types/ingestion_response.py | 21 +- .../ingestion/types/ingestion_success.py | 21 +- .../ingestion/types/observation_body.py | 41 +--- .../ingestion/types/open_ai_usage.py | 33 +-- .../ingestion/types/open_ai_usage_schema.py | 21 +- .../types/optional_observation_body.py | 33 +-- .../resources/ingestion/types/score_body.py | 29 +-- .../resources/ingestion/types/score_event.py | 21 +- .../resources/ingestion/types/sdk_log_body.py | 21 +- .../ingestion/types/sdk_log_event.py | 21 +- .../resources/ingestion/types/trace_body.py | 25 +- .../resources/ingestion/types/trace_event.py | 21 +- .../ingestion/types/update_event_body.py | 21 +- .../ingestion/types/update_generation_body.py | 41 +--- .../types/update_generation_event.py | 21 +- .../types/update_observation_event.py | 21 +- .../ingestion/types/update_span_body.py | 25 +- .../ingestion/types/update_span_event.py | 21 +- langfuse/api/resources/media/client.py | 154 +++---------- .../media/types/get_media_response.py | 21 +- .../types/get_media_upload_url_request.py | 25 +- .../types/get_media_upload_url_response.py | 25 +- .../resources/media/types/patch_media_body.py | 29 +-- langfuse/api/resources/metrics/client.py | 52 ++--- .../resources/metrics/types/daily_metrics.py | 21 +- .../metrics/types/daily_metrics_details.py | 21 +- .../resources/metrics/types/usage_by_model.py | 21 +- langfuse/api/resources/models/client.py | 194 ++++------------ .../models/types/create_model_request.py | 45 +--- .../models/types/paginated_models.py | 21 +- langfuse/api/resources/observations/client.py | 100 ++------ .../observations/types/observations.py | 21 +- .../observations/types/observations_views.py | 21 +- langfuse/api/resources/projects/client.py | 40 +--- .../api/resources/projects/types/project.py | 21 +- .../api/resources/projects/types/projects.py | 21 +- .../api/resources/prompt_version/__init__.py | 2 + .../api/resources/prompt_version/client.py | 181 +++++++++++++++ langfuse/api/resources/prompts/__init__.py | 14 -- langfuse/api/resources/prompts/client.py | 144 +++--------- .../api/resources/prompts/types/__init__.py | 18 +- .../types/create_chat_prompt_request.py | 23 +- .../prompts/types/create_prompt_request.py | 44 +--- .../types/create_text_prompt_request.py | 21 +- .../resources/prompts/types/prompt_meta.py | 21 +- .../types/prompt_meta_list_response.py | 21 +- langfuse/api/resources/score/client.py | 206 ++++------------- .../score/types/create_score_request.py | 29 +-- .../score/types/create_score_response.py | 21 +- .../score/types/get_scores_response.py | 21 +- .../score/types/get_scores_response_data.py | 103 ++------- .../types/get_scores_response_data_boolean.py | 21 +- .../get_scores_response_data_categorical.py | 21 +- .../types/get_scores_response_data_numeric.py | 21 +- .../types/get_scores_response_trace_data.py | 21 +- .../api/resources/score_configs/client.py | 130 +++-------- .../types/create_score_config_request.py | 33 +-- .../score_configs/types/score_configs.py | 21 +- langfuse/api/resources/sessions/client.py | 100 ++------ .../sessions/types/paginated_sessions.py | 21 +- langfuse/api/resources/trace/client.py | 92 ++------ langfuse/api/resources/trace/types/sort.py | 21 +- langfuse/api/resources/trace/types/traces.py | 21 +- .../pagination/types/meta_response.py | 21 +- langfuse/api/tests/utils/test_http_client.py | 26 +-- .../api/tests/utils/test_query_encoding.py | 14 +- langfuse/client.py | 25 ++ langfuse/prompt_cache.py | 6 + tests/test_updating_prompt.py | 36 +++ 138 files changed, 1451 insertions(+), 3870 deletions(-) rename langfuse/api/resources/{prompts => commons}/types/base_prompt.py (63%) rename langfuse/api/resources/{prompts => commons}/types/chat_message.py (54%) rename langfuse/api/resources/{prompts => commons}/types/chat_prompt.py (59%) rename langfuse/api/resources/{prompts => commons}/types/prompt.py (57%) rename langfuse/api/resources/{prompts => commons}/types/text_prompt.py (57%) create mode 100644 langfuse/api/resources/prompt_version/__init__.py create mode 100644 langfuse/api/resources/prompt_version/client.py create mode 100644 tests/test_updating_prompt.py diff --git a/langfuse/api/__init__.py b/langfuse/api/__init__.py index 1bdfac254..ec2bed17e 100644 --- a/langfuse/api/__init__.py +++ b/langfuse/api/__init__.py @@ -147,6 +147,7 @@ models, observations, projects, + prompt_version, prompts, score, score_configs, @@ -302,6 +303,7 @@ "models", "observations", "projects", + "prompt_version", "prompts", "score", "score_configs", diff --git a/langfuse/api/client.py b/langfuse/api/client.py index 674d62721..ce6e8577b 100644 --- a/langfuse/api/client.py +++ b/langfuse/api/client.py @@ -7,10 +7,7 @@ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .resources.comments.client import AsyncCommentsClient, CommentsClient from .resources.dataset_items.client import AsyncDatasetItemsClient, DatasetItemsClient -from .resources.dataset_run_items.client import ( - AsyncDatasetRunItemsClient, - DatasetRunItemsClient, -) +from .resources.dataset_run_items.client import AsyncDatasetRunItemsClient, DatasetRunItemsClient from .resources.datasets.client import AsyncDatasetsClient, DatasetsClient from .resources.health.client import AsyncHealthClient, HealthClient from .resources.ingestion.client import AsyncIngestionClient, IngestionClient @@ -19,6 +16,7 @@ from .resources.models.client import AsyncModelsClient, ModelsClient from .resources.observations.client import AsyncObservationsClient, ObservationsClient from .resources.projects.client import AsyncProjectsClient, ProjectsClient +from .resources.prompt_version.client import AsyncPromptVersionClient, PromptVersionClient from .resources.prompts.client import AsyncPromptsClient, PromptsClient from .resources.score.client import AsyncScoreClient, ScoreClient from .resources.score_configs.client import AsyncScoreConfigsClient, ScoreConfigsClient @@ -74,11 +72,9 @@ def __init__( password: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, timeout: typing.Optional[float] = None, follow_redirects: typing.Optional[bool] = True, - httpx_client: typing.Optional[httpx.Client] = None, + httpx_client: typing.Optional[httpx.Client] = None ): - _defaulted_timeout = ( - timeout if timeout is not None else 60 if httpx_client is None else None - ) + _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None self._client_wrapper = SyncClientWrapper( base_url=base_url, x_langfuse_sdk_name=x_langfuse_sdk_name, @@ -88,18 +84,14 @@ def __init__( password=password, httpx_client=httpx_client if httpx_client is not None - else httpx.Client( - timeout=_defaulted_timeout, follow_redirects=follow_redirects - ) + else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects) if follow_redirects is not None else httpx.Client(timeout=_defaulted_timeout), timeout=_defaulted_timeout, ) self.comments = CommentsClient(client_wrapper=self._client_wrapper) self.dataset_items = DatasetItemsClient(client_wrapper=self._client_wrapper) - self.dataset_run_items = DatasetRunItemsClient( - client_wrapper=self._client_wrapper - ) + self.dataset_run_items = DatasetRunItemsClient(client_wrapper=self._client_wrapper) self.datasets = DatasetsClient(client_wrapper=self._client_wrapper) self.health = HealthClient(client_wrapper=self._client_wrapper) self.ingestion = IngestionClient(client_wrapper=self._client_wrapper) @@ -108,6 +100,7 @@ def __init__( self.models = ModelsClient(client_wrapper=self._client_wrapper) self.observations = ObservationsClient(client_wrapper=self._client_wrapper) self.projects = ProjectsClient(client_wrapper=self._client_wrapper) + self.prompt_version = PromptVersionClient(client_wrapper=self._client_wrapper) self.prompts = PromptsClient(client_wrapper=self._client_wrapper) self.score_configs = ScoreConfigsClient(client_wrapper=self._client_wrapper) self.score = ScoreClient(client_wrapper=self._client_wrapper) @@ -163,11 +156,9 @@ def __init__( password: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, timeout: typing.Optional[float] = None, follow_redirects: typing.Optional[bool] = True, - httpx_client: typing.Optional[httpx.AsyncClient] = None, + httpx_client: typing.Optional[httpx.AsyncClient] = None ): - _defaulted_timeout = ( - timeout if timeout is not None else 60 if httpx_client is None else None - ) + _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None self._client_wrapper = AsyncClientWrapper( base_url=base_url, x_langfuse_sdk_name=x_langfuse_sdk_name, @@ -177,20 +168,14 @@ def __init__( password=password, httpx_client=httpx_client if httpx_client is not None - else httpx.AsyncClient( - timeout=_defaulted_timeout, follow_redirects=follow_redirects - ) + else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects) if follow_redirects is not None else httpx.AsyncClient(timeout=_defaulted_timeout), timeout=_defaulted_timeout, ) self.comments = AsyncCommentsClient(client_wrapper=self._client_wrapper) - self.dataset_items = AsyncDatasetItemsClient( - client_wrapper=self._client_wrapper - ) - self.dataset_run_items = AsyncDatasetRunItemsClient( - client_wrapper=self._client_wrapper - ) + self.dataset_items = AsyncDatasetItemsClient(client_wrapper=self._client_wrapper) + self.dataset_run_items = AsyncDatasetRunItemsClient(client_wrapper=self._client_wrapper) self.datasets = AsyncDatasetsClient(client_wrapper=self._client_wrapper) self.health = AsyncHealthClient(client_wrapper=self._client_wrapper) self.ingestion = AsyncIngestionClient(client_wrapper=self._client_wrapper) @@ -199,10 +184,9 @@ def __init__( self.models = AsyncModelsClient(client_wrapper=self._client_wrapper) self.observations = AsyncObservationsClient(client_wrapper=self._client_wrapper) self.projects = AsyncProjectsClient(client_wrapper=self._client_wrapper) + self.prompt_version = AsyncPromptVersionClient(client_wrapper=self._client_wrapper) self.prompts = AsyncPromptsClient(client_wrapper=self._client_wrapper) - self.score_configs = AsyncScoreConfigsClient( - client_wrapper=self._client_wrapper - ) + self.score_configs = AsyncScoreConfigsClient(client_wrapper=self._client_wrapper) self.score = AsyncScoreClient(client_wrapper=self._client_wrapper) self.sessions = AsyncSessionsClient(client_wrapper=self._client_wrapper) self.trace = AsyncTraceClient(client_wrapper=self._client_wrapper) diff --git a/langfuse/api/core/api_error.py b/langfuse/api/core/api_error.py index da734b580..2e9fc5431 100644 --- a/langfuse/api/core/api_error.py +++ b/langfuse/api/core/api_error.py @@ -7,9 +7,7 @@ class ApiError(Exception): status_code: typing.Optional[int] body: typing.Any - def __init__( - self, *, status_code: typing.Optional[int] = None, body: typing.Any = None - ): + def __init__(self, *, status_code: typing.Optional[int] = None, body: typing.Any = None): self.status_code = status_code self.body = body diff --git a/langfuse/api/core/client_wrapper.py b/langfuse/api/core/client_wrapper.py index 8a053f4a7..49932db6c 100644 --- a/langfuse/api/core/client_wrapper.py +++ b/langfuse/api/core/client_wrapper.py @@ -17,7 +17,7 @@ def __init__( username: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, password: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, base_url: str, - timeout: typing.Optional[float] = None, + timeout: typing.Optional[float] = None ): self._x_langfuse_sdk_name = x_langfuse_sdk_name self._x_langfuse_sdk_version = x_langfuse_sdk_version @@ -71,7 +71,7 @@ def __init__( password: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, base_url: str, timeout: typing.Optional[float] = None, - httpx_client: httpx.Client, + httpx_client: httpx.Client ): super().__init__( x_langfuse_sdk_name=x_langfuse_sdk_name, @@ -101,7 +101,7 @@ def __init__( password: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, base_url: str, timeout: typing.Optional[float] = None, - httpx_client: httpx.AsyncClient, + httpx_client: httpx.AsyncClient ): super().__init__( x_langfuse_sdk_name=x_langfuse_sdk_name, diff --git a/langfuse/api/core/datetime_utils.py b/langfuse/api/core/datetime_utils.py index 47344e9d9..7c9864a94 100644 --- a/langfuse/api/core/datetime_utils.py +++ b/langfuse/api/core/datetime_utils.py @@ -13,9 +13,7 @@ def serialize_datetime(v: dt.datetime) -> str: """ def _serialize_zoned_datetime(v: dt.datetime) -> str: - if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname( - None - ): + if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None): # UTC is a special case where we use "Z" at the end instead of "+00:00" return v.isoformat().replace("+00:00", "Z") else: diff --git a/langfuse/api/core/file.py b/langfuse/api/core/file.py index 6e0f92bfc..cb0d40bbb 100644 --- a/langfuse/api/core/file.py +++ b/langfuse/api/core/file.py @@ -13,17 +13,12 @@ # (filename, file (or bytes), content_type) typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str]], # (filename, file (or bytes), content_type, headers) - typing.Tuple[ - typing.Optional[str], - FileContent, - typing.Optional[str], - typing.Mapping[str, str], - ], + typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str], typing.Mapping[str, str]], ] def convert_file_dict_to_httpx_tuples( - d: typing.Dict[str, typing.Union[File, typing.List[File]]], + d: typing.Dict[str, typing.Union[File, typing.List[File]]] ) -> typing.List[typing.Tuple[str, File]]: """ The format we use is a list of tuples, where the first element is the diff --git a/langfuse/api/core/http_client.py b/langfuse/api/core/http_client.py index 091f71bc1..9333d8a7f 100644 --- a/langfuse/api/core/http_client.py +++ b/langfuse/api/core/http_client.py @@ -77,9 +77,7 @@ def _retry_timeout(response: httpx.Response, retries: int) -> float: return retry_after # Apply exponential backoff, capped at MAX_RETRY_DELAY_SECONDS. - retry_delay = min( - INITIAL_RETRY_DELAY_SECONDS * pow(2.0, retries), MAX_RETRY_DELAY_SECONDS - ) + retry_delay = min(INITIAL_RETRY_DELAY_SECONDS * pow(2.0, retries), MAX_RETRY_DELAY_SECONDS) # Add a randomness / jitter to the retry delay to avoid overwhelming the server with retries. timeout = retry_delay * (1 - 0.25 * random()) @@ -92,8 +90,7 @@ def _should_retry(response: httpx.Response) -> bool: def remove_omit_from_dict( - original: typing.Dict[str, typing.Optional[typing.Any]], - omit: typing.Optional[typing.Any], + original: typing.Dict[str, typing.Optional[typing.Any]], omit: typing.Optional[typing.Any] ) -> typing.Dict[str, typing.Any]: if omit is None: return original @@ -111,8 +108,7 @@ def maybe_filter_request_body( ) -> typing.Optional[typing.Any]: if data is None: return ( - jsonable_encoder(request_options.get("additional_body_parameters", {})) - or {} + jsonable_encoder(request_options.get("additional_body_parameters", {})) or {} if request_options is not None else None ) @@ -122,8 +118,7 @@ def maybe_filter_request_body( data_content = { **(jsonable_encoder(remove_omit_from_dict(data, omit))), # type: ignore **( - jsonable_encoder(request_options.get("additional_body_parameters", {})) - or {} + jsonable_encoder(request_options.get("additional_body_parameters", {})) or {} if request_options is not None else {} ), @@ -167,9 +162,7 @@ def __init__( def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str: base_url = self.base_url if maybe_base_url is None else maybe_base_url if base_url is None: - raise ValueError( - "A base_url is required to make this request, please provide one and try again." - ) + raise ValueError("A base_url is required to make this request, please provide one and try again.") return base_url def request( @@ -181,12 +174,8 @@ def request( params: typing.Optional[typing.Dict[str, typing.Any]] = None, json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, - content: typing.Optional[ - typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]] - ] = None, - files: typing.Optional[ - typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]] - ] = None, + content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, + files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, retries: int = 0, @@ -195,14 +184,11 @@ def request( base_url = self.get_base_url(base_url) timeout = ( request_options.get("timeout_in_seconds") - if request_options is not None - and request_options.get("timeout_in_seconds") is not None + if request_options is not None and request_options.get("timeout_in_seconds") is not None else self.base_timeout ) - json_body, data_body = get_request_body( - json=json, data=data, request_options=request_options, omit=omit - ) + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) response = self.httpx_client.request( method=method, @@ -212,11 +198,7 @@ def request( { **self.base_headers, **(headers if headers is not None else {}), - **( - request_options.get("additional_headers", {}) or {} - if request_options is not None - else {} - ), + **(request_options.get("additional_headers", {}) or {} if request_options is not None else {}), } ) ), @@ -227,10 +209,7 @@ def request( { **(params if params is not None else {}), **( - request_options.get( - "additional_query_parameters", {} - ) - or {} + request_options.get("additional_query_parameters", {}) or {} if request_options is not None else {} ), @@ -243,15 +222,11 @@ def request( json=json_body, data=data_body, content=content, - files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) - if files is not None - else None, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, timeout=timeout, ) - max_retries: int = ( - request_options.get("max_retries", 0) if request_options is not None else 0 - ) + max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0 if _should_retry(response=response): if max_retries > retries: time.sleep(_retry_timeout(response=response, retries=retries)) @@ -281,12 +256,8 @@ def stream( params: typing.Optional[typing.Dict[str, typing.Any]] = None, json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, - content: typing.Optional[ - typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]] - ] = None, - files: typing.Optional[ - typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]] - ] = None, + content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, + files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, retries: int = 0, @@ -295,14 +266,11 @@ def stream( base_url = self.get_base_url(base_url) timeout = ( request_options.get("timeout_in_seconds") - if request_options is not None - and request_options.get("timeout_in_seconds") is not None + if request_options is not None and request_options.get("timeout_in_seconds") is not None else self.base_timeout ) - json_body, data_body = get_request_body( - json=json, data=data, request_options=request_options, omit=omit - ) + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) with self.httpx_client.stream( method=method, @@ -312,11 +280,7 @@ def stream( { **self.base_headers, **(headers if headers is not None else {}), - **( - request_options.get("additional_headers", {}) - if request_options is not None - else {} - ), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), } ) ), @@ -327,9 +291,7 @@ def stream( { **(params if params is not None else {}), **( - request_options.get( - "additional_query_parameters", {} - ) + request_options.get("additional_query_parameters", {}) if request_options is not None else {} ), @@ -342,9 +304,7 @@ def stream( json=json_body, data=data_body, content=content, - files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) - if files is not None - else None, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, timeout=timeout, ) as stream: yield stream @@ -367,9 +327,7 @@ def __init__( def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str: base_url = self.base_url if maybe_base_url is None else maybe_base_url if base_url is None: - raise ValueError( - "A base_url is required to make this request, please provide one and try again." - ) + raise ValueError("A base_url is required to make this request, please provide one and try again.") return base_url async def request( @@ -381,12 +339,8 @@ async def request( params: typing.Optional[typing.Dict[str, typing.Any]] = None, json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, - content: typing.Optional[ - typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]] - ] = None, - files: typing.Optional[ - typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]] - ] = None, + content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, + files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, retries: int = 0, @@ -395,14 +349,11 @@ async def request( base_url = self.get_base_url(base_url) timeout = ( request_options.get("timeout_in_seconds") - if request_options is not None - and request_options.get("timeout_in_seconds") is not None + if request_options is not None and request_options.get("timeout_in_seconds") is not None else self.base_timeout ) - json_body, data_body = get_request_body( - json=json, data=data, request_options=request_options, omit=omit - ) + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) # Add the input to each of these and do None-safety checks response = await self.httpx_client.request( @@ -413,11 +364,7 @@ async def request( { **self.base_headers, **(headers if headers is not None else {}), - **( - request_options.get("additional_headers", {}) or {} - if request_options is not None - else {} - ), + **(request_options.get("additional_headers", {}) or {} if request_options is not None else {}), } ) ), @@ -428,10 +375,7 @@ async def request( { **(params if params is not None else {}), **( - request_options.get( - "additional_query_parameters", {} - ) - or {} + request_options.get("additional_query_parameters", {}) or {} if request_options is not None else {} ), @@ -444,15 +388,11 @@ async def request( json=json_body, data=data_body, content=content, - files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) - if files is not None - else None, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, timeout=timeout, ) - max_retries: int = ( - request_options.get("max_retries", 0) if request_options is not None else 0 - ) + max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0 if _should_retry(response=response): if max_retries > retries: await asyncio.sleep(_retry_timeout(response=response, retries=retries)) @@ -481,12 +421,8 @@ async def stream( params: typing.Optional[typing.Dict[str, typing.Any]] = None, json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, - content: typing.Optional[ - typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]] - ] = None, - files: typing.Optional[ - typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]] - ] = None, + content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, + files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, retries: int = 0, @@ -495,14 +431,11 @@ async def stream( base_url = self.get_base_url(base_url) timeout = ( request_options.get("timeout_in_seconds") - if request_options is not None - and request_options.get("timeout_in_seconds") is not None + if request_options is not None and request_options.get("timeout_in_seconds") is not None else self.base_timeout ) - json_body, data_body = get_request_body( - json=json, data=data, request_options=request_options, omit=omit - ) + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) async with self.httpx_client.stream( method=method, @@ -512,11 +445,7 @@ async def stream( { **self.base_headers, **(headers if headers is not None else {}), - **( - request_options.get("additional_headers", {}) - if request_options is not None - else {} - ), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), } ) ), @@ -527,9 +456,7 @@ async def stream( { **(params if params is not None else {}), **( - request_options.get( - "additional_query_parameters", {} - ) + request_options.get("additional_query_parameters", {}) if request_options is not None else {} ), @@ -542,9 +469,7 @@ async def stream( json=json_body, data=data_body, content=content, - files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) - if files is not None - else None, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, timeout=timeout, ) as stream: yield stream diff --git a/langfuse/api/core/jsonable_encoder.py b/langfuse/api/core/jsonable_encoder.py index 7a05e9190..f09aaf6b9 100644 --- a/langfuse/api/core/jsonable_encoder.py +++ b/langfuse/api/core/jsonable_encoder.py @@ -25,24 +25,18 @@ def generate_encoders_by_class_tuples( - type_encoder_map: Dict[Any, Callable[[Any], Any]], + type_encoder_map: Dict[Any, Callable[[Any], Any]] ) -> Dict[Callable[[Any], Any], Tuple[Any, ...]]: - encoders_by_class_tuples: Dict[Callable[[Any], Any], Tuple[Any, ...]] = defaultdict( - tuple - ) + encoders_by_class_tuples: Dict[Callable[[Any], Any], Tuple[Any, ...]] = defaultdict(tuple) for type_, encoder in type_encoder_map.items(): encoders_by_class_tuples[encoder] += (type_,) return encoders_by_class_tuples -encoders_by_class_tuples = generate_encoders_by_class_tuples( - pydantic_v1.json.ENCODERS_BY_TYPE -) +encoders_by_class_tuples = generate_encoders_by_class_tuples(pydantic_v1.json.ENCODERS_BY_TYPE) -def jsonable_encoder( - obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None -) -> Any: +def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any: custom_encoder = custom_encoder or {} if custom_encoder: if type(obj) in custom_encoder: diff --git a/langfuse/api/core/query_encoder.py b/langfuse/api/core/query_encoder.py index 069633086..1f5f766b4 100644 --- a/langfuse/api/core/query_encoder.py +++ b/langfuse/api/core/query_encoder.py @@ -7,9 +7,7 @@ # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict( - dict_flat: Dict[str, Any], key_prefix: Optional[str] = None -) -> Dict[str, Any]: +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: result = {} for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k @@ -32,8 +30,4 @@ def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return ( - dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) - if query is not None - else None - ) + return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None diff --git a/langfuse/api/reference.md b/langfuse/api/reference.md index 37683e9f7..2694bac8c 100644 --- a/langfuse/api/reference.md +++ b/langfuse/api/reference.md @@ -2237,6 +2237,100 @@ client.projects.get() + + + + +## PromptVersion +
client.prompt_version.update(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update labels for a specific prompt version +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from langfuse.client import FernLangfuse + +client = FernLangfuse( + x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", + x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", + x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", + username="YOUR_USERNAME", + password="YOUR_PASSWORD", + base_url="https://yourhost.com/path/to/api", +) +client.prompt_version.update( + prompt_name="string", + version=1, + new_labels=["string"], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**prompt_name:** `str` — The name of the prompt + +
+
+ +
+
+ +**version:** `int` — Version of the prompt to update + +
+
+ +
+
+ +**new_labels:** `typing.Sequence[str]` — New labels for the prompt version. Labels are unique across versions. The "latest" label is reserved and managed by Langfuse. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
diff --git a/langfuse/api/resources/__init__.py b/langfuse/api/resources/__init__.py index f838c2f8c..80ce7dead 100644 --- a/langfuse/api/resources/__init__.py +++ b/langfuse/api/resources/__init__.py @@ -13,6 +13,7 @@ models, observations, projects, + prompt_version, prompts, score, score_configs, @@ -23,9 +24,12 @@ from .comments import CreateCommentRequest, CreateCommentResponse, GetCommentsResponse from .commons import ( AccessDeniedError, + BasePrompt, BaseScore, BooleanScore, CategoricalScore, + ChatMessage, + ChatPrompt, Comment, CommentObjectType, ConfigCategory, @@ -46,6 +50,9 @@ Observation, ObservationLevel, ObservationsView, + Prompt, + Prompt_Chat, + Prompt_Text, Score, ScoreConfig, ScoreDataType, @@ -55,6 +62,7 @@ Score_Numeric, Session, SessionWithTraces, + TextPrompt, Trace, TraceWithDetails, TraceWithFullDetails, @@ -120,20 +128,13 @@ from .observations import Observations, ObservationsViews from .projects import Project, Projects from .prompts import ( - BasePrompt, - ChatMessage, - ChatPrompt, CreateChatPromptRequest, CreatePromptRequest, CreatePromptRequest_Chat, CreatePromptRequest_Text, CreateTextPromptRequest, - Prompt, PromptMeta, PromptMetaListResponse, - Prompt_Chat, - Prompt_Text, - TextPrompt, ) from .score import ( CreateScoreRequest, @@ -299,6 +300,7 @@ "models", "observations", "projects", + "prompt_version", "prompts", "score", "score_configs", diff --git a/langfuse/api/resources/comments/client.py b/langfuse/api/resources/comments/client.py index 9d84948a3..83e06cf4f 100644 --- a/langfuse/api/resources/comments/client.py +++ b/langfuse/api/resources/comments/client.py @@ -27,10 +27,7 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def create( - self, - *, - request: CreateCommentRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreateCommentRequest, request_options: typing.Optional[RequestOptions] = None ) -> CreateCommentResponse: """ Create a comment. Comments may be attached to different object types (trace, observation, session, prompt). @@ -70,11 +67,7 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/comments", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/comments", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -82,21 +75,13 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -177,32 +162,19 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def get_by_id( - self, - comment_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> Comment: + def get_by_id(self, comment_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Comment: """ Get a comment by id @@ -235,9 +207,7 @@ def get_by_id( ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/comments/{jsonable_encoder(comment_id)}", - method="GET", - request_options=request_options, + f"api/public/comments/{jsonable_encoder(comment_id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -245,21 +215,13 @@ def get_by_id( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -271,10 +233,7 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def create( - self, - *, - request: CreateCommentRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreateCommentRequest, request_options: typing.Optional[RequestOptions] = None ) -> CreateCommentResponse: """ Create a comment. Comments may be attached to different object types (trace, observation, session, prompt). @@ -322,11 +281,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/comments", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/comments", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -334,21 +289,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -437,32 +384,19 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def get_by_id( - self, - comment_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> Comment: + async def get_by_id(self, comment_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Comment: """ Get a comment by id @@ -503,9 +437,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/comments/{jsonable_encoder(comment_id)}", - method="GET", - request_options=request_options, + f"api/public/comments/{jsonable_encoder(comment_id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -513,21 +445,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/comments/types/create_comment_request.py b/langfuse/api/resources/comments/types/create_comment_request.py index 9ba6081ee..2d8baf79a 100644 --- a/langfuse/api/resources/comments/types/create_comment_request.py +++ b/langfuse/api/resources/comments/types/create_comment_request.py @@ -28,36 +28,21 @@ class CreateCommentRequest(pydantic_v1.BaseModel): The content of the comment. May include markdown. Currently limited to 3000 characters. """ - author_user_id: typing.Optional[str] = pydantic_v1.Field( - alias="authorUserId", default=None - ) + author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) """ The id of the user who created the comment. """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/comments/types/create_comment_response.py b/langfuse/api/resources/comments/types/create_comment_response.py index d7708f798..3bd2ac616 100644 --- a/langfuse/api/resources/comments/types/create_comment_response.py +++ b/langfuse/api/resources/comments/types/create_comment_response.py @@ -14,28 +14,15 @@ class CreateCommentResponse(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/comments/types/get_comments_response.py b/langfuse/api/resources/comments/types/get_comments_response.py index 66a8b9527..a52d5e0b1 100644 --- a/langfuse/api/resources/comments/types/get_comments_response.py +++ b/langfuse/api/resources/comments/types/get_comments_response.py @@ -14,28 +14,15 @@ class GetCommentsResponse(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/__init__.py b/langfuse/api/resources/commons/__init__.py index e3e919f41..f55e7c3c1 100644 --- a/langfuse/api/resources/commons/__init__.py +++ b/langfuse/api/resources/commons/__init__.py @@ -1,9 +1,12 @@ # This file was auto-generated by Fern from our API Definition. from .types import ( + BasePrompt, BaseScore, BooleanScore, CategoricalScore, + ChatMessage, + ChatPrompt, Comment, CommentObjectType, ConfigCategory, @@ -21,6 +24,9 @@ Observation, ObservationLevel, ObservationsView, + Prompt, + Prompt_Chat, + Prompt_Text, Score, ScoreConfig, ScoreDataType, @@ -30,24 +36,22 @@ Score_Numeric, Session, SessionWithTraces, + TextPrompt, Trace, TraceWithDetails, TraceWithFullDetails, Usage, ) -from .errors import ( - AccessDeniedError, - Error, - MethodNotAllowedError, - NotFoundError, - UnauthorizedError, -) +from .errors import AccessDeniedError, Error, MethodNotAllowedError, NotFoundError, UnauthorizedError __all__ = [ "AccessDeniedError", + "BasePrompt", "BaseScore", "BooleanScore", "CategoricalScore", + "ChatMessage", + "ChatPrompt", "Comment", "CommentObjectType", "ConfigCategory", @@ -68,6 +72,9 @@ "Observation", "ObservationLevel", "ObservationsView", + "Prompt", + "Prompt_Chat", + "Prompt_Text", "Score", "ScoreConfig", "ScoreDataType", @@ -77,6 +84,7 @@ "Score_Numeric", "Session", "SessionWithTraces", + "TextPrompt", "Trace", "TraceWithDetails", "TraceWithFullDetails", diff --git a/langfuse/api/resources/commons/errors/__init__.py b/langfuse/api/resources/commons/errors/__init__.py index 0aef2f92f..eb5a67925 100644 --- a/langfuse/api/resources/commons/errors/__init__.py +++ b/langfuse/api/resources/commons/errors/__init__.py @@ -6,10 +6,4 @@ from .not_found_error import NotFoundError from .unauthorized_error import UnauthorizedError -__all__ = [ - "AccessDeniedError", - "Error", - "MethodNotAllowedError", - "NotFoundError", - "UnauthorizedError", -] +__all__ = ["AccessDeniedError", "Error", "MethodNotAllowedError", "NotFoundError", "UnauthorizedError"] diff --git a/langfuse/api/resources/commons/types/__init__.py b/langfuse/api/resources/commons/types/__init__.py index fcec85214..56c0f5d78 100644 --- a/langfuse/api/resources/commons/types/__init__.py +++ b/langfuse/api/resources/commons/types/__init__.py @@ -1,8 +1,11 @@ # This file was auto-generated by Fern from our API Definition. +from .base_prompt import BasePrompt from .base_score import BaseScore from .boolean_score import BooleanScore from .categorical_score import CategoricalScore +from .chat_message import ChatMessage +from .chat_prompt import ChatPrompt from .comment import Comment from .comment_object_type import CommentObjectType from .config_category import ConfigCategory @@ -20,21 +23,26 @@ from .observation import Observation from .observation_level import ObservationLevel from .observations_view import ObservationsView +from .prompt import Prompt, Prompt_Chat, Prompt_Text from .score import Score, Score_Boolean, Score_Categorical, Score_Numeric from .score_config import ScoreConfig from .score_data_type import ScoreDataType from .score_source import ScoreSource from .session import Session from .session_with_traces import SessionWithTraces +from .text_prompt import TextPrompt from .trace import Trace from .trace_with_details import TraceWithDetails from .trace_with_full_details import TraceWithFullDetails from .usage import Usage __all__ = [ + "BasePrompt", "BaseScore", "BooleanScore", "CategoricalScore", + "ChatMessage", + "ChatPrompt", "Comment", "CommentObjectType", "ConfigCategory", @@ -52,6 +60,9 @@ "Observation", "ObservationLevel", "ObservationsView", + "Prompt", + "Prompt_Chat", + "Prompt_Text", "Score", "ScoreConfig", "ScoreDataType", @@ -61,6 +72,7 @@ "Score_Numeric", "Session", "SessionWithTraces", + "TextPrompt", "Trace", "TraceWithDetails", "TraceWithFullDetails", diff --git a/langfuse/api/resources/prompts/types/base_prompt.py b/langfuse/api/resources/commons/types/base_prompt.py similarity index 63% rename from langfuse/api/resources/prompts/types/base_prompt.py rename to langfuse/api/resources/commons/types/base_prompt.py index 82934fbe6..2192f8b28 100644 --- a/langfuse/api/resources/prompts/types/base_prompt.py +++ b/langfuse/api/resources/commons/types/base_prompt.py @@ -22,28 +22,15 @@ class BasePrompt(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/base_score.py b/langfuse/api/resources/commons/types/base_score.py index 71bed6ef4..f623ae909 100644 --- a/langfuse/api/resources/commons/types/base_score.py +++ b/langfuse/api/resources/commons/types/base_score.py @@ -13,15 +13,11 @@ class BaseScore(pydantic_v1.BaseModel): trace_id: str = pydantic_v1.Field(alias="traceId") name: str source: ScoreSource - observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="observationId", default=None - ) + observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) timestamp: dt.datetime created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") - author_user_id: typing.Optional[str] = pydantic_v1.Field( - alias="authorUserId", default=None - ) + author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) comment: typing.Optional[str] = None config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) """ @@ -34,28 +30,15 @@ class BaseScore(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/boolean_score.py b/langfuse/api/resources/commons/types/boolean_score.py index d838b7db9..7a97a9337 100644 --- a/langfuse/api/resources/commons/types/boolean_score.py +++ b/langfuse/api/resources/commons/types/boolean_score.py @@ -20,28 +20,15 @@ class BooleanScore(BaseScore): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/categorical_score.py b/langfuse/api/resources/commons/types/categorical_score.py index 847caf47b..2bc86cb32 100644 --- a/langfuse/api/resources/commons/types/categorical_score.py +++ b/langfuse/api/resources/commons/types/categorical_score.py @@ -20,28 +20,15 @@ class CategoricalScore(BaseScore): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/prompts/types/chat_message.py b/langfuse/api/resources/commons/types/chat_message.py similarity index 54% rename from langfuse/api/resources/prompts/types/chat_message.py rename to langfuse/api/resources/commons/types/chat_message.py index d009bc8cf..d97ea60a1 100644 --- a/langfuse/api/resources/prompts/types/chat_message.py +++ b/langfuse/api/resources/commons/types/chat_message.py @@ -12,28 +12,15 @@ class ChatMessage(pydantic_v1.BaseModel): content: str def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/prompts/types/chat_prompt.py b/langfuse/api/resources/commons/types/chat_prompt.py similarity index 59% rename from langfuse/api/resources/prompts/types/chat_prompt.py rename to langfuse/api/resources/commons/types/chat_prompt.py index 7699d288d..127b7ffa5 100644 --- a/langfuse/api/resources/prompts/types/chat_prompt.py +++ b/langfuse/api/resources/commons/types/chat_prompt.py @@ -13,28 +13,15 @@ class ChatPrompt(BasePrompt): prompt: typing.List[ChatMessage] def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/comment.py b/langfuse/api/resources/commons/types/comment.py index 4d8b1916a..6ad563fdf 100644 --- a/langfuse/api/resources/commons/types/comment.py +++ b/langfuse/api/resources/commons/types/comment.py @@ -16,33 +16,18 @@ class Comment(pydantic_v1.BaseModel): object_type: CommentObjectType = pydantic_v1.Field(alias="objectType") object_id: str = pydantic_v1.Field(alias="objectId") content: str - author_user_id: typing.Optional[str] = pydantic_v1.Field( - alias="authorUserId", default=None - ) + author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/config_category.py b/langfuse/api/resources/commons/types/config_category.py index b1cbde9f2..7455c70a0 100644 --- a/langfuse/api/resources/commons/types/config_category.py +++ b/langfuse/api/resources/commons/types/config_category.py @@ -12,28 +12,15 @@ class ConfigCategory(pydantic_v1.BaseModel): label: str def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/dataset.py b/langfuse/api/resources/commons/types/dataset.py index be59a951a..abc35a168 100644 --- a/langfuse/api/resources/commons/types/dataset.py +++ b/langfuse/api/resources/commons/types/dataset.py @@ -17,28 +17,15 @@ class Dataset(pydantic_v1.BaseModel): updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/dataset_item.py b/langfuse/api/resources/commons/types/dataset_item.py index dd5f85e78..9a34107a8 100644 --- a/langfuse/api/resources/commons/types/dataset_item.py +++ b/langfuse/api/resources/commons/types/dataset_item.py @@ -12,44 +12,25 @@ class DatasetItem(pydantic_v1.BaseModel): id: str status: DatasetStatus input: typing.Optional[typing.Any] = None - expected_output: typing.Optional[typing.Any] = pydantic_v1.Field( - alias="expectedOutput", default=None - ) + expected_output: typing.Optional[typing.Any] = pydantic_v1.Field(alias="expectedOutput", default=None) metadata: typing.Optional[typing.Any] = None - source_trace_id: typing.Optional[str] = pydantic_v1.Field( - alias="sourceTraceId", default=None - ) - source_observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="sourceObservationId", default=None - ) + source_trace_id: typing.Optional[str] = pydantic_v1.Field(alias="sourceTraceId", default=None) + source_observation_id: typing.Optional[str] = pydantic_v1.Field(alias="sourceObservationId", default=None) dataset_id: str = pydantic_v1.Field(alias="datasetId") dataset_name: str = pydantic_v1.Field(alias="datasetName") created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/dataset_run.py b/langfuse/api/resources/commons/types/dataset_run.py index 74b1a2ac8..7fc733ff7 100644 --- a/langfuse/api/resources/commons/types/dataset_run.py +++ b/langfuse/api/resources/commons/types/dataset_run.py @@ -49,28 +49,15 @@ class DatasetRun(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/dataset_run_item.py b/langfuse/api/resources/commons/types/dataset_run_item.py index f1b3af163..683c055df 100644 --- a/langfuse/api/resources/commons/types/dataset_run_item.py +++ b/langfuse/api/resources/commons/types/dataset_run_item.py @@ -13,35 +13,20 @@ class DatasetRunItem(pydantic_v1.BaseModel): dataset_run_name: str = pydantic_v1.Field(alias="datasetRunName") dataset_item_id: str = pydantic_v1.Field(alias="datasetItemId") trace_id: str = pydantic_v1.Field(alias="traceId") - observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="observationId", default=None - ) + observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/dataset_run_with_items.py b/langfuse/api/resources/commons/types/dataset_run_with_items.py index 647d2c553..0179bea39 100644 --- a/langfuse/api/resources/commons/types/dataset_run_with_items.py +++ b/langfuse/api/resources/commons/types/dataset_run_with_items.py @@ -10,33 +10,18 @@ class DatasetRunWithItems(DatasetRun): - dataset_run_items: typing.List[DatasetRunItem] = pydantic_v1.Field( - alias="datasetRunItems" - ) + dataset_run_items: typing.List[DatasetRunItem] = pydantic_v1.Field(alias="datasetRunItems") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/dataset_status.py b/langfuse/api/resources/commons/types/dataset_status.py index 09eac62fe..50b636851 100644 --- a/langfuse/api/resources/commons/types/dataset_status.py +++ b/langfuse/api/resources/commons/types/dataset_status.py @@ -10,11 +10,7 @@ class DatasetStatus(str, enum.Enum): ACTIVE = "ACTIVE" ARCHIVED = "ARCHIVED" - def visit( - self, - active: typing.Callable[[], T_Result], - archived: typing.Callable[[], T_Result], - ) -> T_Result: + def visit(self, active: typing.Callable[[], T_Result], archived: typing.Callable[[], T_Result]) -> T_Result: if self is DatasetStatus.ACTIVE: return active() if self is DatasetStatus.ARCHIVED: diff --git a/langfuse/api/resources/commons/types/map_value.py b/langfuse/api/resources/commons/types/map_value.py index e1e771a9b..aebdb7f97 100644 --- a/langfuse/api/resources/commons/types/map_value.py +++ b/langfuse/api/resources/commons/types/map_value.py @@ -3,8 +3,5 @@ import typing MapValue = typing.Union[ - typing.Optional[str], - typing.Optional[int], - typing.Optional[bool], - typing.Optional[typing.List[str]], + typing.Optional[str], typing.Optional[int], typing.Optional[bool], typing.Optional[typing.List[str]] ] diff --git a/langfuse/api/resources/commons/types/model.py b/langfuse/api/resources/commons/types/model.py index 54cb26bc8..100c39246 100644 --- a/langfuse/api/resources/commons/types/model.py +++ b/langfuse/api/resources/commons/types/model.py @@ -24,9 +24,7 @@ class Model(pydantic_v1.BaseModel): Regex pattern which matches this model definition to generation.model. Useful in case of fine-tuned models. If you want to exact match, use `(?i)^modelname$` """ - start_date: typing.Optional[dt.datetime] = pydantic_v1.Field( - alias="startDate", default=None - ) + start_date: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="startDate", default=None) """ Apply only to generations which are newer than this ISO date. """ @@ -36,37 +34,27 @@ class Model(pydantic_v1.BaseModel): Unit used by this model. """ - input_price: typing.Optional[float] = pydantic_v1.Field( - alias="inputPrice", default=None - ) + input_price: typing.Optional[float] = pydantic_v1.Field(alias="inputPrice", default=None) """ Price (USD) per input unit """ - output_price: typing.Optional[float] = pydantic_v1.Field( - alias="outputPrice", default=None - ) + output_price: typing.Optional[float] = pydantic_v1.Field(alias="outputPrice", default=None) """ Price (USD) per output unit """ - total_price: typing.Optional[float] = pydantic_v1.Field( - alias="totalPrice", default=None - ) + total_price: typing.Optional[float] = pydantic_v1.Field(alias="totalPrice", default=None) """ Price (USD) per total unit. Cannot be set if input or output price is set. """ - tokenizer_id: typing.Optional[str] = pydantic_v1.Field( - alias="tokenizerId", default=None - ) + tokenizer_id: typing.Optional[str] = pydantic_v1.Field(alias="tokenizerId", default=None) """ Optional. Tokenizer to be applied to observations which match to this model. See docs for more details. """ - tokenizer_config: typing.Optional[typing.Any] = pydantic_v1.Field( - alias="tokenizerConfig", default=None - ) + tokenizer_config: typing.Optional[typing.Any] = pydantic_v1.Field(alias="tokenizerConfig", default=None) """ Optional. Configuration for the selected tokenizer. Needs to be JSON. See docs for more details. """ @@ -74,28 +62,15 @@ class Model(pydantic_v1.BaseModel): is_langfuse_managed: bool = pydantic_v1.Field(alias="isLangfuseManaged") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/numeric_score.py b/langfuse/api/resources/commons/types/numeric_score.py index d7f860cd5..188191dd1 100644 --- a/langfuse/api/resources/commons/types/numeric_score.py +++ b/langfuse/api/resources/commons/types/numeric_score.py @@ -15,28 +15,15 @@ class NumericScore(BaseScore): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/observation.py b/langfuse/api/resources/commons/types/observation.py index 93fabb754..da83194bd 100644 --- a/langfuse/api/resources/commons/types/observation.py +++ b/langfuse/api/resources/commons/types/observation.py @@ -36,16 +36,12 @@ class Observation(pydantic_v1.BaseModel): The start time of the observation """ - end_time: typing.Optional[dt.datetime] = pydantic_v1.Field( - alias="endTime", default=None - ) + end_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="endTime", default=None) """ The end time of the observation. """ - completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field( - alias="completionStartTime", default=None - ) + completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="completionStartTime", default=None) """ The completion start time of the observation """ @@ -92,16 +88,12 @@ class Observation(pydantic_v1.BaseModel): The level of the observation """ - status_message: typing.Optional[str] = pydantic_v1.Field( - alias="statusMessage", default=None - ) + status_message: typing.Optional[str] = pydantic_v1.Field(alias="statusMessage", default=None) """ The status message of the observation """ - parent_observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="parentObservationId", default=None - ) + parent_observation_id: typing.Optional[str] = pydantic_v1.Field(alias="parentObservationId", default=None) """ The parent observation ID """ @@ -111,43 +103,26 @@ class Observation(pydantic_v1.BaseModel): The prompt ID associated with the observation """ - usage_details: typing.Optional[typing.Dict[str, int]] = pydantic_v1.Field( - alias="usageDetails", default=None - ) + usage_details: typing.Optional[typing.Dict[str, int]] = pydantic_v1.Field(alias="usageDetails", default=None) """ The usage details of the observation. Key is the name of the usage metric, value is the number of units consumed. The total key is the sum of all (non-total) usage metrics or the total value ingested. """ - cost_details: typing.Optional[typing.Dict[str, float]] = pydantic_v1.Field( - alias="costDetails", default=None - ) + cost_details: typing.Optional[typing.Dict[str, float]] = pydantic_v1.Field(alias="costDetails", default=None) """ The cost details of the observation. Key is the name of the cost metric, value is the cost in USD. The total key is the sum of all (non-total) cost metrics or the total value ingested. """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/observations_view.py b/langfuse/api/resources/commons/types/observations_view.py index e011fa32b..8ab3869cb 100644 --- a/langfuse/api/resources/commons/types/observations_view.py +++ b/langfuse/api/resources/commons/types/observations_view.py @@ -9,16 +9,12 @@ class ObservationsView(Observation): - prompt_name: typing.Optional[str] = pydantic_v1.Field( - alias="promptName", default=None - ) + prompt_name: typing.Optional[str] = pydantic_v1.Field(alias="promptName", default=None) """ The name of the prompt associated with the observation """ - prompt_version: typing.Optional[int] = pydantic_v1.Field( - alias="promptVersion", default=None - ) + prompt_version: typing.Optional[int] = pydantic_v1.Field(alias="promptVersion", default=None) """ The version of the prompt associated with the observation """ @@ -28,44 +24,32 @@ class ObservationsView(Observation): The unique identifier of the model """ - input_price: typing.Optional[float] = pydantic_v1.Field( - alias="inputPrice", default=None - ) + input_price: typing.Optional[float] = pydantic_v1.Field(alias="inputPrice", default=None) """ The price of the input in USD """ - output_price: typing.Optional[float] = pydantic_v1.Field( - alias="outputPrice", default=None - ) + output_price: typing.Optional[float] = pydantic_v1.Field(alias="outputPrice", default=None) """ The price of the output in USD. """ - total_price: typing.Optional[float] = pydantic_v1.Field( - alias="totalPrice", default=None - ) + total_price: typing.Optional[float] = pydantic_v1.Field(alias="totalPrice", default=None) """ The total price in USD. """ - calculated_input_cost: typing.Optional[float] = pydantic_v1.Field( - alias="calculatedInputCost", default=None - ) + calculated_input_cost: typing.Optional[float] = pydantic_v1.Field(alias="calculatedInputCost", default=None) """ (Deprecated. Use usageDetails and costDetails instead.) The calculated cost of the input in USD """ - calculated_output_cost: typing.Optional[float] = pydantic_v1.Field( - alias="calculatedOutputCost", default=None - ) + calculated_output_cost: typing.Optional[float] = pydantic_v1.Field(alias="calculatedOutputCost", default=None) """ (Deprecated. Use usageDetails and costDetails instead.) The calculated cost of the output in USD """ - calculated_total_cost: typing.Optional[float] = pydantic_v1.Field( - alias="calculatedTotalCost", default=None - ) + calculated_total_cost: typing.Optional[float] = pydantic_v1.Field(alias="calculatedTotalCost", default=None) """ (Deprecated. Use usageDetails and costDetails instead.) The calculated total cost in USD """ @@ -75,36 +59,21 @@ class ObservationsView(Observation): The latency in seconds. """ - time_to_first_token: typing.Optional[float] = pydantic_v1.Field( - alias="timeToFirstToken", default=None - ) + time_to_first_token: typing.Optional[float] = pydantic_v1.Field(alias="timeToFirstToken", default=None) """ The time to the first token in seconds """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/prompts/types/prompt.py b/langfuse/api/resources/commons/types/prompt.py similarity index 57% rename from langfuse/api/resources/prompts/types/prompt.py rename to langfuse/api/resources/commons/types/prompt.py index 90ba3447f..0f96fe7c4 100644 --- a/langfuse/api/resources/prompts/types/prompt.py +++ b/langfuse/api/resources/commons/types/prompt.py @@ -20,28 +20,15 @@ class Prompt_Chat(pydantic_v1.BaseModel): type: typing.Literal["chat"] = "chat" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -61,28 +48,15 @@ class Prompt_Text(pydantic_v1.BaseModel): type: typing.Literal["text"] = "text" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/score.py b/langfuse/api/resources/commons/types/score.py index e39221084..6ae9e1fc9 100644 --- a/langfuse/api/resources/commons/types/score.py +++ b/langfuse/api/resources/commons/types/score.py @@ -16,45 +16,26 @@ class Score_Numeric(pydantic_v1.BaseModel): trace_id: str = pydantic_v1.Field(alias="traceId") name: str source: ScoreSource - observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="observationId", default=None - ) + observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) timestamp: dt.datetime created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") - author_user_id: typing.Optional[str] = pydantic_v1.Field( - alias="authorUserId", default=None - ) + author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) comment: typing.Optional[str] = None config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) - data_type: typing.Literal["NUMERIC"] = pydantic_v1.Field( - alias="dataType", default="NUMERIC" - ) + data_type: typing.Literal["NUMERIC"] = pydantic_v1.Field(alias="dataType", default="NUMERIC") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -73,45 +54,26 @@ class Score_Categorical(pydantic_v1.BaseModel): trace_id: str = pydantic_v1.Field(alias="traceId") name: str source: ScoreSource - observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="observationId", default=None - ) + observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) timestamp: dt.datetime created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") - author_user_id: typing.Optional[str] = pydantic_v1.Field( - alias="authorUserId", default=None - ) + author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) comment: typing.Optional[str] = None config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) - data_type: typing.Literal["CATEGORICAL"] = pydantic_v1.Field( - alias="dataType", default="CATEGORICAL" - ) + data_type: typing.Literal["CATEGORICAL"] = pydantic_v1.Field(alias="dataType", default="CATEGORICAL") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -130,45 +92,26 @@ class Score_Boolean(pydantic_v1.BaseModel): trace_id: str = pydantic_v1.Field(alias="traceId") name: str source: ScoreSource - observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="observationId", default=None - ) + observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) timestamp: dt.datetime created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") - author_user_id: typing.Optional[str] = pydantic_v1.Field( - alias="authorUserId", default=None - ) + author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) comment: typing.Optional[str] = None config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) - data_type: typing.Literal["BOOLEAN"] = pydantic_v1.Field( - alias="dataType", default="BOOLEAN" - ) + data_type: typing.Literal["BOOLEAN"] = pydantic_v1.Field(alias="dataType", default="BOOLEAN") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/score_config.py b/langfuse/api/resources/commons/types/score_config.py index 4a7b30e0e..f31fefc5c 100644 --- a/langfuse/api/resources/commons/types/score_config.py +++ b/langfuse/api/resources/commons/types/score_config.py @@ -25,23 +25,17 @@ class ScoreConfig(pydantic_v1.BaseModel): Whether the score config is archived. Defaults to false """ - min_value: typing.Optional[float] = pydantic_v1.Field( - alias="minValue", default=None - ) + min_value: typing.Optional[float] = pydantic_v1.Field(alias="minValue", default=None) """ Sets minimum value for numerical scores. If not set, the minimum value defaults to -∞ """ - max_value: typing.Optional[float] = pydantic_v1.Field( - alias="maxValue", default=None - ) + max_value: typing.Optional[float] = pydantic_v1.Field(alias="maxValue", default=None) """ Sets maximum value for numerical scores. If not set, the maximum value defaults to +∞ """ - categories: typing.Optional[typing.List[ConfigCategory]] = pydantic_v1.Field( - default=None - ) + categories: typing.Optional[typing.List[ConfigCategory]] = pydantic_v1.Field(default=None) """ Configures custom categories for categorical scores """ @@ -49,28 +43,15 @@ class ScoreConfig(pydantic_v1.BaseModel): description: typing.Optional[str] = None def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/session.py b/langfuse/api/resources/commons/types/session.py index 230bf004b..8b5bf1556 100644 --- a/langfuse/api/resources/commons/types/session.py +++ b/langfuse/api/resources/commons/types/session.py @@ -13,28 +13,15 @@ class Session(pydantic_v1.BaseModel): project_id: str = pydantic_v1.Field(alias="projectId") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/session_with_traces.py b/langfuse/api/resources/commons/types/session_with_traces.py index b5465daa9..d1cfa1808 100644 --- a/langfuse/api/resources/commons/types/session_with_traces.py +++ b/langfuse/api/resources/commons/types/session_with_traces.py @@ -13,28 +13,15 @@ class SessionWithTraces(Session): traces: typing.List[Trace] def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/prompts/types/text_prompt.py b/langfuse/api/resources/commons/types/text_prompt.py similarity index 57% rename from langfuse/api/resources/prompts/types/text_prompt.py rename to langfuse/api/resources/commons/types/text_prompt.py index e149ea322..6c3d1f3d2 100644 --- a/langfuse/api/resources/prompts/types/text_prompt.py +++ b/langfuse/api/resources/commons/types/text_prompt.py @@ -12,28 +12,15 @@ class TextPrompt(BasePrompt): prompt: str def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/trace.py b/langfuse/api/resources/commons/types/trace.py index 9c9be5ae8..b180518d3 100644 --- a/langfuse/api/resources/commons/types/trace.py +++ b/langfuse/api/resources/commons/types/trace.py @@ -33,9 +33,7 @@ class Trace(pydantic_v1.BaseModel): The output data of the trace. Can be any JSON. """ - session_id: typing.Optional[str] = pydantic_v1.Field( - alias="sessionId", default=None - ) + session_id: typing.Optional[str] = pydantic_v1.Field(alias="sessionId", default=None) """ The session identifier associated with the trace """ @@ -71,28 +69,15 @@ class Trace(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/trace_with_details.py b/langfuse/api/resources/commons/types/trace_with_details.py index 5ffe6f218..5aba777f3 100644 --- a/langfuse/api/resources/commons/types/trace_with_details.py +++ b/langfuse/api/resources/commons/types/trace_with_details.py @@ -35,28 +35,15 @@ class TraceWithDetails(Trace): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/trace_with_full_details.py b/langfuse/api/resources/commons/types/trace_with_full_details.py index c96258d73..0f6b7bb0b 100644 --- a/langfuse/api/resources/commons/types/trace_with_full_details.py +++ b/langfuse/api/resources/commons/types/trace_with_full_details.py @@ -37,28 +37,15 @@ class TraceWithFullDetails(Trace): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/commons/types/usage.py b/langfuse/api/resources/commons/types/usage.py index c38330494..747958dd5 100644 --- a/langfuse/api/resources/commons/types/usage.py +++ b/langfuse/api/resources/commons/types/usage.py @@ -29,50 +29,31 @@ class Usage(pydantic_v1.BaseModel): """ unit: typing.Optional[ModelUsageUnit] = None - input_cost: typing.Optional[float] = pydantic_v1.Field( - alias="inputCost", default=None - ) + input_cost: typing.Optional[float] = pydantic_v1.Field(alias="inputCost", default=None) """ USD input cost """ - output_cost: typing.Optional[float] = pydantic_v1.Field( - alias="outputCost", default=None - ) + output_cost: typing.Optional[float] = pydantic_v1.Field(alias="outputCost", default=None) """ USD output cost """ - total_cost: typing.Optional[float] = pydantic_v1.Field( - alias="totalCost", default=None - ) + total_cost: typing.Optional[float] = pydantic_v1.Field(alias="totalCost", default=None) """ USD total cost, defaults to input+output """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/dataset_items/client.py b/langfuse/api/resources/dataset_items/client.py index 7cab6f51c..66a64afc9 100644 --- a/langfuse/api/resources/dataset_items/client.py +++ b/langfuse/api/resources/dataset_items/client.py @@ -26,10 +26,7 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def create( - self, - *, - request: CreateDatasetItemRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreateDatasetItemRequest, request_options: typing.Optional[RequestOptions] = None ) -> DatasetItem: """ Create a dataset item @@ -72,11 +69,7 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/dataset-items", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/dataset-items", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -84,29 +77,19 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def get( - self, id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> DatasetItem: + def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DatasetItem: """ Get a dataset item @@ -138,9 +121,7 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/dataset-items/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, + f"api/public/dataset-items/{jsonable_encoder(id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -148,21 +129,13 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -240,21 +213,13 @@ def list( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -266,10 +231,7 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def create( - self, - *, - request: CreateDatasetItemRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreateDatasetItemRequest, request_options: typing.Optional[RequestOptions] = None ) -> DatasetItem: """ Create a dataset item @@ -320,11 +282,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/dataset-items", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/dataset-items", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -332,29 +290,19 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def get( - self, id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> DatasetItem: + async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DatasetItem: """ Get a dataset item @@ -394,9 +342,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/dataset-items/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, + f"api/public/dataset-items/{jsonable_encoder(id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -404,21 +350,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -504,21 +442,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/dataset_items/types/create_dataset_item_request.py b/langfuse/api/resources/dataset_items/types/create_dataset_item_request.py index 111f6819a..52d3ff635 100644 --- a/langfuse/api/resources/dataset_items/types/create_dataset_item_request.py +++ b/langfuse/api/resources/dataset_items/types/create_dataset_item_request.py @@ -11,16 +11,10 @@ class CreateDatasetItemRequest(pydantic_v1.BaseModel): dataset_name: str = pydantic_v1.Field(alias="datasetName") input: typing.Optional[typing.Any] = None - expected_output: typing.Optional[typing.Any] = pydantic_v1.Field( - alias="expectedOutput", default=None - ) + expected_output: typing.Optional[typing.Any] = pydantic_v1.Field(alias="expectedOutput", default=None) metadata: typing.Optional[typing.Any] = None - source_trace_id: typing.Optional[str] = pydantic_v1.Field( - alias="sourceTraceId", default=None - ) - source_observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="sourceObservationId", default=None - ) + source_trace_id: typing.Optional[str] = pydantic_v1.Field(alias="sourceTraceId", default=None) + source_observation_id: typing.Optional[str] = pydantic_v1.Field(alias="sourceObservationId", default=None) id: typing.Optional[str] = pydantic_v1.Field(default=None) """ Dataset items are upserted on their id. Id needs to be unique (project-level) and cannot be reused across datasets. @@ -32,28 +26,15 @@ class CreateDatasetItemRequest(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/dataset_items/types/paginated_dataset_items.py b/langfuse/api/resources/dataset_items/types/paginated_dataset_items.py index 8592ba80f..c63f147c4 100644 --- a/langfuse/api/resources/dataset_items/types/paginated_dataset_items.py +++ b/langfuse/api/resources/dataset_items/types/paginated_dataset_items.py @@ -14,28 +14,15 @@ class PaginatedDatasetItems(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/dataset_run_items/client.py b/langfuse/api/resources/dataset_run_items/client.py index c4c923a9b..0be19fa4f 100644 --- a/langfuse/api/resources/dataset_run_items/client.py +++ b/langfuse/api/resources/dataset_run_items/client.py @@ -24,10 +24,7 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def create( - self, - *, - request: CreateDatasetRunItemRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreateDatasetRunItemRequest, request_options: typing.Optional[RequestOptions] = None ) -> DatasetRunItem: """ Create a dataset run item @@ -68,11 +65,7 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/dataset-run-items", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/dataset-run-items", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -80,21 +73,13 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -106,10 +91,7 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def create( - self, - *, - request: CreateDatasetRunItemRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreateDatasetRunItemRequest, request_options: typing.Optional[RequestOptions] = None ) -> DatasetRunItem: """ Create a dataset run item @@ -158,11 +140,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/dataset-run-items", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/dataset-run-items", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -170,21 +148,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/dataset_run_items/types/create_dataset_run_item_request.py b/langfuse/api/resources/dataset_run_items/types/create_dataset_run_item_request.py index 0a643b835..8762d7418 100644 --- a/langfuse/api/resources/dataset_run_items/types/create_dataset_run_item_request.py +++ b/langfuse/api/resources/dataset_run_items/types/create_dataset_run_item_request.py @@ -9,9 +9,7 @@ class CreateDatasetRunItemRequest(pydantic_v1.BaseModel): run_name: str = pydantic_v1.Field(alias="runName") - run_description: typing.Optional[str] = pydantic_v1.Field( - alias="runDescription", default=None - ) + run_description: typing.Optional[str] = pydantic_v1.Field(alias="runDescription", default=None) """ Description of the run. If run exists, description will be updated. """ @@ -22,37 +20,22 @@ class CreateDatasetRunItemRequest(pydantic_v1.BaseModel): """ dataset_item_id: str = pydantic_v1.Field(alias="datasetItemId") - observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="observationId", default=None - ) + observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) trace_id: typing.Optional[str] = pydantic_v1.Field(alias="traceId", default=None) """ traceId should always be provided. For compatibility with older SDK versions it can also be inferred from the provided observationId. """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/datasets/client.py b/langfuse/api/resources/datasets/client.py index 5d535b949..fcfed2498 100644 --- a/langfuse/api/resources/datasets/client.py +++ b/langfuse/api/resources/datasets/client.py @@ -81,32 +81,19 @@ def list( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def get( - self, - dataset_name: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> Dataset: + def get(self, dataset_name: str, *, request_options: typing.Optional[RequestOptions] = None) -> Dataset: """ Get a dataset @@ -138,9 +125,7 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/v2/datasets/{jsonable_encoder(dataset_name)}", - method="GET", - request_options=request_options, + f"api/public/v2/datasets/{jsonable_encoder(dataset_name)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -148,31 +133,20 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def create( - self, - *, - request: CreateDatasetRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreateDatasetRequest, request_options: typing.Optional[RequestOptions] = None ) -> Dataset: """ Create a dataset @@ -210,11 +184,7 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/v2/datasets", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/v2/datasets", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -222,32 +192,20 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def get_run( - self, - dataset_name: str, - run_name: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, dataset_name: str, run_name: str, *, request_options: typing.Optional[RequestOptions] = None ) -> DatasetRunWithItems: """ Get a dataset run and its items @@ -293,21 +251,13 @@ def get_run( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -371,21 +321,13 @@ def get_runs( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -458,32 +400,19 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def get( - self, - dataset_name: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> Dataset: + async def get(self, dataset_name: str, *, request_options: typing.Optional[RequestOptions] = None) -> Dataset: """ Get a dataset @@ -523,9 +452,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/v2/datasets/{jsonable_encoder(dataset_name)}", - method="GET", - request_options=request_options, + f"api/public/v2/datasets/{jsonable_encoder(dataset_name)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -533,31 +460,20 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def create( - self, - *, - request: CreateDatasetRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreateDatasetRequest, request_options: typing.Optional[RequestOptions] = None ) -> Dataset: """ Create a dataset @@ -603,11 +519,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/v2/datasets", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/v2/datasets", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -615,32 +527,20 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def get_run( - self, - dataset_name: str, - run_name: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, dataset_name: str, run_name: str, *, request_options: typing.Optional[RequestOptions] = None ) -> DatasetRunWithItems: """ Get a dataset run and its items @@ -694,21 +594,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -780,21 +672,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/datasets/types/create_dataset_request.py b/langfuse/api/resources/datasets/types/create_dataset_request.py index 023cb4c12..9fb01dde2 100644 --- a/langfuse/api/resources/datasets/types/create_dataset_request.py +++ b/langfuse/api/resources/datasets/types/create_dataset_request.py @@ -13,28 +13,15 @@ class CreateDatasetRequest(pydantic_v1.BaseModel): metadata: typing.Optional[typing.Any] = None def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/datasets/types/paginated_dataset_runs.py b/langfuse/api/resources/datasets/types/paginated_dataset_runs.py index 86f2f0a73..dad465bc7 100644 --- a/langfuse/api/resources/datasets/types/paginated_dataset_runs.py +++ b/langfuse/api/resources/datasets/types/paginated_dataset_runs.py @@ -14,28 +14,15 @@ class PaginatedDatasetRuns(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/datasets/types/paginated_datasets.py b/langfuse/api/resources/datasets/types/paginated_datasets.py index c2d436bf4..e24be3483 100644 --- a/langfuse/api/resources/datasets/types/paginated_datasets.py +++ b/langfuse/api/resources/datasets/types/paginated_datasets.py @@ -14,28 +14,15 @@ class PaginatedDatasets(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/health/client.py b/langfuse/api/resources/health/client.py index 029be7a0c..68560e1e3 100644 --- a/langfuse/api/resources/health/client.py +++ b/langfuse/api/resources/health/client.py @@ -20,9 +20,7 @@ class HealthClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def health( - self, *, request_options: typing.Optional[RequestOptions] = None - ) -> HealthResponse: + def health(self, *, request_options: typing.Optional[RequestOptions] = None) -> HealthResponse: """ Check health of API and database @@ -60,21 +58,13 @@ def health( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -85,9 +75,7 @@ class AsyncHealthClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def health( - self, *, request_options: typing.Optional[RequestOptions] = None - ) -> HealthResponse: + async def health(self, *, request_options: typing.Optional[RequestOptions] = None) -> HealthResponse: """ Check health of API and database @@ -133,21 +121,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/health/types/health_response.py b/langfuse/api/resources/health/types/health_response.py index 633da67a8..70e04b122 100644 --- a/langfuse/api/resources/health/types/health_response.py +++ b/langfuse/api/resources/health/types/health_response.py @@ -27,28 +27,15 @@ class HealthResponse(pydantic_v1.BaseModel): status: str def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/client.py b/langfuse/api/resources/ingestion/client.py index cc58c32e4..e85751ee0 100644 --- a/langfuse/api/resources/ingestion/client.py +++ b/langfuse/api/resources/ingestion/client.py @@ -28,7 +28,7 @@ def batch( *, batch: typing.Sequence[IngestionEvent], metadata: typing.Optional[typing.Any] = OMIT, - request_options: typing.Optional[RequestOptions] = None, + request_options: typing.Optional[RequestOptions] = None ) -> IngestionResponse: """ Batched ingestion for Langfuse Tracing. If you want to use tracing via the API, such as to build your own Langfuse client implementation, this is the only API route you need to implement. @@ -109,21 +109,13 @@ def batch( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -139,7 +131,7 @@ async def batch( *, batch: typing.Sequence[IngestionEvent], metadata: typing.Optional[typing.Any] = OMIT, - request_options: typing.Optional[RequestOptions] = None, + request_options: typing.Optional[RequestOptions] = None ) -> IngestionResponse: """ Batched ingestion for Langfuse Tracing. If you want to use tracing via the API, such as to build your own Langfuse client implementation, this is the only API route you need to implement. @@ -227,21 +219,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/ingestion/types/base_event.py b/langfuse/api/resources/ingestion/types/base_event.py index dec8a52e7..145d224ec 100644 --- a/langfuse/api/resources/ingestion/types/base_event.py +++ b/langfuse/api/resources/ingestion/types/base_event.py @@ -24,28 +24,15 @@ class BaseEvent(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/create_event_body.py b/langfuse/api/resources/ingestion/types/create_event_body.py index afe8677f3..566c39294 100644 --- a/langfuse/api/resources/ingestion/types/create_event_body.py +++ b/langfuse/api/resources/ingestion/types/create_event_body.py @@ -12,28 +12,15 @@ class CreateEventBody(OptionalObservationBody): id: typing.Optional[str] = None def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/create_event_event.py b/langfuse/api/resources/ingestion/types/create_event_event.py index 0c3cce040..fad6d92e0 100644 --- a/langfuse/api/resources/ingestion/types/create_event_event.py +++ b/langfuse/api/resources/ingestion/types/create_event_event.py @@ -13,28 +13,15 @@ class CreateEventEvent(BaseEvent): body: CreateEventBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/create_generation_body.py b/langfuse/api/resources/ingestion/types/create_generation_body.py index 428b58607..22a0cf776 100644 --- a/langfuse/api/resources/ingestion/types/create_generation_body.py +++ b/langfuse/api/resources/ingestion/types/create_generation_body.py @@ -12,50 +12,27 @@ class CreateGenerationBody(CreateSpanBody): - completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field( - alias="completionStartTime", default=None - ) + completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="completionStartTime", default=None) model: typing.Optional[str] = None model_parameters: typing.Optional[typing.Dict[str, MapValue]] = pydantic_v1.Field( alias="modelParameters", default=None ) usage: typing.Optional[IngestionUsage] = None - usage_details: typing.Optional[UsageDetails] = pydantic_v1.Field( - alias="usageDetails", default=None - ) - cost_details: typing.Optional[typing.Dict[str, float]] = pydantic_v1.Field( - alias="costDetails", default=None - ) - prompt_name: typing.Optional[str] = pydantic_v1.Field( - alias="promptName", default=None - ) - prompt_version: typing.Optional[int] = pydantic_v1.Field( - alias="promptVersion", default=None - ) + usage_details: typing.Optional[UsageDetails] = pydantic_v1.Field(alias="usageDetails", default=None) + cost_details: typing.Optional[typing.Dict[str, float]] = pydantic_v1.Field(alias="costDetails", default=None) + prompt_name: typing.Optional[str] = pydantic_v1.Field(alias="promptName", default=None) + prompt_version: typing.Optional[int] = pydantic_v1.Field(alias="promptVersion", default=None) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/create_generation_event.py b/langfuse/api/resources/ingestion/types/create_generation_event.py index cb7b484dd..4b95cfa58 100644 --- a/langfuse/api/resources/ingestion/types/create_generation_event.py +++ b/langfuse/api/resources/ingestion/types/create_generation_event.py @@ -13,28 +13,15 @@ class CreateGenerationEvent(BaseEvent): body: CreateGenerationBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/create_observation_event.py b/langfuse/api/resources/ingestion/types/create_observation_event.py index adfefc793..7a72cc017 100644 --- a/langfuse/api/resources/ingestion/types/create_observation_event.py +++ b/langfuse/api/resources/ingestion/types/create_observation_event.py @@ -13,28 +13,15 @@ class CreateObservationEvent(BaseEvent): body: ObservationBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/create_span_body.py b/langfuse/api/resources/ingestion/types/create_span_body.py index c31fde567..21ef5aaf3 100644 --- a/langfuse/api/resources/ingestion/types/create_span_body.py +++ b/langfuse/api/resources/ingestion/types/create_span_body.py @@ -9,33 +9,18 @@ class CreateSpanBody(CreateEventBody): - end_time: typing.Optional[dt.datetime] = pydantic_v1.Field( - alias="endTime", default=None - ) + end_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="endTime", default=None) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/create_span_event.py b/langfuse/api/resources/ingestion/types/create_span_event.py index 7a8e8154c..042124a93 100644 --- a/langfuse/api/resources/ingestion/types/create_span_event.py +++ b/langfuse/api/resources/ingestion/types/create_span_event.py @@ -13,28 +13,15 @@ class CreateSpanEvent(BaseEvent): body: CreateSpanBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/ingestion_error.py b/langfuse/api/resources/ingestion/types/ingestion_error.py index b9028ce1d..14c661961 100644 --- a/langfuse/api/resources/ingestion/types/ingestion_error.py +++ b/langfuse/api/resources/ingestion/types/ingestion_error.py @@ -14,28 +14,15 @@ class IngestionError(pydantic_v1.BaseModel): error: typing.Optional[typing.Any] = None def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/ingestion_event.py b/langfuse/api/resources/ingestion/types/ingestion_event.py index e083c9354..b8093f89b 100644 --- a/langfuse/api/resources/ingestion/types/ingestion_event.py +++ b/langfuse/api/resources/ingestion/types/ingestion_event.py @@ -26,28 +26,15 @@ class IngestionEvent_TraceCreate(pydantic_v1.BaseModel): type: typing.Literal["trace-create"] = "trace-create" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -65,28 +52,15 @@ class IngestionEvent_ScoreCreate(pydantic_v1.BaseModel): type: typing.Literal["score-create"] = "score-create" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -104,28 +78,15 @@ class IngestionEvent_SpanCreate(pydantic_v1.BaseModel): type: typing.Literal["span-create"] = "span-create" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -143,28 +104,15 @@ class IngestionEvent_SpanUpdate(pydantic_v1.BaseModel): type: typing.Literal["span-update"] = "span-update" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -182,28 +130,15 @@ class IngestionEvent_GenerationCreate(pydantic_v1.BaseModel): type: typing.Literal["generation-create"] = "generation-create" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -221,28 +156,15 @@ class IngestionEvent_GenerationUpdate(pydantic_v1.BaseModel): type: typing.Literal["generation-update"] = "generation-update" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -260,28 +182,15 @@ class IngestionEvent_EventCreate(pydantic_v1.BaseModel): type: typing.Literal["event-create"] = "event-create" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -299,28 +208,15 @@ class IngestionEvent_SdkLog(pydantic_v1.BaseModel): type: typing.Literal["sdk-log"] = "sdk-log" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -338,28 +234,15 @@ class IngestionEvent_ObservationCreate(pydantic_v1.BaseModel): type: typing.Literal["observation-create"] = "observation-create" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -377,28 +260,15 @@ class IngestionEvent_ObservationUpdate(pydantic_v1.BaseModel): type: typing.Literal["observation-update"] = "observation-update" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/ingestion_response.py b/langfuse/api/resources/ingestion/types/ingestion_response.py index b4e66349c..deadc1cb9 100644 --- a/langfuse/api/resources/ingestion/types/ingestion_response.py +++ b/langfuse/api/resources/ingestion/types/ingestion_response.py @@ -14,28 +14,15 @@ class IngestionResponse(pydantic_v1.BaseModel): errors: typing.List[IngestionError] def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/ingestion_success.py b/langfuse/api/resources/ingestion/types/ingestion_success.py index 481e64752..043533491 100644 --- a/langfuse/api/resources/ingestion/types/ingestion_success.py +++ b/langfuse/api/resources/ingestion/types/ingestion_success.py @@ -12,28 +12,15 @@ class IngestionSuccess(pydantic_v1.BaseModel): status: int def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/observation_body.py b/langfuse/api/resources/ingestion/types/observation_body.py index 254c600da..de88ad69f 100644 --- a/langfuse/api/resources/ingestion/types/observation_body.py +++ b/langfuse/api/resources/ingestion/types/observation_body.py @@ -16,15 +16,9 @@ class ObservationBody(pydantic_v1.BaseModel): trace_id: typing.Optional[str] = pydantic_v1.Field(alias="traceId", default=None) type: ObservationType name: typing.Optional[str] = None - start_time: typing.Optional[dt.datetime] = pydantic_v1.Field( - alias="startTime", default=None - ) - end_time: typing.Optional[dt.datetime] = pydantic_v1.Field( - alias="endTime", default=None - ) - completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field( - alias="completionStartTime", default=None - ) + start_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="startTime", default=None) + end_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="endTime", default=None) + completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="completionStartTime", default=None) model: typing.Optional[str] = None model_parameters: typing.Optional[typing.Dict[str, MapValue]] = pydantic_v1.Field( alias="modelParameters", default=None @@ -35,36 +29,19 @@ class ObservationBody(pydantic_v1.BaseModel): output: typing.Optional[typing.Any] = None usage: typing.Optional[Usage] = None level: typing.Optional[ObservationLevel] = None - status_message: typing.Optional[str] = pydantic_v1.Field( - alias="statusMessage", default=None - ) - parent_observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="parentObservationId", default=None - ) + status_message: typing.Optional[str] = pydantic_v1.Field(alias="statusMessage", default=None) + parent_observation_id: typing.Optional[str] = pydantic_v1.Field(alias="parentObservationId", default=None) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/open_ai_usage.py b/langfuse/api/resources/ingestion/types/open_ai_usage.py index 86e7ebd82..c5a8ade45 100644 --- a/langfuse/api/resources/ingestion/types/open_ai_usage.py +++ b/langfuse/api/resources/ingestion/types/open_ai_usage.py @@ -12,39 +12,20 @@ class OpenAiUsage(pydantic_v1.BaseModel): Usage interface of OpenAI for improved compatibility. """ - prompt_tokens: typing.Optional[int] = pydantic_v1.Field( - alias="promptTokens", default=None - ) - completion_tokens: typing.Optional[int] = pydantic_v1.Field( - alias="completionTokens", default=None - ) - total_tokens: typing.Optional[int] = pydantic_v1.Field( - alias="totalTokens", default=None - ) + prompt_tokens: typing.Optional[int] = pydantic_v1.Field(alias="promptTokens", default=None) + completion_tokens: typing.Optional[int] = pydantic_v1.Field(alias="completionTokens", default=None) + total_tokens: typing.Optional[int] = pydantic_v1.Field(alias="totalTokens", default=None) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/open_ai_usage_schema.py b/langfuse/api/resources/ingestion/types/open_ai_usage_schema.py index ecf755bb3..04055f84a 100644 --- a/langfuse/api/resources/ingestion/types/open_ai_usage_schema.py +++ b/langfuse/api/resources/ingestion/types/open_ai_usage_schema.py @@ -15,28 +15,15 @@ class OpenAiUsageSchema(pydantic_v1.BaseModel): completion_tokens_details: typing.Optional[typing.Dict[str, int]] = None def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/optional_observation_body.py b/langfuse/api/resources/ingestion/types/optional_observation_body.py index bd7cb5808..d38e07da4 100644 --- a/langfuse/api/resources/ingestion/types/optional_observation_body.py +++ b/langfuse/api/resources/ingestion/types/optional_observation_body.py @@ -11,44 +11,25 @@ class OptionalObservationBody(pydantic_v1.BaseModel): trace_id: typing.Optional[str] = pydantic_v1.Field(alias="traceId", default=None) name: typing.Optional[str] = None - start_time: typing.Optional[dt.datetime] = pydantic_v1.Field( - alias="startTime", default=None - ) + start_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="startTime", default=None) metadata: typing.Optional[typing.Any] = None input: typing.Optional[typing.Any] = None output: typing.Optional[typing.Any] = None level: typing.Optional[ObservationLevel] = None - status_message: typing.Optional[str] = pydantic_v1.Field( - alias="statusMessage", default=None - ) - parent_observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="parentObservationId", default=None - ) + status_message: typing.Optional[str] = pydantic_v1.Field(alias="statusMessage", default=None) + parent_observation_id: typing.Optional[str] = pydantic_v1.Field(alias="parentObservationId", default=None) version: typing.Optional[str] = None def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/score_body.py b/langfuse/api/resources/ingestion/types/score_body.py index aad152dd8..3b41d5d61 100644 --- a/langfuse/api/resources/ingestion/types/score_body.py +++ b/langfuse/api/resources/ingestion/types/score_body.py @@ -30,13 +30,9 @@ class ScoreBody(pydantic_v1.BaseModel): The value of the score. Must be passed as string for categorical scores, and numeric for boolean and numeric scores. Boolean score values must equal either 1 or 0 (true or false) """ - observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="observationId", default=None - ) + observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) comment: typing.Optional[str] = None - data_type: typing.Optional[ScoreDataType] = pydantic_v1.Field( - alias="dataType", default=None - ) + data_type: typing.Optional[ScoreDataType] = pydantic_v1.Field(alias="dataType", default=None) """ When set, must match the score value's type. If not set, will be inferred from the score value or config """ @@ -47,28 +43,15 @@ class ScoreBody(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/score_event.py b/langfuse/api/resources/ingestion/types/score_event.py index ea05aedef..36e4e1424 100644 --- a/langfuse/api/resources/ingestion/types/score_event.py +++ b/langfuse/api/resources/ingestion/types/score_event.py @@ -13,28 +13,15 @@ class ScoreEvent(BaseEvent): body: ScoreBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/sdk_log_body.py b/langfuse/api/resources/ingestion/types/sdk_log_body.py index df8972860..7bf69e4d4 100644 --- a/langfuse/api/resources/ingestion/types/sdk_log_body.py +++ b/langfuse/api/resources/ingestion/types/sdk_log_body.py @@ -11,28 +11,15 @@ class SdkLogBody(pydantic_v1.BaseModel): log: typing.Any def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/sdk_log_event.py b/langfuse/api/resources/ingestion/types/sdk_log_event.py index d7ad87de8..e4fcc2672 100644 --- a/langfuse/api/resources/ingestion/types/sdk_log_event.py +++ b/langfuse/api/resources/ingestion/types/sdk_log_event.py @@ -13,28 +13,15 @@ class SdkLogEvent(BaseEvent): body: SdkLogBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/trace_body.py b/langfuse/api/resources/ingestion/types/trace_body.py index 42cb4f197..de01c2f02 100644 --- a/langfuse/api/resources/ingestion/types/trace_body.py +++ b/langfuse/api/resources/ingestion/types/trace_body.py @@ -14,9 +14,7 @@ class TraceBody(pydantic_v1.BaseModel): user_id: typing.Optional[str] = pydantic_v1.Field(alias="userId", default=None) input: typing.Optional[typing.Any] = None output: typing.Optional[typing.Any] = None - session_id: typing.Optional[str] = pydantic_v1.Field( - alias="sessionId", default=None - ) + session_id: typing.Optional[str] = pydantic_v1.Field(alias="sessionId", default=None) release: typing.Optional[str] = None version: typing.Optional[str] = None metadata: typing.Optional[typing.Any] = None @@ -27,28 +25,15 @@ class TraceBody(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/trace_event.py b/langfuse/api/resources/ingestion/types/trace_event.py index b84ddd615..c2e39defa 100644 --- a/langfuse/api/resources/ingestion/types/trace_event.py +++ b/langfuse/api/resources/ingestion/types/trace_event.py @@ -13,28 +13,15 @@ class TraceEvent(BaseEvent): body: TraceBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/update_event_body.py b/langfuse/api/resources/ingestion/types/update_event_body.py index 35bbb359b..12c0b0f45 100644 --- a/langfuse/api/resources/ingestion/types/update_event_body.py +++ b/langfuse/api/resources/ingestion/types/update_event_body.py @@ -12,28 +12,15 @@ class UpdateEventBody(OptionalObservationBody): id: str def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/update_generation_body.py b/langfuse/api/resources/ingestion/types/update_generation_body.py index 2058543af..b1305bbe6 100644 --- a/langfuse/api/resources/ingestion/types/update_generation_body.py +++ b/langfuse/api/resources/ingestion/types/update_generation_body.py @@ -12,50 +12,27 @@ class UpdateGenerationBody(UpdateSpanBody): - completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field( - alias="completionStartTime", default=None - ) + completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="completionStartTime", default=None) model: typing.Optional[str] = None model_parameters: typing.Optional[typing.Dict[str, MapValue]] = pydantic_v1.Field( alias="modelParameters", default=None ) usage: typing.Optional[IngestionUsage] = None - prompt_name: typing.Optional[str] = pydantic_v1.Field( - alias="promptName", default=None - ) - usage_details: typing.Optional[UsageDetails] = pydantic_v1.Field( - alias="usageDetails", default=None - ) - cost_details: typing.Optional[typing.Dict[str, float]] = pydantic_v1.Field( - alias="costDetails", default=None - ) - prompt_version: typing.Optional[int] = pydantic_v1.Field( - alias="promptVersion", default=None - ) + prompt_name: typing.Optional[str] = pydantic_v1.Field(alias="promptName", default=None) + usage_details: typing.Optional[UsageDetails] = pydantic_v1.Field(alias="usageDetails", default=None) + cost_details: typing.Optional[typing.Dict[str, float]] = pydantic_v1.Field(alias="costDetails", default=None) + prompt_version: typing.Optional[int] = pydantic_v1.Field(alias="promptVersion", default=None) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/update_generation_event.py b/langfuse/api/resources/ingestion/types/update_generation_event.py index da8f6a9fa..33c8b42f0 100644 --- a/langfuse/api/resources/ingestion/types/update_generation_event.py +++ b/langfuse/api/resources/ingestion/types/update_generation_event.py @@ -13,28 +13,15 @@ class UpdateGenerationEvent(BaseEvent): body: UpdateGenerationBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/update_observation_event.py b/langfuse/api/resources/ingestion/types/update_observation_event.py index 9d7af357f..ebc1353cf 100644 --- a/langfuse/api/resources/ingestion/types/update_observation_event.py +++ b/langfuse/api/resources/ingestion/types/update_observation_event.py @@ -13,28 +13,15 @@ class UpdateObservationEvent(BaseEvent): body: ObservationBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/update_span_body.py b/langfuse/api/resources/ingestion/types/update_span_body.py index e3484879b..1575ba553 100644 --- a/langfuse/api/resources/ingestion/types/update_span_body.py +++ b/langfuse/api/resources/ingestion/types/update_span_body.py @@ -9,33 +9,18 @@ class UpdateSpanBody(UpdateEventBody): - end_time: typing.Optional[dt.datetime] = pydantic_v1.Field( - alias="endTime", default=None - ) + end_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="endTime", default=None) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/ingestion/types/update_span_event.py b/langfuse/api/resources/ingestion/types/update_span_event.py index ec7d83b15..3ad1b61b4 100644 --- a/langfuse/api/resources/ingestion/types/update_span_event.py +++ b/langfuse/api/resources/ingestion/types/update_span_event.py @@ -13,28 +13,15 @@ class UpdateSpanEvent(BaseEvent): body: UpdateSpanBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/media/client.py b/langfuse/api/resources/media/client.py index 0dcd75e8e..b6815cc8f 100644 --- a/langfuse/api/resources/media/client.py +++ b/langfuse/api/resources/media/client.py @@ -26,9 +26,7 @@ class MediaClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def get( - self, media_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetMediaResponse: + def get(self, media_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetMediaResponse: """ Get a media record @@ -61,9 +59,7 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/media/{jsonable_encoder(media_id)}", - method="GET", - request_options=request_options, + f"api/public/media/{jsonable_encoder(media_id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -71,32 +67,20 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def patch( - self, - media_id: str, - *, - request: PatchMediaBody, - request_options: typing.Optional[RequestOptions] = None, + self, media_id: str, *, request: PatchMediaBody, request_options: typing.Optional[RequestOptions] = None ) -> None: """ Patch a media record @@ -155,31 +139,20 @@ def patch( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def get_upload_url( - self, - *, - request: GetMediaUploadUrlRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: GetMediaUploadUrlRequest, request_options: typing.Optional[RequestOptions] = None ) -> GetMediaUploadUrlResponse: """ Get a presigned upload URL for a media record @@ -220,35 +193,21 @@ def get_upload_url( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/media", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/media", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as( - GetMediaUploadUrlResponse, _response.json() - ) # type: ignore + return pydantic_v1.parse_obj_as(GetMediaUploadUrlResponse, _response.json()) # type: ignore if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -259,9 +218,7 @@ class AsyncMediaClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def get( - self, media_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetMediaResponse: + async def get(self, media_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetMediaResponse: """ Get a media record @@ -302,9 +259,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/media/{jsonable_encoder(media_id)}", - method="GET", - request_options=request_options, + f"api/public/media/{jsonable_encoder(media_id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -312,32 +267,20 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def patch( - self, - media_id: str, - *, - request: PatchMediaBody, - request_options: typing.Optional[RequestOptions] = None, + self, media_id: str, *, request: PatchMediaBody, request_options: typing.Optional[RequestOptions] = None ) -> None: """ Patch a media record @@ -403,31 +346,20 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def get_upload_url( - self, - *, - request: GetMediaUploadUrlRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: GetMediaUploadUrlRequest, request_options: typing.Optional[RequestOptions] = None ) -> GetMediaUploadUrlResponse: """ Get a presigned upload URL for a media record @@ -476,35 +408,21 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/media", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/media", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as( - GetMediaUploadUrlResponse, _response.json() - ) # type: ignore + return pydantic_v1.parse_obj_as(GetMediaUploadUrlResponse, _response.json()) # type: ignore if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/media/types/get_media_response.py b/langfuse/api/resources/media/types/get_media_response.py index fa5368872..102816e8f 100644 --- a/langfuse/api/resources/media/types/get_media_response.py +++ b/langfuse/api/resources/media/types/get_media_response.py @@ -39,28 +39,15 @@ class GetMediaResponse(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/media/types/get_media_upload_url_request.py b/langfuse/api/resources/media/types/get_media_upload_url_request.py index d0cde59fe..33514f397 100644 --- a/langfuse/api/resources/media/types/get_media_upload_url_request.py +++ b/langfuse/api/resources/media/types/get_media_upload_url_request.py @@ -14,9 +14,7 @@ class GetMediaUploadUrlRequest(pydantic_v1.BaseModel): The trace ID associated with the media record """ - observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="observationId", default=None - ) + observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) """ The observation ID associated with the media record. If the media record is associated directly with a trace, this will be null. """ @@ -38,28 +36,15 @@ class GetMediaUploadUrlRequest(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/media/types/get_media_upload_url_response.py b/langfuse/api/resources/media/types/get_media_upload_url_response.py index fadc76c01..06e2e8742 100644 --- a/langfuse/api/resources/media/types/get_media_upload_url_response.py +++ b/langfuse/api/resources/media/types/get_media_upload_url_response.py @@ -8,9 +8,7 @@ class GetMediaUploadUrlResponse(pydantic_v1.BaseModel): - upload_url: typing.Optional[str] = pydantic_v1.Field( - alias="uploadUrl", default=None - ) + upload_url: typing.Optional[str] = pydantic_v1.Field(alias="uploadUrl", default=None) """ The presigned upload URL. If the asset is already uploaded, this will be null """ @@ -21,28 +19,15 @@ class GetMediaUploadUrlResponse(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/media/types/patch_media_body.py b/langfuse/api/resources/media/types/patch_media_body.py index 49f0c3432..49108c175 100644 --- a/langfuse/api/resources/media/types/patch_media_body.py +++ b/langfuse/api/resources/media/types/patch_media_body.py @@ -18,43 +18,26 @@ class PatchMediaBody(pydantic_v1.BaseModel): The HTTP status code of the upload """ - upload_http_error: typing.Optional[str] = pydantic_v1.Field( - alias="uploadHttpError", default=None - ) + upload_http_error: typing.Optional[str] = pydantic_v1.Field(alias="uploadHttpError", default=None) """ The HTTP error message of the upload """ - upload_time_ms: typing.Optional[int] = pydantic_v1.Field( - alias="uploadTimeMs", default=None - ) + upload_time_ms: typing.Optional[int] = pydantic_v1.Field(alias="uploadTimeMs", default=None) """ The time in milliseconds it took to upload the media record """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/metrics/client.py b/langfuse/api/resources/metrics/client.py index 6447b1133..6d80a605a 100644 --- a/langfuse/api/resources/metrics/client.py +++ b/langfuse/api/resources/metrics/client.py @@ -31,7 +31,7 @@ def daily( tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, from_timestamp: typing.Optional[dt.datetime] = None, to_timestamp: typing.Optional[dt.datetime] = None, - request_options: typing.Optional[RequestOptions] = None, + request_options: typing.Optional[RequestOptions] = None ) -> DailyMetrics: """ Get daily metrics of the Langfuse project @@ -103,12 +103,8 @@ def daily( "traceName": trace_name, "userId": user_id, "tags": tags, - "fromTimestamp": serialize_datetime(from_timestamp) - if from_timestamp is not None - else None, - "toTimestamp": serialize_datetime(to_timestamp) - if to_timestamp is not None - else None, + "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, + "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, }, request_options=request_options, ) @@ -118,21 +114,13 @@ def daily( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -153,7 +141,7 @@ async def daily( tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, from_timestamp: typing.Optional[dt.datetime] = None, to_timestamp: typing.Optional[dt.datetime] = None, - request_options: typing.Optional[RequestOptions] = None, + request_options: typing.Optional[RequestOptions] = None ) -> DailyMetrics: """ Get daily metrics of the Langfuse project @@ -232,12 +220,8 @@ async def main() -> None: "traceName": trace_name, "userId": user_id, "tags": tags, - "fromTimestamp": serialize_datetime(from_timestamp) - if from_timestamp is not None - else None, - "toTimestamp": serialize_datetime(to_timestamp) - if to_timestamp is not None - else None, + "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, + "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, }, request_options=request_options, ) @@ -247,21 +231,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/metrics/types/daily_metrics.py b/langfuse/api/resources/metrics/types/daily_metrics.py index 36a12a3d6..52d5f151d 100644 --- a/langfuse/api/resources/metrics/types/daily_metrics.py +++ b/langfuse/api/resources/metrics/types/daily_metrics.py @@ -18,28 +18,15 @@ class DailyMetrics(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/metrics/types/daily_metrics_details.py b/langfuse/api/resources/metrics/types/daily_metrics_details.py index e97f65446..3a208ab10 100644 --- a/langfuse/api/resources/metrics/types/daily_metrics_details.py +++ b/langfuse/api/resources/metrics/types/daily_metrics_details.py @@ -20,28 +20,15 @@ class DailyMetricsDetails(pydantic_v1.BaseModel): usage: typing.List[UsageByModel] def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/metrics/types/usage_by_model.py b/langfuse/api/resources/metrics/types/usage_by_model.py index 3ff6de59c..b94cc02ac 100644 --- a/langfuse/api/resources/metrics/types/usage_by_model.py +++ b/langfuse/api/resources/metrics/types/usage_by_model.py @@ -36,28 +36,15 @@ class UsageByModel(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/models/client.py b/langfuse/api/resources/models/client.py index 1ebac9d07..c819df2fb 100644 --- a/langfuse/api/resources/models/client.py +++ b/langfuse/api/resources/models/client.py @@ -25,12 +25,7 @@ class ModelsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def create( - self, - *, - request: CreateModelRequest, - request_options: typing.Optional[RequestOptions] = None, - ) -> Model: + def create(self, *, request: CreateModelRequest, request_options: typing.Optional[RequestOptions] = None) -> Model: """ Create a model @@ -77,11 +72,7 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/models", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/models", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -89,21 +80,13 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -152,10 +135,7 @@ def list( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/models", - method="GET", - params={"page": page, "limit": limit}, - request_options=request_options, + "api/public/models", method="GET", params={"page": page, "limit": limit}, request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -163,29 +143,19 @@ def list( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def get( - self, id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> Model: + def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Model: """ Get a model @@ -217,9 +187,7 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/models/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, + f"api/public/models/{jsonable_encoder(id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -227,29 +195,19 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def delete( - self, id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> None: + def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ Delete a model. Cannot delete models managed by Langfuse. You can create your own definition with the same modelName to override the definition though. @@ -281,9 +239,7 @@ def delete( ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/models/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, + f"api/public/models/{jsonable_encoder(id)}", method="DELETE", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -291,21 +247,13 @@ def delete( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -317,10 +265,7 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def create( - self, - *, - request: CreateModelRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreateModelRequest, request_options: typing.Optional[RequestOptions] = None ) -> Model: """ Create a model @@ -375,11 +320,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/models", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/models", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -387,21 +328,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -458,10 +391,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/models", - method="GET", - params={"page": page, "limit": limit}, - request_options=request_options, + "api/public/models", method="GET", params={"page": page, "limit": limit}, request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -469,29 +399,19 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def get( - self, id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> Model: + async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Model: """ Get a model @@ -531,9 +451,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/models/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, + f"api/public/models/{jsonable_encoder(id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -541,29 +459,19 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def delete( - self, id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> None: + async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ Delete a model. Cannot delete models managed by Langfuse. You can create your own definition with the same modelName to override the definition though. @@ -603,9 +511,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/models/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, + f"api/public/models/{jsonable_encoder(id)}", method="DELETE", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -613,21 +519,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/models/types/create_model_request.py b/langfuse/api/resources/models/types/create_model_request.py index b3d8a6462..a2c5fedb5 100644 --- a/langfuse/api/resources/models/types/create_model_request.py +++ b/langfuse/api/resources/models/types/create_model_request.py @@ -19,9 +19,7 @@ class CreateModelRequest(pydantic_v1.BaseModel): Regex pattern which matches this model definition to generation.model. Useful in case of fine-tuned models. If you want to exact match, use `(?i)^modelname$` """ - start_date: typing.Optional[dt.datetime] = pydantic_v1.Field( - alias="startDate", default=None - ) + start_date: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="startDate", default=None) """ Apply only to generations which are newer than this ISO date. """ @@ -31,64 +29,41 @@ class CreateModelRequest(pydantic_v1.BaseModel): Unit used by this model. """ - input_price: typing.Optional[float] = pydantic_v1.Field( - alias="inputPrice", default=None - ) + input_price: typing.Optional[float] = pydantic_v1.Field(alias="inputPrice", default=None) """ Price (USD) per input unit """ - output_price: typing.Optional[float] = pydantic_v1.Field( - alias="outputPrice", default=None - ) + output_price: typing.Optional[float] = pydantic_v1.Field(alias="outputPrice", default=None) """ Price (USD) per output unit """ - total_price: typing.Optional[float] = pydantic_v1.Field( - alias="totalPrice", default=None - ) + total_price: typing.Optional[float] = pydantic_v1.Field(alias="totalPrice", default=None) """ Price (USD) per total units. Cannot be set if input or output price is set. """ - tokenizer_id: typing.Optional[str] = pydantic_v1.Field( - alias="tokenizerId", default=None - ) + tokenizer_id: typing.Optional[str] = pydantic_v1.Field(alias="tokenizerId", default=None) """ Optional. Tokenizer to be applied to observations which match to this model. See docs for more details. """ - tokenizer_config: typing.Optional[typing.Any] = pydantic_v1.Field( - alias="tokenizerConfig", default=None - ) + tokenizer_config: typing.Optional[typing.Any] = pydantic_v1.Field(alias="tokenizerConfig", default=None) """ Optional. Configuration for the selected tokenizer. Needs to be JSON. See docs for more details. """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/models/types/paginated_models.py b/langfuse/api/resources/models/types/paginated_models.py index 3469a1fe6..308054c12 100644 --- a/langfuse/api/resources/models/types/paginated_models.py +++ b/langfuse/api/resources/models/types/paginated_models.py @@ -14,28 +14,15 @@ class PaginatedModels(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/observations/client.py b/langfuse/api/resources/observations/client.py index d937841b9..93078238d 100644 --- a/langfuse/api/resources/observations/client.py +++ b/langfuse/api/resources/observations/client.py @@ -23,12 +23,7 @@ class ObservationsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def get( - self, - observation_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ObservationsView: + def get(self, observation_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ObservationsView: """ Get a observation @@ -61,9 +56,7 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/observations/{jsonable_encoder(observation_id)}", - method="GET", - request_options=request_options, + f"api/public/observations/{jsonable_encoder(observation_id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -71,21 +64,13 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -185,12 +170,8 @@ def get_many( "type": type, "traceId": trace_id, "parentObservationId": parent_observation_id, - "fromStartTime": serialize_datetime(from_start_time) - if from_start_time is not None - else None, - "toStartTime": serialize_datetime(to_start_time) - if to_start_time is not None - else None, + "fromStartTime": serialize_datetime(from_start_time) if from_start_time is not None else None, + "toStartTime": serialize_datetime(to_start_time) if to_start_time is not None else None, "version": version, }, request_options=request_options, @@ -201,21 +182,13 @@ def get_many( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -227,10 +200,7 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def get( - self, - observation_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, observation_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> ObservationsView: """ Get a observation @@ -272,9 +242,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/observations/{jsonable_encoder(observation_id)}", - method="GET", - request_options=request_options, + f"api/public/observations/{jsonable_encoder(observation_id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -282,21 +250,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -403,12 +363,8 @@ async def main() -> None: "type": type, "traceId": trace_id, "parentObservationId": parent_observation_id, - "fromStartTime": serialize_datetime(from_start_time) - if from_start_time is not None - else None, - "toStartTime": serialize_datetime(to_start_time) - if to_start_time is not None - else None, + "fromStartTime": serialize_datetime(from_start_time) if from_start_time is not None else None, + "toStartTime": serialize_datetime(to_start_time) if to_start_time is not None else None, "version": version, }, request_options=request_options, @@ -419,21 +375,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/observations/types/observations.py b/langfuse/api/resources/observations/types/observations.py index 1534dc87e..4cf452cb2 100644 --- a/langfuse/api/resources/observations/types/observations.py +++ b/langfuse/api/resources/observations/types/observations.py @@ -14,28 +14,15 @@ class Observations(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/observations/types/observations_views.py b/langfuse/api/resources/observations/types/observations_views.py index ed86b7d1e..5ff652f67 100644 --- a/langfuse/api/resources/observations/types/observations_views.py +++ b/langfuse/api/resources/observations/types/observations_views.py @@ -14,28 +14,15 @@ class ObservationsViews(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/projects/client.py b/langfuse/api/resources/projects/client.py index 3f4e38e6e..6973753d3 100644 --- a/langfuse/api/resources/projects/client.py +++ b/langfuse/api/resources/projects/client.py @@ -19,9 +19,7 @@ class ProjectsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def get( - self, *, request_options: typing.Optional[RequestOptions] = None - ) -> Projects: + def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Projects: """ Get Project associated with API key @@ -57,21 +55,13 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -82,9 +72,7 @@ class AsyncProjectsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def get( - self, *, request_options: typing.Optional[RequestOptions] = None - ) -> Projects: + async def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Projects: """ Get Project associated with API key @@ -128,21 +116,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/projects/types/project.py b/langfuse/api/resources/projects/types/project.py index ad2b48cd2..8c0f5fcbd 100644 --- a/langfuse/api/resources/projects/types/project.py +++ b/langfuse/api/resources/projects/types/project.py @@ -12,28 +12,15 @@ class Project(pydantic_v1.BaseModel): name: str def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/projects/types/projects.py b/langfuse/api/resources/projects/types/projects.py index c5eaabfbd..9e0be782d 100644 --- a/langfuse/api/resources/projects/types/projects.py +++ b/langfuse/api/resources/projects/types/projects.py @@ -12,28 +12,15 @@ class Projects(pydantic_v1.BaseModel): data: typing.List[Project] def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/prompt_version/__init__.py b/langfuse/api/resources/prompt_version/__init__.py new file mode 100644 index 000000000..f3ea2659b --- /dev/null +++ b/langfuse/api/resources/prompt_version/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/langfuse/api/resources/prompt_version/client.py b/langfuse/api/resources/prompt_version/client.py new file mode 100644 index 000000000..781dba7e5 --- /dev/null +++ b/langfuse/api/resources/prompt_version/client.py @@ -0,0 +1,181 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.jsonable_encoder import jsonable_encoder +from ...core.pydantic_utilities import pydantic_v1 +from ...core.request_options import RequestOptions +from ..commons.errors.access_denied_error import AccessDeniedError +from ..commons.errors.error import Error +from ..commons.errors.method_not_allowed_error import MethodNotAllowedError +from ..commons.errors.not_found_error import NotFoundError +from ..commons.errors.unauthorized_error import UnauthorizedError +from ..commons.types.prompt import Prompt + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class PromptVersionClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def update( + self, + prompt_name: str, + version: int, + *, + new_labels: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> Prompt: + """ + Update labels for a specific prompt version + + Parameters + ---------- + prompt_name : str + The name of the prompt + + version : int + Version of the prompt to update + + new_labels : typing.Sequence[str] + New labels for the prompt version. Labels are unique across versions. The "latest" label is reserved and managed by Langfuse. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Prompt + + Examples + -------- + from langfuse.client import FernLangfuse + + client = FernLangfuse( + x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", + x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", + x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", + username="YOUR_USERNAME", + password="YOUR_PASSWORD", + base_url="https://yourhost.com/path/to/api", + ) + client.prompt_version.update( + prompt_name="string", + version=1, + new_labels=["string"], + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"api/public/v2/prompts/{jsonable_encoder(prompt_name)}/version/{jsonable_encoder(version)}", + method="PATCH", + json={"newLabels": new_labels}, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Prompt, _response.json()) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + +class AsyncPromptVersionClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def update( + self, + prompt_name: str, + version: int, + *, + new_labels: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> Prompt: + """ + Update labels for a specific prompt version + + Parameters + ---------- + prompt_name : str + The name of the prompt + + version : int + Version of the prompt to update + + new_labels : typing.Sequence[str] + New labels for the prompt version. Labels are unique across versions. The "latest" label is reserved and managed by Langfuse. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Prompt + + Examples + -------- + import asyncio + + from langfuse.client import AsyncFernLangfuse + + client = AsyncFernLangfuse( + x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", + x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", + x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", + username="YOUR_USERNAME", + password="YOUR_PASSWORD", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.prompt_version.update( + prompt_name="string", + version=1, + new_labels=["string"], + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/public/v2/prompts/{jsonable_encoder(prompt_name)}/version/{jsonable_encoder(version)}", + method="PATCH", + json={"newLabels": new_labels}, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(Prompt, _response.json()) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/langfuse/api/resources/prompts/__init__.py b/langfuse/api/resources/prompts/__init__.py index 73dcf38b0..75b546741 100644 --- a/langfuse/api/resources/prompts/__init__.py +++ b/langfuse/api/resources/prompts/__init__.py @@ -1,35 +1,21 @@ # This file was auto-generated by Fern from our API Definition. from .types import ( - BasePrompt, - ChatMessage, - ChatPrompt, CreateChatPromptRequest, CreatePromptRequest, CreatePromptRequest_Chat, CreatePromptRequest_Text, CreateTextPromptRequest, - Prompt, PromptMeta, PromptMetaListResponse, - Prompt_Chat, - Prompt_Text, - TextPrompt, ) __all__ = [ - "BasePrompt", - "ChatMessage", - "ChatPrompt", "CreateChatPromptRequest", "CreatePromptRequest", "CreatePromptRequest_Chat", "CreatePromptRequest_Text", "CreateTextPromptRequest", - "Prompt", "PromptMeta", "PromptMetaListResponse", - "Prompt_Chat", - "Prompt_Text", - "TextPrompt", ] diff --git a/langfuse/api/resources/prompts/client.py b/langfuse/api/resources/prompts/client.py index ebaa07909..9d0ac5d22 100644 --- a/langfuse/api/resources/prompts/client.py +++ b/langfuse/api/resources/prompts/client.py @@ -15,8 +15,8 @@ from ..commons.errors.method_not_allowed_error import MethodNotAllowedError from ..commons.errors.not_found_error import NotFoundError from ..commons.errors.unauthorized_error import UnauthorizedError +from ..commons.types.prompt import Prompt from .types.create_prompt_request import CreatePromptRequest -from .types.prompt import Prompt from .types.prompt_meta_list_response import PromptMetaListResponse # this is used as the default value for optional parameters @@ -86,21 +86,13 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -185,48 +177,31 @@ def list( "tag": tag, "page": page, "limit": limit, - "fromUpdatedAt": serialize_datetime(from_updated_at) - if from_updated_at is not None - else None, - "toUpdatedAt": serialize_datetime(to_updated_at) - if to_updated_at is not None - else None, + "fromUpdatedAt": serialize_datetime(from_updated_at) if from_updated_at is not None else None, + "toUpdatedAt": serialize_datetime(to_updated_at) if to_updated_at is not None else None, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as( - PromptMetaListResponse, _response.json() - ) # type: ignore + return pydantic_v1.parse_obj_as(PromptMetaListResponse, _response.json()) # type: ignore if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def create( - self, - *, - request: CreatePromptRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreatePromptRequest, request_options: typing.Optional[RequestOptions] = None ) -> Prompt: """ Create a new version for the prompt with the given `name` @@ -271,11 +246,7 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/v2/prompts", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/v2/prompts", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -283,21 +254,13 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -375,21 +338,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -481,48 +436,31 @@ async def main() -> None: "tag": tag, "page": page, "limit": limit, - "fromUpdatedAt": serialize_datetime(from_updated_at) - if from_updated_at is not None - else None, - "toUpdatedAt": serialize_datetime(to_updated_at) - if to_updated_at is not None - else None, + "fromUpdatedAt": serialize_datetime(from_updated_at) if from_updated_at is not None else None, + "toUpdatedAt": serialize_datetime(to_updated_at) if to_updated_at is not None else None, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as( - PromptMetaListResponse, _response.json() - ) # type: ignore + return pydantic_v1.parse_obj_as(PromptMetaListResponse, _response.json()) # type: ignore if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def create( - self, - *, - request: CreatePromptRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreatePromptRequest, request_options: typing.Optional[RequestOptions] = None ) -> Prompt: """ Create a new version for the prompt with the given `name` @@ -575,11 +513,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/v2/prompts", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/v2/prompts", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -587,21 +521,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/prompts/types/__init__.py b/langfuse/api/resources/prompts/types/__init__.py index cb5ba920c..99bcf4011 100644 --- a/langfuse/api/resources/prompts/types/__init__.py +++ b/langfuse/api/resources/prompts/types/__init__.py @@ -1,33 +1,17 @@ # This file was auto-generated by Fern from our API Definition. -from .base_prompt import BasePrompt -from .chat_message import ChatMessage -from .chat_prompt import ChatPrompt from .create_chat_prompt_request import CreateChatPromptRequest -from .create_prompt_request import ( - CreatePromptRequest, - CreatePromptRequest_Chat, - CreatePromptRequest_Text, -) +from .create_prompt_request import CreatePromptRequest, CreatePromptRequest_Chat, CreatePromptRequest_Text from .create_text_prompt_request import CreateTextPromptRequest -from .prompt import Prompt, Prompt_Chat, Prompt_Text from .prompt_meta import PromptMeta from .prompt_meta_list_response import PromptMetaListResponse -from .text_prompt import TextPrompt __all__ = [ - "BasePrompt", - "ChatMessage", - "ChatPrompt", "CreateChatPromptRequest", "CreatePromptRequest", "CreatePromptRequest_Chat", "CreatePromptRequest_Text", "CreateTextPromptRequest", - "Prompt", "PromptMeta", "PromptMetaListResponse", - "Prompt_Chat", - "Prompt_Text", - "TextPrompt", ] diff --git a/langfuse/api/resources/prompts/types/create_chat_prompt_request.py b/langfuse/api/resources/prompts/types/create_chat_prompt_request.py index a7c9f113b..e2b40102d 100644 --- a/langfuse/api/resources/prompts/types/create_chat_prompt_request.py +++ b/langfuse/api/resources/prompts/types/create_chat_prompt_request.py @@ -5,7 +5,7 @@ from ....core.datetime_utils import serialize_datetime from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from .chat_message import ChatMessage +from ...commons.types.chat_message import ChatMessage class CreateChatPromptRequest(pydantic_v1.BaseModel): @@ -23,28 +23,15 @@ class CreateChatPromptRequest(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/prompts/types/create_prompt_request.py b/langfuse/api/resources/prompts/types/create_prompt_request.py index 9b23bd12d..2c9b0f877 100644 --- a/langfuse/api/resources/prompts/types/create_prompt_request.py +++ b/langfuse/api/resources/prompts/types/create_prompt_request.py @@ -7,7 +7,7 @@ from ....core.datetime_utils import serialize_datetime from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from .chat_message import ChatMessage +from ...commons.types.chat_message import ChatMessage class CreatePromptRequest_Chat(pydantic_v1.BaseModel): @@ -19,28 +19,15 @@ class CreatePromptRequest_Chat(pydantic_v1.BaseModel): type: typing.Literal["chat"] = "chat" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -59,28 +46,15 @@ class CreatePromptRequest_Text(pydantic_v1.BaseModel): type: typing.Literal["text"] = "text" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/prompts/types/create_text_prompt_request.py b/langfuse/api/resources/prompts/types/create_text_prompt_request.py index 31b1c0eee..751b4492c 100644 --- a/langfuse/api/resources/prompts/types/create_text_prompt_request.py +++ b/langfuse/api/resources/prompts/types/create_text_prompt_request.py @@ -22,28 +22,15 @@ class CreateTextPromptRequest(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/prompts/types/prompt_meta.py b/langfuse/api/resources/prompts/types/prompt_meta.py index bbb028fb2..f0621e105 100644 --- a/langfuse/api/resources/prompts/types/prompt_meta.py +++ b/langfuse/api/resources/prompts/types/prompt_meta.py @@ -19,28 +19,15 @@ class PromptMeta(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/prompts/types/prompt_meta_list_response.py b/langfuse/api/resources/prompts/types/prompt_meta_list_response.py index d3dccf650..6ebf13c4a 100644 --- a/langfuse/api/resources/prompts/types/prompt_meta_list_response.py +++ b/langfuse/api/resources/prompts/types/prompt_meta_list_response.py @@ -14,28 +14,15 @@ class PromptMetaListResponse(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/score/client.py b/langfuse/api/resources/score/client.py index 2c911449d..4f7fc0e4f 100644 --- a/langfuse/api/resources/score/client.py +++ b/langfuse/api/resources/score/client.py @@ -31,10 +31,7 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def create( - self, - *, - request: CreateScoreRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreateScoreRequest, request_options: typing.Optional[RequestOptions] = None ) -> CreateScoreResponse: """ Create a score @@ -72,11 +69,7 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/scores", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/scores", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -84,21 +77,13 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -120,9 +105,7 @@ def get( config_id: typing.Optional[str] = None, queue_id: typing.Optional[str] = None, data_type: typing.Optional[ScoreDataType] = None, - trace_tags: typing.Optional[ - typing.Union[typing.Sequence[str], typing.Sequence[typing.Sequence[str]]] - ] = None, + trace_tags: typing.Optional[typing.Union[typing.Sequence[str], typing.Sequence[typing.Sequence[str]]]] = None, request_options: typing.Optional[RequestOptions] = None, ) -> GetScoresResponse: """ @@ -223,12 +206,8 @@ def get( "limit": limit, "userId": user_id, "name": name, - "fromTimestamp": serialize_datetime(from_timestamp) - if from_timestamp is not None - else None, - "toTimestamp": serialize_datetime(to_timestamp) - if to_timestamp is not None - else None, + "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, + "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, "source": source, "operator": operator, "value": value, @@ -246,29 +225,19 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def get_by_id( - self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> Score: + def get_by_id(self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Score: """ Get a score @@ -301,9 +270,7 @@ def get_by_id( ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/scores/{jsonable_encoder(score_id)}", - method="GET", - request_options=request_options, + f"api/public/scores/{jsonable_encoder(score_id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -311,29 +278,19 @@ def get_by_id( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def delete( - self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> None: + def delete(self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ Delete a score @@ -366,9 +323,7 @@ def delete( ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/scores/{jsonable_encoder(score_id)}", - method="DELETE", - request_options=request_options, + f"api/public/scores/{jsonable_encoder(score_id)}", method="DELETE", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -376,21 +331,13 @@ def delete( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -402,10 +349,7 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def create( - self, - *, - request: CreateScoreRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreateScoreRequest, request_options: typing.Optional[RequestOptions] = None ) -> CreateScoreResponse: """ Create a score @@ -451,11 +395,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/scores", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/scores", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -463,21 +403,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -499,9 +431,7 @@ async def get( config_id: typing.Optional[str] = None, queue_id: typing.Optional[str] = None, data_type: typing.Optional[ScoreDataType] = None, - trace_tags: typing.Optional[ - typing.Union[typing.Sequence[str], typing.Sequence[typing.Sequence[str]]] - ] = None, + trace_tags: typing.Optional[typing.Union[typing.Sequence[str], typing.Sequence[typing.Sequence[str]]]] = None, request_options: typing.Optional[RequestOptions] = None, ) -> GetScoresResponse: """ @@ -609,12 +539,8 @@ async def main() -> None: "limit": limit, "userId": user_id, "name": name, - "fromTimestamp": serialize_datetime(from_timestamp) - if from_timestamp is not None - else None, - "toTimestamp": serialize_datetime(to_timestamp) - if to_timestamp is not None - else None, + "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, + "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, "source": source, "operator": operator, "value": value, @@ -632,29 +558,19 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def get_by_id( - self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> Score: + async def get_by_id(self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Score: """ Get a score @@ -695,9 +611,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/scores/{jsonable_encoder(score_id)}", - method="GET", - request_options=request_options, + f"api/public/scores/{jsonable_encoder(score_id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -705,29 +619,19 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def delete( - self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> None: + async def delete(self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ Delete a score @@ -768,9 +672,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/scores/{jsonable_encoder(score_id)}", - method="DELETE", - request_options=request_options, + f"api/public/scores/{jsonable_encoder(score_id)}", method="DELETE", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -778,21 +680,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/score/types/create_score_request.py b/langfuse/api/resources/score/types/create_score_request.py index 8a76f464e..d08990189 100644 --- a/langfuse/api/resources/score/types/create_score_request.py +++ b/langfuse/api/resources/score/types/create_score_request.py @@ -30,13 +30,9 @@ class CreateScoreRequest(pydantic_v1.BaseModel): The value of the score. Must be passed as string for categorical scores, and numeric for boolean and numeric scores. Boolean score values must equal either 1 or 0 (true or false) """ - observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="observationId", default=None - ) + observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) comment: typing.Optional[str] = None - data_type: typing.Optional[ScoreDataType] = pydantic_v1.Field( - alias="dataType", default=None - ) + data_type: typing.Optional[ScoreDataType] = pydantic_v1.Field(alias="dataType", default=None) """ The data type of the score. When passing a configId this field is inferred. Otherwise, this field must be passed or will default to numeric. """ @@ -47,28 +43,15 @@ class CreateScoreRequest(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/score/types/create_score_response.py b/langfuse/api/resources/score/types/create_score_response.py index a8c90fce2..db7fba163 100644 --- a/langfuse/api/resources/score/types/create_score_response.py +++ b/langfuse/api/resources/score/types/create_score_response.py @@ -14,28 +14,15 @@ class CreateScoreResponse(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/score/types/get_scores_response.py b/langfuse/api/resources/score/types/get_scores_response.py index 777bb799b..820697ec7 100644 --- a/langfuse/api/resources/score/types/get_scores_response.py +++ b/langfuse/api/resources/score/types/get_scores_response.py @@ -14,28 +14,15 @@ class GetScoresResponse(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/score/types/get_scores_response_data.py b/langfuse/api/resources/score/types/get_scores_response_data.py index e1b317975..dbc65673f 100644 --- a/langfuse/api/resources/score/types/get_scores_response_data.py +++ b/langfuse/api/resources/score/types/get_scores_response_data.py @@ -18,45 +18,26 @@ class GetScoresResponseData_Numeric(pydantic_v1.BaseModel): trace_id: str = pydantic_v1.Field(alias="traceId") name: str source: ScoreSource - observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="observationId", default=None - ) + observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) timestamp: dt.datetime created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") - author_user_id: typing.Optional[str] = pydantic_v1.Field( - alias="authorUserId", default=None - ) + author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) comment: typing.Optional[str] = None config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) - data_type: typing.Literal["NUMERIC"] = pydantic_v1.Field( - alias="dataType", default="NUMERIC" - ) + data_type: typing.Literal["NUMERIC"] = pydantic_v1.Field(alias="dataType", default="NUMERIC") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -76,45 +57,26 @@ class GetScoresResponseData_Categorical(pydantic_v1.BaseModel): trace_id: str = pydantic_v1.Field(alias="traceId") name: str source: ScoreSource - observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="observationId", default=None - ) + observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) timestamp: dt.datetime created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") - author_user_id: typing.Optional[str] = pydantic_v1.Field( - alias="authorUserId", default=None - ) + author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) comment: typing.Optional[str] = None config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) - data_type: typing.Literal["CATEGORICAL"] = pydantic_v1.Field( - alias="dataType", default="CATEGORICAL" - ) + data_type: typing.Literal["CATEGORICAL"] = pydantic_v1.Field(alias="dataType", default="CATEGORICAL") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -134,45 +96,26 @@ class GetScoresResponseData_Boolean(pydantic_v1.BaseModel): trace_id: str = pydantic_v1.Field(alias="traceId") name: str source: ScoreSource - observation_id: typing.Optional[str] = pydantic_v1.Field( - alias="observationId", default=None - ) + observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) timestamp: dt.datetime created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") - author_user_id: typing.Optional[str] = pydantic_v1.Field( - alias="authorUserId", default=None - ) + author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) comment: typing.Optional[str] = None config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) - data_type: typing.Literal["BOOLEAN"] = pydantic_v1.Field( - alias="dataType", default="BOOLEAN" - ) + data_type: typing.Literal["BOOLEAN"] = pydantic_v1.Field(alias="dataType", default="BOOLEAN") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: @@ -185,7 +128,5 @@ class Config: GetScoresResponseData = typing.Union[ - GetScoresResponseData_Numeric, - GetScoresResponseData_Categorical, - GetScoresResponseData_Boolean, + GetScoresResponseData_Numeric, GetScoresResponseData_Categorical, GetScoresResponseData_Boolean ] diff --git a/langfuse/api/resources/score/types/get_scores_response_data_boolean.py b/langfuse/api/resources/score/types/get_scores_response_data_boolean.py index 4dbf85af2..00df659d1 100644 --- a/langfuse/api/resources/score/types/get_scores_response_data_boolean.py +++ b/langfuse/api/resources/score/types/get_scores_response_data_boolean.py @@ -13,28 +13,15 @@ class GetScoresResponseDataBoolean(BooleanScore): trace: GetScoresResponseTraceData def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/score/types/get_scores_response_data_categorical.py b/langfuse/api/resources/score/types/get_scores_response_data_categorical.py index 3c619779f..4cb2de853 100644 --- a/langfuse/api/resources/score/types/get_scores_response_data_categorical.py +++ b/langfuse/api/resources/score/types/get_scores_response_data_categorical.py @@ -13,28 +13,15 @@ class GetScoresResponseDataCategorical(CategoricalScore): trace: GetScoresResponseTraceData def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/score/types/get_scores_response_data_numeric.py b/langfuse/api/resources/score/types/get_scores_response_data_numeric.py index 127d8f028..8f5814973 100644 --- a/langfuse/api/resources/score/types/get_scores_response_data_numeric.py +++ b/langfuse/api/resources/score/types/get_scores_response_data_numeric.py @@ -13,28 +13,15 @@ class GetScoresResponseDataNumeric(NumericScore): trace: GetScoresResponseTraceData def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/score/types/get_scores_response_trace_data.py b/langfuse/api/resources/score/types/get_scores_response_trace_data.py index efbafadf4..42d14fe5f 100644 --- a/langfuse/api/resources/score/types/get_scores_response_trace_data.py +++ b/langfuse/api/resources/score/types/get_scores_response_trace_data.py @@ -19,28 +19,15 @@ class GetScoresResponseTraceData(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/score_configs/client.py b/langfuse/api/resources/score_configs/client.py index 5f8463612..886ac95fe 100644 --- a/langfuse/api/resources/score_configs/client.py +++ b/langfuse/api/resources/score_configs/client.py @@ -26,10 +26,7 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def create( - self, - *, - request: CreateScoreConfigRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreateScoreConfigRequest, request_options: typing.Optional[RequestOptions] = None ) -> ScoreConfig: """ Create a score configuration (config). Score configs are used to define the structure of scores @@ -75,11 +72,7 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/score-configs", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/score-configs", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -87,21 +80,13 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -161,29 +146,19 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def get_by_id( - self, config_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> ScoreConfig: + def get_by_id(self, config_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ScoreConfig: """ Get a score config @@ -216,9 +191,7 @@ def get_by_id( ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/score-configs/{jsonable_encoder(config_id)}", - method="GET", - request_options=request_options, + f"api/public/score-configs/{jsonable_encoder(config_id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -226,21 +199,13 @@ def get_by_id( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -252,10 +217,7 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def create( - self, - *, - request: CreateScoreConfigRequest, - request_options: typing.Optional[RequestOptions] = None, + self, *, request: CreateScoreConfigRequest, request_options: typing.Optional[RequestOptions] = None ) -> ScoreConfig: """ Create a score configuration (config). Score configs are used to define the structure of scores @@ -309,11 +271,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/score-configs", - method="POST", - json=request, - request_options=request_options, - omit=OMIT, + "api/public/score-configs", method="POST", json=request, request_options=request_options, omit=OMIT ) try: if 200 <= _response.status_code < 300: @@ -321,21 +279,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -403,21 +353,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -466,9 +408,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/score-configs/{jsonable_encoder(config_id)}", - method="GET", - request_options=request_options, + f"api/public/score-configs/{jsonable_encoder(config_id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -476,21 +416,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/score_configs/types/create_score_config_request.py b/langfuse/api/resources/score_configs/types/create_score_config_request.py index e136af157..bec260d3b 100644 --- a/langfuse/api/resources/score_configs/types/create_score_config_request.py +++ b/langfuse/api/resources/score_configs/types/create_score_config_request.py @@ -12,23 +12,17 @@ class CreateScoreConfigRequest(pydantic_v1.BaseModel): name: str data_type: ScoreDataType = pydantic_v1.Field(alias="dataType") - categories: typing.Optional[typing.List[ConfigCategory]] = pydantic_v1.Field( - default=None - ) + categories: typing.Optional[typing.List[ConfigCategory]] = pydantic_v1.Field(default=None) """ Configure custom categories for categorical scores. Pass a list of objects with `label` and `value` properties. Categories are autogenerated for boolean configs and cannot be passed """ - min_value: typing.Optional[float] = pydantic_v1.Field( - alias="minValue", default=None - ) + min_value: typing.Optional[float] = pydantic_v1.Field(alias="minValue", default=None) """ Configure a minimum value for numerical scores. If not set, the minimum value defaults to -∞ """ - max_value: typing.Optional[float] = pydantic_v1.Field( - alias="maxValue", default=None - ) + max_value: typing.Optional[float] = pydantic_v1.Field(alias="maxValue", default=None) """ Configure a maximum value for numerical scores. If not set, the maximum value defaults to +∞ """ @@ -39,28 +33,15 @@ class CreateScoreConfigRequest(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/score_configs/types/score_configs.py b/langfuse/api/resources/score_configs/types/score_configs.py index fc84e28a3..6efb652c1 100644 --- a/langfuse/api/resources/score_configs/types/score_configs.py +++ b/langfuse/api/resources/score_configs/types/score_configs.py @@ -14,28 +14,15 @@ class ScoreConfigs(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/sessions/client.py b/langfuse/api/resources/sessions/client.py index 98c56e0fc..5add5230c 100644 --- a/langfuse/api/resources/sessions/client.py +++ b/langfuse/api/resources/sessions/client.py @@ -87,12 +87,8 @@ def list( params={ "page": page, "limit": limit, - "fromTimestamp": serialize_datetime(from_timestamp) - if from_timestamp is not None - else None, - "toTimestamp": serialize_datetime(to_timestamp) - if to_timestamp is not None - else None, + "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, + "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, }, request_options=request_options, ) @@ -102,32 +98,19 @@ def list( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def get( - self, - session_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> SessionWithTraces: + def get(self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> SessionWithTraces: """ Get a session. Please note that `traces` on this endpoint are not paginated, if you plan to fetch large sessions, consider `GET /api/public/traces?sessionId=` @@ -160,9 +143,7 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/sessions/{jsonable_encoder(session_id)}", - method="GET", - request_options=request_options, + f"api/public/sessions/{jsonable_encoder(session_id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -170,21 +151,13 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -266,12 +239,8 @@ async def main() -> None: params={ "page": page, "limit": limit, - "fromTimestamp": serialize_datetime(from_timestamp) - if from_timestamp is not None - else None, - "toTimestamp": serialize_datetime(to_timestamp) - if to_timestamp is not None - else None, + "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, + "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, }, request_options=request_options, ) @@ -281,31 +250,20 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def get( - self, - session_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> SessionWithTraces: """ Get a session. Please note that `traces` on this endpoint are not paginated, if you plan to fetch large sessions, consider `GET /api/public/traces?sessionId=` @@ -347,9 +305,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/sessions/{jsonable_encoder(session_id)}", - method="GET", - request_options=request_options, + f"api/public/sessions/{jsonable_encoder(session_id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -357,21 +313,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/sessions/types/paginated_sessions.py b/langfuse/api/resources/sessions/types/paginated_sessions.py index 5dd9fb497..c220490b9 100644 --- a/langfuse/api/resources/sessions/types/paginated_sessions.py +++ b/langfuse/api/resources/sessions/types/paginated_sessions.py @@ -14,28 +14,15 @@ class PaginatedSessions(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/trace/client.py b/langfuse/api/resources/trace/client.py index 0c33e90d5..8010105a1 100644 --- a/langfuse/api/resources/trace/client.py +++ b/langfuse/api/resources/trace/client.py @@ -23,9 +23,7 @@ class TraceClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def get( - self, trace_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> TraceWithFullDetails: + def get(self, trace_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> TraceWithFullDetails: """ Get a specific trace @@ -58,9 +56,7 @@ def get( ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/traces/{jsonable_encoder(trace_id)}", - method="GET", - request_options=request_options, + f"api/public/traces/{jsonable_encoder(trace_id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -68,21 +64,13 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -187,12 +175,8 @@ def list( "userId": user_id, "name": name, "sessionId": session_id, - "fromTimestamp": serialize_datetime(from_timestamp) - if from_timestamp is not None - else None, - "toTimestamp": serialize_datetime(to_timestamp) - if to_timestamp is not None - else None, + "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, + "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, "orderBy": order_by, "tags": tags, "version": version, @@ -206,21 +190,13 @@ def list( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -274,9 +250,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/traces/{jsonable_encoder(trace_id)}", - method="GET", - request_options=request_options, + f"api/public/traces/{jsonable_encoder(trace_id)}", method="GET", request_options=request_options ) try: if 200 <= _response.status_code < 300: @@ -284,21 +258,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -410,12 +376,8 @@ async def main() -> None: "userId": user_id, "name": name, "sessionId": session_id, - "fromTimestamp": serialize_datetime(from_timestamp) - if from_timestamp is not None - else None, - "toTimestamp": serialize_datetime(to_timestamp) - if to_timestamp is not None - else None, + "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, + "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, "orderBy": order_by, "tags": tags, "version": version, @@ -429,21 +391,13 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 403: - raise AccessDeniedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError( - pydantic_v1.parse_obj_as(typing.Any, _response.json()) - ) # type: ignore + raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/trace/types/sort.py b/langfuse/api/resources/trace/types/sort.py index 76a5045b6..b1e6bb79e 100644 --- a/langfuse/api/resources/trace/types/sort.py +++ b/langfuse/api/resources/trace/types/sort.py @@ -11,28 +11,15 @@ class Sort(pydantic_v1.BaseModel): id: str def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/trace/types/traces.py b/langfuse/api/resources/trace/types/traces.py index 09f58978f..e31dcce71 100644 --- a/langfuse/api/resources/trace/types/traces.py +++ b/langfuse/api/resources/trace/types/traces.py @@ -14,28 +14,15 @@ class Traces(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/resources/utils/resources/pagination/types/meta_response.py b/langfuse/api/resources/utils/resources/pagination/types/meta_response.py index 2d082c68f..8918812de 100644 --- a/langfuse/api/resources/utils/resources/pagination/types/meta_response.py +++ b/langfuse/api/resources/utils/resources/pagination/types/meta_response.py @@ -29,28 +29,15 @@ class MetaResponse(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, - **kwargs, - } + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) ) class Config: diff --git a/langfuse/api/tests/utils/test_http_client.py b/langfuse/api/tests/utils/test_http_client.py index 950fcdeb1..d1b274bde 100644 --- a/langfuse/api/tests/utils/test_http_client.py +++ b/langfuse/api/tests/utils/test_http_client.py @@ -1,7 +1,7 @@ # This file was auto-generated by Fern from our API Definition. -from langfuse.api.core.http_client import get_request_body -from langfuse.api.core.request_options import RequestOptions +from langfuse.core.http_client import get_request_body +from langfuse.core.request_options import RequestOptions def get_request_options() -> RequestOptions: @@ -9,17 +9,12 @@ def get_request_options() -> RequestOptions: def test_get_json_request_body() -> None: - json_body, data_body = get_request_body( - json={"hello": "world"}, data=None, request_options=None, omit=None - ) + json_body, data_body = get_request_body(json={"hello": "world"}, data=None, request_options=None, omit=None) assert json_body == {"hello": "world"} assert data_body is None json_body_extras, data_body_extras = get_request_body( - json={"goodbye": "world"}, - data=None, - request_options=get_request_options(), - omit=None, + json={"goodbye": "world"}, data=None, request_options=get_request_options(), omit=None ) assert json_body_extras == {"goodbye": "world", "see you": "later"} @@ -27,17 +22,12 @@ def test_get_json_request_body() -> None: def test_get_files_request_body() -> None: - json_body, data_body = get_request_body( - json=None, data={"hello": "world"}, request_options=None, omit=None - ) + json_body, data_body = get_request_body(json=None, data={"hello": "world"}, request_options=None, omit=None) assert data_body == {"hello": "world"} assert json_body is None json_body_extras, data_body_extras = get_request_body( - json=None, - data={"goodbye": "world"}, - request_options=get_request_options(), - omit=None, + json=None, data={"goodbye": "world"}, request_options=get_request_options(), omit=None ) assert data_body_extras == {"goodbye": "world", "see you": "later"} @@ -45,9 +35,7 @@ def test_get_files_request_body() -> None: def test_get_none_request_body() -> None: - json_body, data_body = get_request_body( - json=None, data=None, request_options=None, omit=None - ) + json_body, data_body = get_request_body(json=None, data=None, request_options=None, omit=None) assert data_body is None assert json_body is None diff --git a/langfuse/api/tests/utils/test_query_encoding.py b/langfuse/api/tests/utils/test_query_encoding.py index 9afa0ea78..d3e0d828b 100644 --- a/langfuse/api/tests/utils/test_query_encoding.py +++ b/langfuse/api/tests/utils/test_query_encoding.py @@ -1,18 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from langfuse.api.core.query_encoder import encode_query +from langfuse.core.query_encoder import encode_query def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == { - "hello world": "hello world" - } - assert encode_query({"hello_world": {"hello": "world"}}) == { - "hello_world[hello]": "world" - } - assert encode_query( - {"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"} - ) == { + assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} + assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { "hello_world[hello][world]": "today", "hello_world[test]": "this", "hi": "there", diff --git a/langfuse/client.py b/langfuse/client.py index cbcab973d..4430114d2 100644 --- a/langfuse/client.py +++ b/langfuse/client.py @@ -1357,6 +1357,31 @@ def create_prompt( handle_fern_exception(e) raise e + def update_prompt( + self, + prompt_name: str, + prompt_version: int, + new_labels: List[str] = [], + ): + """Update an existing prompt version in Langfuse. The Langfuse SDK prompt cache is invalidated for all prompts witht he specified name. + + Args: + prompt_id (str): The name/id of the prompt to update. + prompt_version (int): The version number of the prompt to update. + new_labels (List[str], optional): New labels to assign to the prompt version. Labels are unique across versions. The "latest" label is reserved and managed by Langfuse. Defaults to []. + + Returns: + Prompt: The updated prompt from the Langfuse API. + + """ + updated_prompt = self.client.prompt_version.update( + prompt_name=prompt_name, + version=prompt_version, + new_labels=new_labels, + ) + self.prompt_cache.invalidate(prompt_name) + return updated_prompt + def _url_encode(self, url: str) -> str: return urllib.parse.quote(url) diff --git a/langfuse/prompt_cache.py b/langfuse/prompt_cache.py index d51711490..67611d50d 100644 --- a/langfuse/prompt_cache.py +++ b/langfuse/prompt_cache.py @@ -152,6 +152,12 @@ def set(self, key: str, value: PromptClient, ttl_seconds: Optional[int]): self._cache[key] = PromptCacheItem(value, ttl_seconds) + def invalidate(self, prompt_name: str): + """Invalidate all cached prompts with the given prompt name.""" + for key in list(self._cache): + if key.startswith(prompt_name): + del self._cache[key] + def add_refresh_prompt_task(self, key: str, fetch_func): self._log.debug(f"Submitting refresh task for key: {key}") self._task_manager.add_task(key, fetch_func) diff --git a/tests/test_updating_prompt.py b/tests/test_updating_prompt.py new file mode 100644 index 000000000..cd8aae2a1 --- /dev/null +++ b/tests/test_updating_prompt.py @@ -0,0 +1,36 @@ +from time import sleep +import pytest +from unittest.mock import Mock, patch + +import openai +from langfuse.client import Langfuse +from langfuse.prompt_cache import PromptCacheItem, DEFAULT_PROMPT_CACHE_TTL_SECONDS +from tests.utils import create_uuid, get_api +from langfuse.api.resources.prompts import Prompt_Text, Prompt_Chat +from langfuse.model import TextPromptClient, ChatPromptClient + + +def test_update_prompt(): + langfuse = Langfuse() + prompt_name = create_uuid() + + # Create initial prompt + prompt_client = langfuse.create_prompt( + name=prompt_name, + prompt="test prompt", + labels=["production"], + ) + + # Update prompt labels + updated_prompt = langfuse.update_prompt( + prompt_name=prompt_name, prompt_version=1, new_labels=["john", "doe"] + ) + + # Fetch prompt after update (should be invalidated) + fetched_prompt = langfuse.get_prompt(prompt_name) + + # Verify the fetched prompt matches the updated values + assert fetched_prompt.name == prompt_name + assert fetched_prompt.version == 1 + assert fetched_prompt.labels == ["john", "doe"] + assert updated_prompt.labels == ["john", "doe"] From 95b04896fc166d17ffb0cc4eb42bffe2e74e7703 Mon Sep 17 00:00:00 2001 From: Max Deichmann Date: Mon, 20 Jan 2025 20:47:21 +0100 Subject: [PATCH 02/14] feat: update prompts and invalidate cache --- tests/test_updating_prompt.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tests/test_updating_prompt.py b/tests/test_updating_prompt.py index cd8aae2a1..43422e27b 100644 --- a/tests/test_updating_prompt.py +++ b/tests/test_updating_prompt.py @@ -1,13 +1,5 @@ -from time import sleep -import pytest -from unittest.mock import Mock, patch - -import openai from langfuse.client import Langfuse -from langfuse.prompt_cache import PromptCacheItem, DEFAULT_PROMPT_CACHE_TTL_SECONDS -from tests.utils import create_uuid, get_api -from langfuse.api.resources.prompts import Prompt_Text, Prompt_Chat -from langfuse.model import TextPromptClient, ChatPromptClient +from tests.utils import create_uuid def test_update_prompt(): From 9114ed568fee574bfa377ba43dc6038c1f6b738b Mon Sep 17 00:00:00 2001 From: Max Deichmann Date: Mon, 20 Jan 2025 20:52:00 +0100 Subject: [PATCH 03/14] feat: update prompts and invalidate cache --- tests/test_updating_prompt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_updating_prompt.py b/tests/test_updating_prompt.py index 43422e27b..81c60c311 100644 --- a/tests/test_updating_prompt.py +++ b/tests/test_updating_prompt.py @@ -7,7 +7,7 @@ def test_update_prompt(): prompt_name = create_uuid() # Create initial prompt - prompt_client = langfuse.create_prompt( + langfuse.create_prompt( name=prompt_name, prompt="test prompt", labels=["production"], From e5a12429ba34ad5f3db2f47613c99e86b49d9c67 Mon Sep 17 00:00:00 2001 From: Max Deichmann Date: Mon, 20 Jan 2025 21:27:32 +0100 Subject: [PATCH 04/14] feat: update prompts and invalidate cache --- langfuse/api/client.py | 50 ++-- langfuse/api/core/api_error.py | 4 +- langfuse/api/core/client_wrapper.py | 6 +- langfuse/api/core/datetime_utils.py | 4 +- langfuse/api/core/file.py | 9 +- langfuse/api/core/http_client.py | 147 +++++++++--- langfuse/api/core/jsonable_encoder.py | 14 +- langfuse/api/core/query_encoder.py | 10 +- langfuse/api/resources/comments/client.py | 140 +++++++++--- .../comments/types/create_comment_request.py | 25 +- .../comments/types/create_comment_response.py | 21 +- .../comments/types/get_comments_response.py | 21 +- langfuse/api/resources/commons/__init__.py | 8 +- .../api/resources/commons/errors/__init__.py | 8 +- .../resources/commons/types/base_prompt.py | 21 +- .../api/resources/commons/types/base_score.py | 29 ++- .../resources/commons/types/boolean_score.py | 21 +- .../commons/types/categorical_score.py | 21 +- .../resources/commons/types/chat_message.py | 21 +- .../resources/commons/types/chat_prompt.py | 21 +- .../api/resources/commons/types/comment.py | 25 +- .../commons/types/config_category.py | 21 +- .../api/resources/commons/types/dataset.py | 21 +- .../resources/commons/types/dataset_item.py | 33 ++- .../resources/commons/types/dataset_run.py | 21 +- .../commons/types/dataset_run_item.py | 25 +- .../commons/types/dataset_run_with_items.py | 25 +- .../resources/commons/types/dataset_status.py | 6 +- .../api/resources/commons/types/map_value.py | 5 +- langfuse/api/resources/commons/types/model.py | 45 +++- .../resources/commons/types/numeric_score.py | 21 +- .../resources/commons/types/observation.py | 45 +++- .../commons/types/observations_view.py | 57 +++-- .../api/resources/commons/types/prompt.py | 42 +++- langfuse/api/resources/commons/types/score.py | 99 ++++++-- .../resources/commons/types/score_config.py | 33 ++- .../api/resources/commons/types/session.py | 21 +- .../commons/types/session_with_traces.py | 21 +- .../resources/commons/types/text_prompt.py | 21 +- langfuse/api/resources/commons/types/trace.py | 25 +- .../commons/types/trace_with_details.py | 21 +- .../commons/types/trace_with_full_details.py | 21 +- langfuse/api/resources/commons/types/usage.py | 33 ++- .../api/resources/dataset_items/client.py | 134 ++++++++--- .../types/create_dataset_item_request.py | 33 ++- .../types/paginated_dataset_items.py | 21 +- .../api/resources/dataset_run_items/client.py | 54 ++++- .../types/create_dataset_run_item_request.py | 29 ++- langfuse/api/resources/datasets/client.py | 216 ++++++++++++++---- .../datasets/types/create_dataset_request.py | 21 +- .../datasets/types/paginated_dataset_runs.py | 21 +- .../datasets/types/paginated_datasets.py | 21 +- langfuse/api/resources/health/client.py | 40 +++- .../resources/health/types/health_response.py | 21 +- langfuse/api/resources/ingestion/client.py | 36 ++- .../resources/ingestion/types/base_event.py | 21 +- .../ingestion/types/create_event_body.py | 21 +- .../ingestion/types/create_event_event.py | 21 +- .../ingestion/types/create_generation_body.py | 41 +++- .../types/create_generation_event.py | 21 +- .../types/create_observation_event.py | 21 +- .../ingestion/types/create_span_body.py | 25 +- .../ingestion/types/create_span_event.py | 21 +- .../ingestion/types/ingestion_error.py | 21 +- .../ingestion/types/ingestion_event.py | 210 +++++++++++++---- .../ingestion/types/ingestion_response.py | 21 +- .../ingestion/types/ingestion_success.py | 21 +- .../ingestion/types/observation_body.py | 41 +++- .../ingestion/types/open_ai_usage.py | 33 ++- .../ingestion/types/open_ai_usage_schema.py | 21 +- .../types/optional_observation_body.py | 33 ++- .../resources/ingestion/types/score_body.py | 29 ++- .../resources/ingestion/types/score_event.py | 21 +- .../resources/ingestion/types/sdk_log_body.py | 21 +- .../ingestion/types/sdk_log_event.py | 21 +- .../resources/ingestion/types/trace_body.py | 25 +- .../resources/ingestion/types/trace_event.py | 21 +- .../ingestion/types/update_event_body.py | 21 +- .../ingestion/types/update_generation_body.py | 41 +++- .../types/update_generation_event.py | 21 +- .../types/update_observation_event.py | 21 +- .../ingestion/types/update_span_body.py | 25 +- .../ingestion/types/update_span_event.py | 21 +- langfuse/api/resources/media/client.py | 154 ++++++++++--- .../media/types/get_media_response.py | 21 +- .../types/get_media_upload_url_request.py | 25 +- .../types/get_media_upload_url_response.py | 25 +- .../resources/media/types/patch_media_body.py | 29 ++- langfuse/api/resources/metrics/client.py | 52 +++-- .../resources/metrics/types/daily_metrics.py | 21 +- .../metrics/types/daily_metrics_details.py | 21 +- .../resources/metrics/types/usage_by_model.py | 21 +- langfuse/api/resources/models/client.py | 194 ++++++++++++---- .../models/types/create_model_request.py | 45 +++- .../models/types/paginated_models.py | 21 +- langfuse/api/resources/observations/client.py | 100 ++++++-- .../observations/types/observations.py | 21 +- .../observations/types/observations_views.py | 21 +- langfuse/api/resources/projects/client.py | 40 +++- .../api/resources/projects/types/project.py | 21 +- .../api/resources/projects/types/projects.py | 21 +- .../api/resources/prompt_version/client.py | 32 ++- langfuse/api/resources/prompts/client.py | 142 +++++++++--- .../api/resources/prompts/types/__init__.py | 6 +- .../types/create_chat_prompt_request.py | 21 +- .../prompts/types/create_prompt_request.py | 42 +++- .../types/create_text_prompt_request.py | 21 +- .../resources/prompts/types/prompt_meta.py | 21 +- .../types/prompt_meta_list_response.py | 21 +- langfuse/api/resources/score/client.py | 206 +++++++++++++---- .../score/types/create_score_request.py | 29 ++- .../score/types/create_score_response.py | 21 +- .../score/types/get_scores_response.py | 21 +- .../score/types/get_scores_response_data.py | 103 +++++++-- .../types/get_scores_response_data_boolean.py | 21 +- .../get_scores_response_data_categorical.py | 21 +- .../types/get_scores_response_data_numeric.py | 21 +- .../types/get_scores_response_trace_data.py | 21 +- .../api/resources/score_configs/client.py | 130 ++++++++--- .../types/create_score_config_request.py | 33 ++- .../score_configs/types/score_configs.py | 21 +- langfuse/api/resources/sessions/client.py | 100 ++++++-- .../sessions/types/paginated_sessions.py | 21 +- langfuse/api/resources/trace/client.py | 92 ++++++-- langfuse/api/resources/trace/types/sort.py | 21 +- langfuse/api/resources/trace/types/traces.py | 21 +- .../pagination/types/meta_response.py | 21 +- langfuse/api/tests/utils/test_http_client.py | 22 +- .../api/tests/utils/test_query_encoding.py | 12 +- 129 files changed, 3862 insertions(+), 1071 deletions(-) diff --git a/langfuse/api/client.py b/langfuse/api/client.py index ce6e8577b..932f5f3c2 100644 --- a/langfuse/api/client.py +++ b/langfuse/api/client.py @@ -7,7 +7,10 @@ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .resources.comments.client import AsyncCommentsClient, CommentsClient from .resources.dataset_items.client import AsyncDatasetItemsClient, DatasetItemsClient -from .resources.dataset_run_items.client import AsyncDatasetRunItemsClient, DatasetRunItemsClient +from .resources.dataset_run_items.client import ( + AsyncDatasetRunItemsClient, + DatasetRunItemsClient, +) from .resources.datasets.client import AsyncDatasetsClient, DatasetsClient from .resources.health.client import AsyncHealthClient, HealthClient from .resources.ingestion.client import AsyncIngestionClient, IngestionClient @@ -16,7 +19,10 @@ from .resources.models.client import AsyncModelsClient, ModelsClient from .resources.observations.client import AsyncObservationsClient, ObservationsClient from .resources.projects.client import AsyncProjectsClient, ProjectsClient -from .resources.prompt_version.client import AsyncPromptVersionClient, PromptVersionClient +from .resources.prompt_version.client import ( + AsyncPromptVersionClient, + PromptVersionClient, +) from .resources.prompts.client import AsyncPromptsClient, PromptsClient from .resources.score.client import AsyncScoreClient, ScoreClient from .resources.score_configs.client import AsyncScoreConfigsClient, ScoreConfigsClient @@ -72,9 +78,11 @@ def __init__( password: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, timeout: typing.Optional[float] = None, follow_redirects: typing.Optional[bool] = True, - httpx_client: typing.Optional[httpx.Client] = None + httpx_client: typing.Optional[httpx.Client] = None, ): - _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None + _defaulted_timeout = ( + timeout if timeout is not None else 60 if httpx_client is None else None + ) self._client_wrapper = SyncClientWrapper( base_url=base_url, x_langfuse_sdk_name=x_langfuse_sdk_name, @@ -84,14 +92,18 @@ def __init__( password=password, httpx_client=httpx_client if httpx_client is not None - else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects) + else httpx.Client( + timeout=_defaulted_timeout, follow_redirects=follow_redirects + ) if follow_redirects is not None else httpx.Client(timeout=_defaulted_timeout), timeout=_defaulted_timeout, ) self.comments = CommentsClient(client_wrapper=self._client_wrapper) self.dataset_items = DatasetItemsClient(client_wrapper=self._client_wrapper) - self.dataset_run_items = DatasetRunItemsClient(client_wrapper=self._client_wrapper) + self.dataset_run_items = DatasetRunItemsClient( + client_wrapper=self._client_wrapper + ) self.datasets = DatasetsClient(client_wrapper=self._client_wrapper) self.health = HealthClient(client_wrapper=self._client_wrapper) self.ingestion = IngestionClient(client_wrapper=self._client_wrapper) @@ -156,9 +168,11 @@ def __init__( password: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, timeout: typing.Optional[float] = None, follow_redirects: typing.Optional[bool] = True, - httpx_client: typing.Optional[httpx.AsyncClient] = None + httpx_client: typing.Optional[httpx.AsyncClient] = None, ): - _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None + _defaulted_timeout = ( + timeout if timeout is not None else 60 if httpx_client is None else None + ) self._client_wrapper = AsyncClientWrapper( base_url=base_url, x_langfuse_sdk_name=x_langfuse_sdk_name, @@ -168,14 +182,20 @@ def __init__( password=password, httpx_client=httpx_client if httpx_client is not None - else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects) + else httpx.AsyncClient( + timeout=_defaulted_timeout, follow_redirects=follow_redirects + ) if follow_redirects is not None else httpx.AsyncClient(timeout=_defaulted_timeout), timeout=_defaulted_timeout, ) self.comments = AsyncCommentsClient(client_wrapper=self._client_wrapper) - self.dataset_items = AsyncDatasetItemsClient(client_wrapper=self._client_wrapper) - self.dataset_run_items = AsyncDatasetRunItemsClient(client_wrapper=self._client_wrapper) + self.dataset_items = AsyncDatasetItemsClient( + client_wrapper=self._client_wrapper + ) + self.dataset_run_items = AsyncDatasetRunItemsClient( + client_wrapper=self._client_wrapper + ) self.datasets = AsyncDatasetsClient(client_wrapper=self._client_wrapper) self.health = AsyncHealthClient(client_wrapper=self._client_wrapper) self.ingestion = AsyncIngestionClient(client_wrapper=self._client_wrapper) @@ -184,9 +204,13 @@ def __init__( self.models = AsyncModelsClient(client_wrapper=self._client_wrapper) self.observations = AsyncObservationsClient(client_wrapper=self._client_wrapper) self.projects = AsyncProjectsClient(client_wrapper=self._client_wrapper) - self.prompt_version = AsyncPromptVersionClient(client_wrapper=self._client_wrapper) + self.prompt_version = AsyncPromptVersionClient( + client_wrapper=self._client_wrapper + ) self.prompts = AsyncPromptsClient(client_wrapper=self._client_wrapper) - self.score_configs = AsyncScoreConfigsClient(client_wrapper=self._client_wrapper) + self.score_configs = AsyncScoreConfigsClient( + client_wrapper=self._client_wrapper + ) self.score = AsyncScoreClient(client_wrapper=self._client_wrapper) self.sessions = AsyncSessionsClient(client_wrapper=self._client_wrapper) self.trace = AsyncTraceClient(client_wrapper=self._client_wrapper) diff --git a/langfuse/api/core/api_error.py b/langfuse/api/core/api_error.py index 2e9fc5431..da734b580 100644 --- a/langfuse/api/core/api_error.py +++ b/langfuse/api/core/api_error.py @@ -7,7 +7,9 @@ class ApiError(Exception): status_code: typing.Optional[int] body: typing.Any - def __init__(self, *, status_code: typing.Optional[int] = None, body: typing.Any = None): + def __init__( + self, *, status_code: typing.Optional[int] = None, body: typing.Any = None + ): self.status_code = status_code self.body = body diff --git a/langfuse/api/core/client_wrapper.py b/langfuse/api/core/client_wrapper.py index 49932db6c..8a053f4a7 100644 --- a/langfuse/api/core/client_wrapper.py +++ b/langfuse/api/core/client_wrapper.py @@ -17,7 +17,7 @@ def __init__( username: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, password: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, base_url: str, - timeout: typing.Optional[float] = None + timeout: typing.Optional[float] = None, ): self._x_langfuse_sdk_name = x_langfuse_sdk_name self._x_langfuse_sdk_version = x_langfuse_sdk_version @@ -71,7 +71,7 @@ def __init__( password: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, base_url: str, timeout: typing.Optional[float] = None, - httpx_client: httpx.Client + httpx_client: httpx.Client, ): super().__init__( x_langfuse_sdk_name=x_langfuse_sdk_name, @@ -101,7 +101,7 @@ def __init__( password: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, base_url: str, timeout: typing.Optional[float] = None, - httpx_client: httpx.AsyncClient + httpx_client: httpx.AsyncClient, ): super().__init__( x_langfuse_sdk_name=x_langfuse_sdk_name, diff --git a/langfuse/api/core/datetime_utils.py b/langfuse/api/core/datetime_utils.py index 7c9864a94..47344e9d9 100644 --- a/langfuse/api/core/datetime_utils.py +++ b/langfuse/api/core/datetime_utils.py @@ -13,7 +13,9 @@ def serialize_datetime(v: dt.datetime) -> str: """ def _serialize_zoned_datetime(v: dt.datetime) -> str: - if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None): + if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname( + None + ): # UTC is a special case where we use "Z" at the end instead of "+00:00" return v.isoformat().replace("+00:00", "Z") else: diff --git a/langfuse/api/core/file.py b/langfuse/api/core/file.py index cb0d40bbb..6e0f92bfc 100644 --- a/langfuse/api/core/file.py +++ b/langfuse/api/core/file.py @@ -13,12 +13,17 @@ # (filename, file (or bytes), content_type) typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str]], # (filename, file (or bytes), content_type, headers) - typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str], typing.Mapping[str, str]], + typing.Tuple[ + typing.Optional[str], + FileContent, + typing.Optional[str], + typing.Mapping[str, str], + ], ] def convert_file_dict_to_httpx_tuples( - d: typing.Dict[str, typing.Union[File, typing.List[File]]] + d: typing.Dict[str, typing.Union[File, typing.List[File]]], ) -> typing.List[typing.Tuple[str, File]]: """ The format we use is a list of tuples, where the first element is the diff --git a/langfuse/api/core/http_client.py b/langfuse/api/core/http_client.py index 9333d8a7f..091f71bc1 100644 --- a/langfuse/api/core/http_client.py +++ b/langfuse/api/core/http_client.py @@ -77,7 +77,9 @@ def _retry_timeout(response: httpx.Response, retries: int) -> float: return retry_after # Apply exponential backoff, capped at MAX_RETRY_DELAY_SECONDS. - retry_delay = min(INITIAL_RETRY_DELAY_SECONDS * pow(2.0, retries), MAX_RETRY_DELAY_SECONDS) + retry_delay = min( + INITIAL_RETRY_DELAY_SECONDS * pow(2.0, retries), MAX_RETRY_DELAY_SECONDS + ) # Add a randomness / jitter to the retry delay to avoid overwhelming the server with retries. timeout = retry_delay * (1 - 0.25 * random()) @@ -90,7 +92,8 @@ def _should_retry(response: httpx.Response) -> bool: def remove_omit_from_dict( - original: typing.Dict[str, typing.Optional[typing.Any]], omit: typing.Optional[typing.Any] + original: typing.Dict[str, typing.Optional[typing.Any]], + omit: typing.Optional[typing.Any], ) -> typing.Dict[str, typing.Any]: if omit is None: return original @@ -108,7 +111,8 @@ def maybe_filter_request_body( ) -> typing.Optional[typing.Any]: if data is None: return ( - jsonable_encoder(request_options.get("additional_body_parameters", {})) or {} + jsonable_encoder(request_options.get("additional_body_parameters", {})) + or {} if request_options is not None else None ) @@ -118,7 +122,8 @@ def maybe_filter_request_body( data_content = { **(jsonable_encoder(remove_omit_from_dict(data, omit))), # type: ignore **( - jsonable_encoder(request_options.get("additional_body_parameters", {})) or {} + jsonable_encoder(request_options.get("additional_body_parameters", {})) + or {} if request_options is not None else {} ), @@ -162,7 +167,9 @@ def __init__( def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str: base_url = self.base_url if maybe_base_url is None else maybe_base_url if base_url is None: - raise ValueError("A base_url is required to make this request, please provide one and try again.") + raise ValueError( + "A base_url is required to make this request, please provide one and try again." + ) return base_url def request( @@ -174,8 +181,12 @@ def request( params: typing.Optional[typing.Dict[str, typing.Any]] = None, json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, - content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, - files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + content: typing.Optional[ + typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]] + ] = None, + files: typing.Optional[ + typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]] + ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, retries: int = 0, @@ -184,11 +195,14 @@ def request( base_url = self.get_base_url(base_url) timeout = ( request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None + if request_options is not None + and request_options.get("timeout_in_seconds") is not None else self.base_timeout ) - json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + json_body, data_body = get_request_body( + json=json, data=data, request_options=request_options, omit=omit + ) response = self.httpx_client.request( method=method, @@ -198,7 +212,11 @@ def request( { **self.base_headers, **(headers if headers is not None else {}), - **(request_options.get("additional_headers", {}) or {} if request_options is not None else {}), + **( + request_options.get("additional_headers", {}) or {} + if request_options is not None + else {} + ), } ) ), @@ -209,7 +227,10 @@ def request( { **(params if params is not None else {}), **( - request_options.get("additional_query_parameters", {}) or {} + request_options.get( + "additional_query_parameters", {} + ) + or {} if request_options is not None else {} ), @@ -222,11 +243,15 @@ def request( json=json_body, data=data_body, content=content, - files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) + if files is not None + else None, timeout=timeout, ) - max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0 + max_retries: int = ( + request_options.get("max_retries", 0) if request_options is not None else 0 + ) if _should_retry(response=response): if max_retries > retries: time.sleep(_retry_timeout(response=response, retries=retries)) @@ -256,8 +281,12 @@ def stream( params: typing.Optional[typing.Dict[str, typing.Any]] = None, json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, - content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, - files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + content: typing.Optional[ + typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]] + ] = None, + files: typing.Optional[ + typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]] + ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, retries: int = 0, @@ -266,11 +295,14 @@ def stream( base_url = self.get_base_url(base_url) timeout = ( request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None + if request_options is not None + and request_options.get("timeout_in_seconds") is not None else self.base_timeout ) - json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + json_body, data_body = get_request_body( + json=json, data=data, request_options=request_options, omit=omit + ) with self.httpx_client.stream( method=method, @@ -280,7 +312,11 @@ def stream( { **self.base_headers, **(headers if headers is not None else {}), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), + **( + request_options.get("additional_headers", {}) + if request_options is not None + else {} + ), } ) ), @@ -291,7 +327,9 @@ def stream( { **(params if params is not None else {}), **( - request_options.get("additional_query_parameters", {}) + request_options.get( + "additional_query_parameters", {} + ) if request_options is not None else {} ), @@ -304,7 +342,9 @@ def stream( json=json_body, data=data_body, content=content, - files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) + if files is not None + else None, timeout=timeout, ) as stream: yield stream @@ -327,7 +367,9 @@ def __init__( def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str: base_url = self.base_url if maybe_base_url is None else maybe_base_url if base_url is None: - raise ValueError("A base_url is required to make this request, please provide one and try again.") + raise ValueError( + "A base_url is required to make this request, please provide one and try again." + ) return base_url async def request( @@ -339,8 +381,12 @@ async def request( params: typing.Optional[typing.Dict[str, typing.Any]] = None, json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, - content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, - files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + content: typing.Optional[ + typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]] + ] = None, + files: typing.Optional[ + typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]] + ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, retries: int = 0, @@ -349,11 +395,14 @@ async def request( base_url = self.get_base_url(base_url) timeout = ( request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None + if request_options is not None + and request_options.get("timeout_in_seconds") is not None else self.base_timeout ) - json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + json_body, data_body = get_request_body( + json=json, data=data, request_options=request_options, omit=omit + ) # Add the input to each of these and do None-safety checks response = await self.httpx_client.request( @@ -364,7 +413,11 @@ async def request( { **self.base_headers, **(headers if headers is not None else {}), - **(request_options.get("additional_headers", {}) or {} if request_options is not None else {}), + **( + request_options.get("additional_headers", {}) or {} + if request_options is not None + else {} + ), } ) ), @@ -375,7 +428,10 @@ async def request( { **(params if params is not None else {}), **( - request_options.get("additional_query_parameters", {}) or {} + request_options.get( + "additional_query_parameters", {} + ) + or {} if request_options is not None else {} ), @@ -388,11 +444,15 @@ async def request( json=json_body, data=data_body, content=content, - files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) + if files is not None + else None, timeout=timeout, ) - max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0 + max_retries: int = ( + request_options.get("max_retries", 0) if request_options is not None else 0 + ) if _should_retry(response=response): if max_retries > retries: await asyncio.sleep(_retry_timeout(response=response, retries=retries)) @@ -421,8 +481,12 @@ async def stream( params: typing.Optional[typing.Dict[str, typing.Any]] = None, json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, - content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, - files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + content: typing.Optional[ + typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]] + ] = None, + files: typing.Optional[ + typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]] + ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, retries: int = 0, @@ -431,11 +495,14 @@ async def stream( base_url = self.get_base_url(base_url) timeout = ( request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None + if request_options is not None + and request_options.get("timeout_in_seconds") is not None else self.base_timeout ) - json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + json_body, data_body = get_request_body( + json=json, data=data, request_options=request_options, omit=omit + ) async with self.httpx_client.stream( method=method, @@ -445,7 +512,11 @@ async def stream( { **self.base_headers, **(headers if headers is not None else {}), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), + **( + request_options.get("additional_headers", {}) + if request_options is not None + else {} + ), } ) ), @@ -456,7 +527,9 @@ async def stream( { **(params if params is not None else {}), **( - request_options.get("additional_query_parameters", {}) + request_options.get( + "additional_query_parameters", {} + ) if request_options is not None else {} ), @@ -469,7 +542,9 @@ async def stream( json=json_body, data=data_body, content=content, - files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) + if files is not None + else None, timeout=timeout, ) as stream: yield stream diff --git a/langfuse/api/core/jsonable_encoder.py b/langfuse/api/core/jsonable_encoder.py index f09aaf6b9..7a05e9190 100644 --- a/langfuse/api/core/jsonable_encoder.py +++ b/langfuse/api/core/jsonable_encoder.py @@ -25,18 +25,24 @@ def generate_encoders_by_class_tuples( - type_encoder_map: Dict[Any, Callable[[Any], Any]] + type_encoder_map: Dict[Any, Callable[[Any], Any]], ) -> Dict[Callable[[Any], Any], Tuple[Any, ...]]: - encoders_by_class_tuples: Dict[Callable[[Any], Any], Tuple[Any, ...]] = defaultdict(tuple) + encoders_by_class_tuples: Dict[Callable[[Any], Any], Tuple[Any, ...]] = defaultdict( + tuple + ) for type_, encoder in type_encoder_map.items(): encoders_by_class_tuples[encoder] += (type_,) return encoders_by_class_tuples -encoders_by_class_tuples = generate_encoders_by_class_tuples(pydantic_v1.json.ENCODERS_BY_TYPE) +encoders_by_class_tuples = generate_encoders_by_class_tuples( + pydantic_v1.json.ENCODERS_BY_TYPE +) -def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any: +def jsonable_encoder( + obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None +) -> Any: custom_encoder = custom_encoder or {} if custom_encoder: if type(obj) in custom_encoder: diff --git a/langfuse/api/core/query_encoder.py b/langfuse/api/core/query_encoder.py index 1f5f766b4..069633086 100644 --- a/langfuse/api/core/query_encoder.py +++ b/langfuse/api/core/query_encoder.py @@ -7,7 +7,9 @@ # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: +def traverse_query_dict( + dict_flat: Dict[str, Any], key_prefix: Optional[str] = None +) -> Dict[str, Any]: result = {} for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k @@ -30,4 +32,8 @@ def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return ( + dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) + if query is not None + else None + ) diff --git a/langfuse/api/resources/comments/client.py b/langfuse/api/resources/comments/client.py index 83e06cf4f..9d84948a3 100644 --- a/langfuse/api/resources/comments/client.py +++ b/langfuse/api/resources/comments/client.py @@ -27,7 +27,10 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def create( - self, *, request: CreateCommentRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreateCommentRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> CreateCommentResponse: """ Create a comment. Comments may be attached to different object types (trace, observation, session, prompt). @@ -67,7 +70,11 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/comments", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/comments", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -75,13 +82,21 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -162,19 +177,32 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def get_by_id(self, comment_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Comment: + def get_by_id( + self, + comment_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> Comment: """ Get a comment by id @@ -207,7 +235,9 @@ def get_by_id(self, comment_id: str, *, request_options: typing.Optional[Request ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/comments/{jsonable_encoder(comment_id)}", method="GET", request_options=request_options + f"api/public/comments/{jsonable_encoder(comment_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -215,13 +245,21 @@ def get_by_id(self, comment_id: str, *, request_options: typing.Optional[Request if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -233,7 +271,10 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def create( - self, *, request: CreateCommentRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreateCommentRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> CreateCommentResponse: """ Create a comment. Comments may be attached to different object types (trace, observation, session, prompt). @@ -281,7 +322,11 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/comments", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/comments", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -289,13 +334,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -384,19 +437,32 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def get_by_id(self, comment_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Comment: + async def get_by_id( + self, + comment_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> Comment: """ Get a comment by id @@ -437,7 +503,9 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/comments/{jsonable_encoder(comment_id)}", method="GET", request_options=request_options + f"api/public/comments/{jsonable_encoder(comment_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -445,13 +513,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/comments/types/create_comment_request.py b/langfuse/api/resources/comments/types/create_comment_request.py index 2d8baf79a..9ba6081ee 100644 --- a/langfuse/api/resources/comments/types/create_comment_request.py +++ b/langfuse/api/resources/comments/types/create_comment_request.py @@ -28,21 +28,36 @@ class CreateCommentRequest(pydantic_v1.BaseModel): The content of the comment. May include markdown. Currently limited to 3000 characters. """ - author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) + author_user_id: typing.Optional[str] = pydantic_v1.Field( + alias="authorUserId", default=None + ) """ The id of the user who created the comment. """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/comments/types/create_comment_response.py b/langfuse/api/resources/comments/types/create_comment_response.py index 3bd2ac616..d7708f798 100644 --- a/langfuse/api/resources/comments/types/create_comment_response.py +++ b/langfuse/api/resources/comments/types/create_comment_response.py @@ -14,15 +14,28 @@ class CreateCommentResponse(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/comments/types/get_comments_response.py b/langfuse/api/resources/comments/types/get_comments_response.py index a52d5e0b1..66a8b9527 100644 --- a/langfuse/api/resources/comments/types/get_comments_response.py +++ b/langfuse/api/resources/comments/types/get_comments_response.py @@ -14,15 +14,28 @@ class GetCommentsResponse(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/__init__.py b/langfuse/api/resources/commons/__init__.py index f55e7c3c1..cfaf5a993 100644 --- a/langfuse/api/resources/commons/__init__.py +++ b/langfuse/api/resources/commons/__init__.py @@ -42,7 +42,13 @@ TraceWithFullDetails, Usage, ) -from .errors import AccessDeniedError, Error, MethodNotAllowedError, NotFoundError, UnauthorizedError +from .errors import ( + AccessDeniedError, + Error, + MethodNotAllowedError, + NotFoundError, + UnauthorizedError, +) __all__ = [ "AccessDeniedError", diff --git a/langfuse/api/resources/commons/errors/__init__.py b/langfuse/api/resources/commons/errors/__init__.py index eb5a67925..0aef2f92f 100644 --- a/langfuse/api/resources/commons/errors/__init__.py +++ b/langfuse/api/resources/commons/errors/__init__.py @@ -6,4 +6,10 @@ from .not_found_error import NotFoundError from .unauthorized_error import UnauthorizedError -__all__ = ["AccessDeniedError", "Error", "MethodNotAllowedError", "NotFoundError", "UnauthorizedError"] +__all__ = [ + "AccessDeniedError", + "Error", + "MethodNotAllowedError", + "NotFoundError", + "UnauthorizedError", +] diff --git a/langfuse/api/resources/commons/types/base_prompt.py b/langfuse/api/resources/commons/types/base_prompt.py index 2192f8b28..82934fbe6 100644 --- a/langfuse/api/resources/commons/types/base_prompt.py +++ b/langfuse/api/resources/commons/types/base_prompt.py @@ -22,15 +22,28 @@ class BasePrompt(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/base_score.py b/langfuse/api/resources/commons/types/base_score.py index f623ae909..71bed6ef4 100644 --- a/langfuse/api/resources/commons/types/base_score.py +++ b/langfuse/api/resources/commons/types/base_score.py @@ -13,11 +13,15 @@ class BaseScore(pydantic_v1.BaseModel): trace_id: str = pydantic_v1.Field(alias="traceId") name: str source: ScoreSource - observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) + observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="observationId", default=None + ) timestamp: dt.datetime created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") - author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) + author_user_id: typing.Optional[str] = pydantic_v1.Field( + alias="authorUserId", default=None + ) comment: typing.Optional[str] = None config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) """ @@ -30,15 +34,28 @@ class BaseScore(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/boolean_score.py b/langfuse/api/resources/commons/types/boolean_score.py index 7a97a9337..d838b7db9 100644 --- a/langfuse/api/resources/commons/types/boolean_score.py +++ b/langfuse/api/resources/commons/types/boolean_score.py @@ -20,15 +20,28 @@ class BooleanScore(BaseScore): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/categorical_score.py b/langfuse/api/resources/commons/types/categorical_score.py index 2bc86cb32..847caf47b 100644 --- a/langfuse/api/resources/commons/types/categorical_score.py +++ b/langfuse/api/resources/commons/types/categorical_score.py @@ -20,15 +20,28 @@ class CategoricalScore(BaseScore): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/chat_message.py b/langfuse/api/resources/commons/types/chat_message.py index d97ea60a1..d009bc8cf 100644 --- a/langfuse/api/resources/commons/types/chat_message.py +++ b/langfuse/api/resources/commons/types/chat_message.py @@ -12,15 +12,28 @@ class ChatMessage(pydantic_v1.BaseModel): content: str def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/chat_prompt.py b/langfuse/api/resources/commons/types/chat_prompt.py index 127b7ffa5..7699d288d 100644 --- a/langfuse/api/resources/commons/types/chat_prompt.py +++ b/langfuse/api/resources/commons/types/chat_prompt.py @@ -13,15 +13,28 @@ class ChatPrompt(BasePrompt): prompt: typing.List[ChatMessage] def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/comment.py b/langfuse/api/resources/commons/types/comment.py index 6ad563fdf..4d8b1916a 100644 --- a/langfuse/api/resources/commons/types/comment.py +++ b/langfuse/api/resources/commons/types/comment.py @@ -16,18 +16,33 @@ class Comment(pydantic_v1.BaseModel): object_type: CommentObjectType = pydantic_v1.Field(alias="objectType") object_id: str = pydantic_v1.Field(alias="objectId") content: str - author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) + author_user_id: typing.Optional[str] = pydantic_v1.Field( + alias="authorUserId", default=None + ) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/config_category.py b/langfuse/api/resources/commons/types/config_category.py index 7455c70a0..b1cbde9f2 100644 --- a/langfuse/api/resources/commons/types/config_category.py +++ b/langfuse/api/resources/commons/types/config_category.py @@ -12,15 +12,28 @@ class ConfigCategory(pydantic_v1.BaseModel): label: str def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/dataset.py b/langfuse/api/resources/commons/types/dataset.py index abc35a168..be59a951a 100644 --- a/langfuse/api/resources/commons/types/dataset.py +++ b/langfuse/api/resources/commons/types/dataset.py @@ -17,15 +17,28 @@ class Dataset(pydantic_v1.BaseModel): updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/dataset_item.py b/langfuse/api/resources/commons/types/dataset_item.py index 9a34107a8..dd5f85e78 100644 --- a/langfuse/api/resources/commons/types/dataset_item.py +++ b/langfuse/api/resources/commons/types/dataset_item.py @@ -12,25 +12,44 @@ class DatasetItem(pydantic_v1.BaseModel): id: str status: DatasetStatus input: typing.Optional[typing.Any] = None - expected_output: typing.Optional[typing.Any] = pydantic_v1.Field(alias="expectedOutput", default=None) + expected_output: typing.Optional[typing.Any] = pydantic_v1.Field( + alias="expectedOutput", default=None + ) metadata: typing.Optional[typing.Any] = None - source_trace_id: typing.Optional[str] = pydantic_v1.Field(alias="sourceTraceId", default=None) - source_observation_id: typing.Optional[str] = pydantic_v1.Field(alias="sourceObservationId", default=None) + source_trace_id: typing.Optional[str] = pydantic_v1.Field( + alias="sourceTraceId", default=None + ) + source_observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="sourceObservationId", default=None + ) dataset_id: str = pydantic_v1.Field(alias="datasetId") dataset_name: str = pydantic_v1.Field(alias="datasetName") created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/dataset_run.py b/langfuse/api/resources/commons/types/dataset_run.py index 7fc733ff7..74b1a2ac8 100644 --- a/langfuse/api/resources/commons/types/dataset_run.py +++ b/langfuse/api/resources/commons/types/dataset_run.py @@ -49,15 +49,28 @@ class DatasetRun(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/dataset_run_item.py b/langfuse/api/resources/commons/types/dataset_run_item.py index 683c055df..f1b3af163 100644 --- a/langfuse/api/resources/commons/types/dataset_run_item.py +++ b/langfuse/api/resources/commons/types/dataset_run_item.py @@ -13,20 +13,35 @@ class DatasetRunItem(pydantic_v1.BaseModel): dataset_run_name: str = pydantic_v1.Field(alias="datasetRunName") dataset_item_id: str = pydantic_v1.Field(alias="datasetItemId") trace_id: str = pydantic_v1.Field(alias="traceId") - observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) + observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="observationId", default=None + ) created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/dataset_run_with_items.py b/langfuse/api/resources/commons/types/dataset_run_with_items.py index 0179bea39..647d2c553 100644 --- a/langfuse/api/resources/commons/types/dataset_run_with_items.py +++ b/langfuse/api/resources/commons/types/dataset_run_with_items.py @@ -10,18 +10,33 @@ class DatasetRunWithItems(DatasetRun): - dataset_run_items: typing.List[DatasetRunItem] = pydantic_v1.Field(alias="datasetRunItems") + dataset_run_items: typing.List[DatasetRunItem] = pydantic_v1.Field( + alias="datasetRunItems" + ) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/dataset_status.py b/langfuse/api/resources/commons/types/dataset_status.py index 50b636851..09eac62fe 100644 --- a/langfuse/api/resources/commons/types/dataset_status.py +++ b/langfuse/api/resources/commons/types/dataset_status.py @@ -10,7 +10,11 @@ class DatasetStatus(str, enum.Enum): ACTIVE = "ACTIVE" ARCHIVED = "ARCHIVED" - def visit(self, active: typing.Callable[[], T_Result], archived: typing.Callable[[], T_Result]) -> T_Result: + def visit( + self, + active: typing.Callable[[], T_Result], + archived: typing.Callable[[], T_Result], + ) -> T_Result: if self is DatasetStatus.ACTIVE: return active() if self is DatasetStatus.ARCHIVED: diff --git a/langfuse/api/resources/commons/types/map_value.py b/langfuse/api/resources/commons/types/map_value.py index aebdb7f97..e1e771a9b 100644 --- a/langfuse/api/resources/commons/types/map_value.py +++ b/langfuse/api/resources/commons/types/map_value.py @@ -3,5 +3,8 @@ import typing MapValue = typing.Union[ - typing.Optional[str], typing.Optional[int], typing.Optional[bool], typing.Optional[typing.List[str]] + typing.Optional[str], + typing.Optional[int], + typing.Optional[bool], + typing.Optional[typing.List[str]], ] diff --git a/langfuse/api/resources/commons/types/model.py b/langfuse/api/resources/commons/types/model.py index 100c39246..54cb26bc8 100644 --- a/langfuse/api/resources/commons/types/model.py +++ b/langfuse/api/resources/commons/types/model.py @@ -24,7 +24,9 @@ class Model(pydantic_v1.BaseModel): Regex pattern which matches this model definition to generation.model. Useful in case of fine-tuned models. If you want to exact match, use `(?i)^modelname$` """ - start_date: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="startDate", default=None) + start_date: typing.Optional[dt.datetime] = pydantic_v1.Field( + alias="startDate", default=None + ) """ Apply only to generations which are newer than this ISO date. """ @@ -34,27 +36,37 @@ class Model(pydantic_v1.BaseModel): Unit used by this model. """ - input_price: typing.Optional[float] = pydantic_v1.Field(alias="inputPrice", default=None) + input_price: typing.Optional[float] = pydantic_v1.Field( + alias="inputPrice", default=None + ) """ Price (USD) per input unit """ - output_price: typing.Optional[float] = pydantic_v1.Field(alias="outputPrice", default=None) + output_price: typing.Optional[float] = pydantic_v1.Field( + alias="outputPrice", default=None + ) """ Price (USD) per output unit """ - total_price: typing.Optional[float] = pydantic_v1.Field(alias="totalPrice", default=None) + total_price: typing.Optional[float] = pydantic_v1.Field( + alias="totalPrice", default=None + ) """ Price (USD) per total unit. Cannot be set if input or output price is set. """ - tokenizer_id: typing.Optional[str] = pydantic_v1.Field(alias="tokenizerId", default=None) + tokenizer_id: typing.Optional[str] = pydantic_v1.Field( + alias="tokenizerId", default=None + ) """ Optional. Tokenizer to be applied to observations which match to this model. See docs for more details. """ - tokenizer_config: typing.Optional[typing.Any] = pydantic_v1.Field(alias="tokenizerConfig", default=None) + tokenizer_config: typing.Optional[typing.Any] = pydantic_v1.Field( + alias="tokenizerConfig", default=None + ) """ Optional. Configuration for the selected tokenizer. Needs to be JSON. See docs for more details. """ @@ -62,15 +74,28 @@ class Model(pydantic_v1.BaseModel): is_langfuse_managed: bool = pydantic_v1.Field(alias="isLangfuseManaged") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/numeric_score.py b/langfuse/api/resources/commons/types/numeric_score.py index 188191dd1..d7f860cd5 100644 --- a/langfuse/api/resources/commons/types/numeric_score.py +++ b/langfuse/api/resources/commons/types/numeric_score.py @@ -15,15 +15,28 @@ class NumericScore(BaseScore): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/observation.py b/langfuse/api/resources/commons/types/observation.py index da83194bd..93fabb754 100644 --- a/langfuse/api/resources/commons/types/observation.py +++ b/langfuse/api/resources/commons/types/observation.py @@ -36,12 +36,16 @@ class Observation(pydantic_v1.BaseModel): The start time of the observation """ - end_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="endTime", default=None) + end_time: typing.Optional[dt.datetime] = pydantic_v1.Field( + alias="endTime", default=None + ) """ The end time of the observation. """ - completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="completionStartTime", default=None) + completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field( + alias="completionStartTime", default=None + ) """ The completion start time of the observation """ @@ -88,12 +92,16 @@ class Observation(pydantic_v1.BaseModel): The level of the observation """ - status_message: typing.Optional[str] = pydantic_v1.Field(alias="statusMessage", default=None) + status_message: typing.Optional[str] = pydantic_v1.Field( + alias="statusMessage", default=None + ) """ The status message of the observation """ - parent_observation_id: typing.Optional[str] = pydantic_v1.Field(alias="parentObservationId", default=None) + parent_observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="parentObservationId", default=None + ) """ The parent observation ID """ @@ -103,26 +111,43 @@ class Observation(pydantic_v1.BaseModel): The prompt ID associated with the observation """ - usage_details: typing.Optional[typing.Dict[str, int]] = pydantic_v1.Field(alias="usageDetails", default=None) + usage_details: typing.Optional[typing.Dict[str, int]] = pydantic_v1.Field( + alias="usageDetails", default=None + ) """ The usage details of the observation. Key is the name of the usage metric, value is the number of units consumed. The total key is the sum of all (non-total) usage metrics or the total value ingested. """ - cost_details: typing.Optional[typing.Dict[str, float]] = pydantic_v1.Field(alias="costDetails", default=None) + cost_details: typing.Optional[typing.Dict[str, float]] = pydantic_v1.Field( + alias="costDetails", default=None + ) """ The cost details of the observation. Key is the name of the cost metric, value is the cost in USD. The total key is the sum of all (non-total) cost metrics or the total value ingested. """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/observations_view.py b/langfuse/api/resources/commons/types/observations_view.py index 8ab3869cb..e011fa32b 100644 --- a/langfuse/api/resources/commons/types/observations_view.py +++ b/langfuse/api/resources/commons/types/observations_view.py @@ -9,12 +9,16 @@ class ObservationsView(Observation): - prompt_name: typing.Optional[str] = pydantic_v1.Field(alias="promptName", default=None) + prompt_name: typing.Optional[str] = pydantic_v1.Field( + alias="promptName", default=None + ) """ The name of the prompt associated with the observation """ - prompt_version: typing.Optional[int] = pydantic_v1.Field(alias="promptVersion", default=None) + prompt_version: typing.Optional[int] = pydantic_v1.Field( + alias="promptVersion", default=None + ) """ The version of the prompt associated with the observation """ @@ -24,32 +28,44 @@ class ObservationsView(Observation): The unique identifier of the model """ - input_price: typing.Optional[float] = pydantic_v1.Field(alias="inputPrice", default=None) + input_price: typing.Optional[float] = pydantic_v1.Field( + alias="inputPrice", default=None + ) """ The price of the input in USD """ - output_price: typing.Optional[float] = pydantic_v1.Field(alias="outputPrice", default=None) + output_price: typing.Optional[float] = pydantic_v1.Field( + alias="outputPrice", default=None + ) """ The price of the output in USD. """ - total_price: typing.Optional[float] = pydantic_v1.Field(alias="totalPrice", default=None) + total_price: typing.Optional[float] = pydantic_v1.Field( + alias="totalPrice", default=None + ) """ The total price in USD. """ - calculated_input_cost: typing.Optional[float] = pydantic_v1.Field(alias="calculatedInputCost", default=None) + calculated_input_cost: typing.Optional[float] = pydantic_v1.Field( + alias="calculatedInputCost", default=None + ) """ (Deprecated. Use usageDetails and costDetails instead.) The calculated cost of the input in USD """ - calculated_output_cost: typing.Optional[float] = pydantic_v1.Field(alias="calculatedOutputCost", default=None) + calculated_output_cost: typing.Optional[float] = pydantic_v1.Field( + alias="calculatedOutputCost", default=None + ) """ (Deprecated. Use usageDetails and costDetails instead.) The calculated cost of the output in USD """ - calculated_total_cost: typing.Optional[float] = pydantic_v1.Field(alias="calculatedTotalCost", default=None) + calculated_total_cost: typing.Optional[float] = pydantic_v1.Field( + alias="calculatedTotalCost", default=None + ) """ (Deprecated. Use usageDetails and costDetails instead.) The calculated total cost in USD """ @@ -59,21 +75,36 @@ class ObservationsView(Observation): The latency in seconds. """ - time_to_first_token: typing.Optional[float] = pydantic_v1.Field(alias="timeToFirstToken", default=None) + time_to_first_token: typing.Optional[float] = pydantic_v1.Field( + alias="timeToFirstToken", default=None + ) """ The time to the first token in seconds """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/prompt.py b/langfuse/api/resources/commons/types/prompt.py index 0f96fe7c4..90ba3447f 100644 --- a/langfuse/api/resources/commons/types/prompt.py +++ b/langfuse/api/resources/commons/types/prompt.py @@ -20,15 +20,28 @@ class Prompt_Chat(pydantic_v1.BaseModel): type: typing.Literal["chat"] = "chat" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -48,15 +61,28 @@ class Prompt_Text(pydantic_v1.BaseModel): type: typing.Literal["text"] = "text" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/score.py b/langfuse/api/resources/commons/types/score.py index 6ae9e1fc9..e39221084 100644 --- a/langfuse/api/resources/commons/types/score.py +++ b/langfuse/api/resources/commons/types/score.py @@ -16,26 +16,45 @@ class Score_Numeric(pydantic_v1.BaseModel): trace_id: str = pydantic_v1.Field(alias="traceId") name: str source: ScoreSource - observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) + observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="observationId", default=None + ) timestamp: dt.datetime created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") - author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) + author_user_id: typing.Optional[str] = pydantic_v1.Field( + alias="authorUserId", default=None + ) comment: typing.Optional[str] = None config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) - data_type: typing.Literal["NUMERIC"] = pydantic_v1.Field(alias="dataType", default="NUMERIC") + data_type: typing.Literal["NUMERIC"] = pydantic_v1.Field( + alias="dataType", default="NUMERIC" + ) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -54,26 +73,45 @@ class Score_Categorical(pydantic_v1.BaseModel): trace_id: str = pydantic_v1.Field(alias="traceId") name: str source: ScoreSource - observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) + observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="observationId", default=None + ) timestamp: dt.datetime created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") - author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) + author_user_id: typing.Optional[str] = pydantic_v1.Field( + alias="authorUserId", default=None + ) comment: typing.Optional[str] = None config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) - data_type: typing.Literal["CATEGORICAL"] = pydantic_v1.Field(alias="dataType", default="CATEGORICAL") + data_type: typing.Literal["CATEGORICAL"] = pydantic_v1.Field( + alias="dataType", default="CATEGORICAL" + ) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -92,26 +130,45 @@ class Score_Boolean(pydantic_v1.BaseModel): trace_id: str = pydantic_v1.Field(alias="traceId") name: str source: ScoreSource - observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) + observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="observationId", default=None + ) timestamp: dt.datetime created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") - author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) + author_user_id: typing.Optional[str] = pydantic_v1.Field( + alias="authorUserId", default=None + ) comment: typing.Optional[str] = None config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) - data_type: typing.Literal["BOOLEAN"] = pydantic_v1.Field(alias="dataType", default="BOOLEAN") + data_type: typing.Literal["BOOLEAN"] = pydantic_v1.Field( + alias="dataType", default="BOOLEAN" + ) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/score_config.py b/langfuse/api/resources/commons/types/score_config.py index f31fefc5c..4a7b30e0e 100644 --- a/langfuse/api/resources/commons/types/score_config.py +++ b/langfuse/api/resources/commons/types/score_config.py @@ -25,17 +25,23 @@ class ScoreConfig(pydantic_v1.BaseModel): Whether the score config is archived. Defaults to false """ - min_value: typing.Optional[float] = pydantic_v1.Field(alias="minValue", default=None) + min_value: typing.Optional[float] = pydantic_v1.Field( + alias="minValue", default=None + ) """ Sets minimum value for numerical scores. If not set, the minimum value defaults to -∞ """ - max_value: typing.Optional[float] = pydantic_v1.Field(alias="maxValue", default=None) + max_value: typing.Optional[float] = pydantic_v1.Field( + alias="maxValue", default=None + ) """ Sets maximum value for numerical scores. If not set, the maximum value defaults to +∞ """ - categories: typing.Optional[typing.List[ConfigCategory]] = pydantic_v1.Field(default=None) + categories: typing.Optional[typing.List[ConfigCategory]] = pydantic_v1.Field( + default=None + ) """ Configures custom categories for categorical scores """ @@ -43,15 +49,28 @@ class ScoreConfig(pydantic_v1.BaseModel): description: typing.Optional[str] = None def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/session.py b/langfuse/api/resources/commons/types/session.py index 8b5bf1556..230bf004b 100644 --- a/langfuse/api/resources/commons/types/session.py +++ b/langfuse/api/resources/commons/types/session.py @@ -13,15 +13,28 @@ class Session(pydantic_v1.BaseModel): project_id: str = pydantic_v1.Field(alias="projectId") def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/session_with_traces.py b/langfuse/api/resources/commons/types/session_with_traces.py index d1cfa1808..b5465daa9 100644 --- a/langfuse/api/resources/commons/types/session_with_traces.py +++ b/langfuse/api/resources/commons/types/session_with_traces.py @@ -13,15 +13,28 @@ class SessionWithTraces(Session): traces: typing.List[Trace] def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/text_prompt.py b/langfuse/api/resources/commons/types/text_prompt.py index 6c3d1f3d2..e149ea322 100644 --- a/langfuse/api/resources/commons/types/text_prompt.py +++ b/langfuse/api/resources/commons/types/text_prompt.py @@ -12,15 +12,28 @@ class TextPrompt(BasePrompt): prompt: str def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/trace.py b/langfuse/api/resources/commons/types/trace.py index b180518d3..9c9be5ae8 100644 --- a/langfuse/api/resources/commons/types/trace.py +++ b/langfuse/api/resources/commons/types/trace.py @@ -33,7 +33,9 @@ class Trace(pydantic_v1.BaseModel): The output data of the trace. Can be any JSON. """ - session_id: typing.Optional[str] = pydantic_v1.Field(alias="sessionId", default=None) + session_id: typing.Optional[str] = pydantic_v1.Field( + alias="sessionId", default=None + ) """ The session identifier associated with the trace """ @@ -69,15 +71,28 @@ class Trace(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/trace_with_details.py b/langfuse/api/resources/commons/types/trace_with_details.py index 5aba777f3..5ffe6f218 100644 --- a/langfuse/api/resources/commons/types/trace_with_details.py +++ b/langfuse/api/resources/commons/types/trace_with_details.py @@ -35,15 +35,28 @@ class TraceWithDetails(Trace): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/trace_with_full_details.py b/langfuse/api/resources/commons/types/trace_with_full_details.py index 0f6b7bb0b..c96258d73 100644 --- a/langfuse/api/resources/commons/types/trace_with_full_details.py +++ b/langfuse/api/resources/commons/types/trace_with_full_details.py @@ -37,15 +37,28 @@ class TraceWithFullDetails(Trace): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/commons/types/usage.py b/langfuse/api/resources/commons/types/usage.py index 747958dd5..c38330494 100644 --- a/langfuse/api/resources/commons/types/usage.py +++ b/langfuse/api/resources/commons/types/usage.py @@ -29,31 +29,50 @@ class Usage(pydantic_v1.BaseModel): """ unit: typing.Optional[ModelUsageUnit] = None - input_cost: typing.Optional[float] = pydantic_v1.Field(alias="inputCost", default=None) + input_cost: typing.Optional[float] = pydantic_v1.Field( + alias="inputCost", default=None + ) """ USD input cost """ - output_cost: typing.Optional[float] = pydantic_v1.Field(alias="outputCost", default=None) + output_cost: typing.Optional[float] = pydantic_v1.Field( + alias="outputCost", default=None + ) """ USD output cost """ - total_cost: typing.Optional[float] = pydantic_v1.Field(alias="totalCost", default=None) + total_cost: typing.Optional[float] = pydantic_v1.Field( + alias="totalCost", default=None + ) """ USD total cost, defaults to input+output """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/dataset_items/client.py b/langfuse/api/resources/dataset_items/client.py index 66a64afc9..7cab6f51c 100644 --- a/langfuse/api/resources/dataset_items/client.py +++ b/langfuse/api/resources/dataset_items/client.py @@ -26,7 +26,10 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def create( - self, *, request: CreateDatasetItemRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreateDatasetItemRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> DatasetItem: """ Create a dataset item @@ -69,7 +72,11 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/dataset-items", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/dataset-items", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -77,19 +84,29 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DatasetItem: + def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> DatasetItem: """ Get a dataset item @@ -121,7 +138,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/dataset-items/{jsonable_encoder(id)}", method="GET", request_options=request_options + f"api/public/dataset-items/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -129,13 +148,21 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -213,13 +240,21 @@ def list( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -231,7 +266,10 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def create( - self, *, request: CreateDatasetItemRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreateDatasetItemRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> DatasetItem: """ Create a dataset item @@ -282,7 +320,11 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/dataset-items", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/dataset-items", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -290,19 +332,29 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DatasetItem: + async def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> DatasetItem: """ Get a dataset item @@ -342,7 +394,9 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/dataset-items/{jsonable_encoder(id)}", method="GET", request_options=request_options + f"api/public/dataset-items/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -350,13 +404,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -442,13 +504,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/dataset_items/types/create_dataset_item_request.py b/langfuse/api/resources/dataset_items/types/create_dataset_item_request.py index 52d3ff635..111f6819a 100644 --- a/langfuse/api/resources/dataset_items/types/create_dataset_item_request.py +++ b/langfuse/api/resources/dataset_items/types/create_dataset_item_request.py @@ -11,10 +11,16 @@ class CreateDatasetItemRequest(pydantic_v1.BaseModel): dataset_name: str = pydantic_v1.Field(alias="datasetName") input: typing.Optional[typing.Any] = None - expected_output: typing.Optional[typing.Any] = pydantic_v1.Field(alias="expectedOutput", default=None) + expected_output: typing.Optional[typing.Any] = pydantic_v1.Field( + alias="expectedOutput", default=None + ) metadata: typing.Optional[typing.Any] = None - source_trace_id: typing.Optional[str] = pydantic_v1.Field(alias="sourceTraceId", default=None) - source_observation_id: typing.Optional[str] = pydantic_v1.Field(alias="sourceObservationId", default=None) + source_trace_id: typing.Optional[str] = pydantic_v1.Field( + alias="sourceTraceId", default=None + ) + source_observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="sourceObservationId", default=None + ) id: typing.Optional[str] = pydantic_v1.Field(default=None) """ Dataset items are upserted on their id. Id needs to be unique (project-level) and cannot be reused across datasets. @@ -26,15 +32,28 @@ class CreateDatasetItemRequest(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/dataset_items/types/paginated_dataset_items.py b/langfuse/api/resources/dataset_items/types/paginated_dataset_items.py index c63f147c4..8592ba80f 100644 --- a/langfuse/api/resources/dataset_items/types/paginated_dataset_items.py +++ b/langfuse/api/resources/dataset_items/types/paginated_dataset_items.py @@ -14,15 +14,28 @@ class PaginatedDatasetItems(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/dataset_run_items/client.py b/langfuse/api/resources/dataset_run_items/client.py index 0be19fa4f..c4c923a9b 100644 --- a/langfuse/api/resources/dataset_run_items/client.py +++ b/langfuse/api/resources/dataset_run_items/client.py @@ -24,7 +24,10 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def create( - self, *, request: CreateDatasetRunItemRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreateDatasetRunItemRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> DatasetRunItem: """ Create a dataset run item @@ -65,7 +68,11 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/dataset-run-items", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/dataset-run-items", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -73,13 +80,21 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -91,7 +106,10 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def create( - self, *, request: CreateDatasetRunItemRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreateDatasetRunItemRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> DatasetRunItem: """ Create a dataset run item @@ -140,7 +158,11 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/dataset-run-items", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/dataset-run-items", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -148,13 +170,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/dataset_run_items/types/create_dataset_run_item_request.py b/langfuse/api/resources/dataset_run_items/types/create_dataset_run_item_request.py index 8762d7418..0a643b835 100644 --- a/langfuse/api/resources/dataset_run_items/types/create_dataset_run_item_request.py +++ b/langfuse/api/resources/dataset_run_items/types/create_dataset_run_item_request.py @@ -9,7 +9,9 @@ class CreateDatasetRunItemRequest(pydantic_v1.BaseModel): run_name: str = pydantic_v1.Field(alias="runName") - run_description: typing.Optional[str] = pydantic_v1.Field(alias="runDescription", default=None) + run_description: typing.Optional[str] = pydantic_v1.Field( + alias="runDescription", default=None + ) """ Description of the run. If run exists, description will be updated. """ @@ -20,22 +22,37 @@ class CreateDatasetRunItemRequest(pydantic_v1.BaseModel): """ dataset_item_id: str = pydantic_v1.Field(alias="datasetItemId") - observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) + observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="observationId", default=None + ) trace_id: typing.Optional[str] = pydantic_v1.Field(alias="traceId", default=None) """ traceId should always be provided. For compatibility with older SDK versions it can also be inferred from the provided observationId. """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/datasets/client.py b/langfuse/api/resources/datasets/client.py index fcfed2498..5d535b949 100644 --- a/langfuse/api/resources/datasets/client.py +++ b/langfuse/api/resources/datasets/client.py @@ -81,19 +81,32 @@ def list( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def get(self, dataset_name: str, *, request_options: typing.Optional[RequestOptions] = None) -> Dataset: + def get( + self, + dataset_name: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> Dataset: """ Get a dataset @@ -125,7 +138,9 @@ def get(self, dataset_name: str, *, request_options: typing.Optional[RequestOpti ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/v2/datasets/{jsonable_encoder(dataset_name)}", method="GET", request_options=request_options + f"api/public/v2/datasets/{jsonable_encoder(dataset_name)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -133,20 +148,31 @@ def get(self, dataset_name: str, *, request_options: typing.Optional[RequestOpti if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def create( - self, *, request: CreateDatasetRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreateDatasetRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> Dataset: """ Create a dataset @@ -184,7 +210,11 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/v2/datasets", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/v2/datasets", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -192,20 +222,32 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def get_run( - self, dataset_name: str, run_name: str, *, request_options: typing.Optional[RequestOptions] = None + self, + dataset_name: str, + run_name: str, + *, + request_options: typing.Optional[RequestOptions] = None, ) -> DatasetRunWithItems: """ Get a dataset run and its items @@ -251,13 +293,21 @@ def get_run( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -321,13 +371,21 @@ def get_runs( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -400,19 +458,32 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def get(self, dataset_name: str, *, request_options: typing.Optional[RequestOptions] = None) -> Dataset: + async def get( + self, + dataset_name: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> Dataset: """ Get a dataset @@ -452,7 +523,9 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/v2/datasets/{jsonable_encoder(dataset_name)}", method="GET", request_options=request_options + f"api/public/v2/datasets/{jsonable_encoder(dataset_name)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -460,20 +533,31 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def create( - self, *, request: CreateDatasetRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreateDatasetRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> Dataset: """ Create a dataset @@ -519,7 +603,11 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/v2/datasets", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/v2/datasets", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -527,20 +615,32 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def get_run( - self, dataset_name: str, run_name: str, *, request_options: typing.Optional[RequestOptions] = None + self, + dataset_name: str, + run_name: str, + *, + request_options: typing.Optional[RequestOptions] = None, ) -> DatasetRunWithItems: """ Get a dataset run and its items @@ -594,13 +694,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -672,13 +780,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/datasets/types/create_dataset_request.py b/langfuse/api/resources/datasets/types/create_dataset_request.py index 9fb01dde2..023cb4c12 100644 --- a/langfuse/api/resources/datasets/types/create_dataset_request.py +++ b/langfuse/api/resources/datasets/types/create_dataset_request.py @@ -13,15 +13,28 @@ class CreateDatasetRequest(pydantic_v1.BaseModel): metadata: typing.Optional[typing.Any] = None def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/datasets/types/paginated_dataset_runs.py b/langfuse/api/resources/datasets/types/paginated_dataset_runs.py index dad465bc7..86f2f0a73 100644 --- a/langfuse/api/resources/datasets/types/paginated_dataset_runs.py +++ b/langfuse/api/resources/datasets/types/paginated_dataset_runs.py @@ -14,15 +14,28 @@ class PaginatedDatasetRuns(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/datasets/types/paginated_datasets.py b/langfuse/api/resources/datasets/types/paginated_datasets.py index e24be3483..c2d436bf4 100644 --- a/langfuse/api/resources/datasets/types/paginated_datasets.py +++ b/langfuse/api/resources/datasets/types/paginated_datasets.py @@ -14,15 +14,28 @@ class PaginatedDatasets(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/health/client.py b/langfuse/api/resources/health/client.py index 68560e1e3..029be7a0c 100644 --- a/langfuse/api/resources/health/client.py +++ b/langfuse/api/resources/health/client.py @@ -20,7 +20,9 @@ class HealthClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def health(self, *, request_options: typing.Optional[RequestOptions] = None) -> HealthResponse: + def health( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HealthResponse: """ Check health of API and database @@ -58,13 +60,21 @@ def health(self, *, request_options: typing.Optional[RequestOptions] = None) -> if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -75,7 +85,9 @@ class AsyncHealthClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def health(self, *, request_options: typing.Optional[RequestOptions] = None) -> HealthResponse: + async def health( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HealthResponse: """ Check health of API and database @@ -121,13 +133,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/health/types/health_response.py b/langfuse/api/resources/health/types/health_response.py index 70e04b122..633da67a8 100644 --- a/langfuse/api/resources/health/types/health_response.py +++ b/langfuse/api/resources/health/types/health_response.py @@ -27,15 +27,28 @@ class HealthResponse(pydantic_v1.BaseModel): status: str def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/client.py b/langfuse/api/resources/ingestion/client.py index e85751ee0..cc58c32e4 100644 --- a/langfuse/api/resources/ingestion/client.py +++ b/langfuse/api/resources/ingestion/client.py @@ -28,7 +28,7 @@ def batch( *, batch: typing.Sequence[IngestionEvent], metadata: typing.Optional[typing.Any] = OMIT, - request_options: typing.Optional[RequestOptions] = None + request_options: typing.Optional[RequestOptions] = None, ) -> IngestionResponse: """ Batched ingestion for Langfuse Tracing. If you want to use tracing via the API, such as to build your own Langfuse client implementation, this is the only API route you need to implement. @@ -109,13 +109,21 @@ def batch( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -131,7 +139,7 @@ async def batch( *, batch: typing.Sequence[IngestionEvent], metadata: typing.Optional[typing.Any] = OMIT, - request_options: typing.Optional[RequestOptions] = None + request_options: typing.Optional[RequestOptions] = None, ) -> IngestionResponse: """ Batched ingestion for Langfuse Tracing. If you want to use tracing via the API, such as to build your own Langfuse client implementation, this is the only API route you need to implement. @@ -219,13 +227,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/ingestion/types/base_event.py b/langfuse/api/resources/ingestion/types/base_event.py index 145d224ec..dec8a52e7 100644 --- a/langfuse/api/resources/ingestion/types/base_event.py +++ b/langfuse/api/resources/ingestion/types/base_event.py @@ -24,15 +24,28 @@ class BaseEvent(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/create_event_body.py b/langfuse/api/resources/ingestion/types/create_event_body.py index 566c39294..afe8677f3 100644 --- a/langfuse/api/resources/ingestion/types/create_event_body.py +++ b/langfuse/api/resources/ingestion/types/create_event_body.py @@ -12,15 +12,28 @@ class CreateEventBody(OptionalObservationBody): id: typing.Optional[str] = None def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/create_event_event.py b/langfuse/api/resources/ingestion/types/create_event_event.py index fad6d92e0..0c3cce040 100644 --- a/langfuse/api/resources/ingestion/types/create_event_event.py +++ b/langfuse/api/resources/ingestion/types/create_event_event.py @@ -13,15 +13,28 @@ class CreateEventEvent(BaseEvent): body: CreateEventBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/create_generation_body.py b/langfuse/api/resources/ingestion/types/create_generation_body.py index 22a0cf776..428b58607 100644 --- a/langfuse/api/resources/ingestion/types/create_generation_body.py +++ b/langfuse/api/resources/ingestion/types/create_generation_body.py @@ -12,27 +12,50 @@ class CreateGenerationBody(CreateSpanBody): - completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="completionStartTime", default=None) + completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field( + alias="completionStartTime", default=None + ) model: typing.Optional[str] = None model_parameters: typing.Optional[typing.Dict[str, MapValue]] = pydantic_v1.Field( alias="modelParameters", default=None ) usage: typing.Optional[IngestionUsage] = None - usage_details: typing.Optional[UsageDetails] = pydantic_v1.Field(alias="usageDetails", default=None) - cost_details: typing.Optional[typing.Dict[str, float]] = pydantic_v1.Field(alias="costDetails", default=None) - prompt_name: typing.Optional[str] = pydantic_v1.Field(alias="promptName", default=None) - prompt_version: typing.Optional[int] = pydantic_v1.Field(alias="promptVersion", default=None) + usage_details: typing.Optional[UsageDetails] = pydantic_v1.Field( + alias="usageDetails", default=None + ) + cost_details: typing.Optional[typing.Dict[str, float]] = pydantic_v1.Field( + alias="costDetails", default=None + ) + prompt_name: typing.Optional[str] = pydantic_v1.Field( + alias="promptName", default=None + ) + prompt_version: typing.Optional[int] = pydantic_v1.Field( + alias="promptVersion", default=None + ) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/create_generation_event.py b/langfuse/api/resources/ingestion/types/create_generation_event.py index 4b95cfa58..cb7b484dd 100644 --- a/langfuse/api/resources/ingestion/types/create_generation_event.py +++ b/langfuse/api/resources/ingestion/types/create_generation_event.py @@ -13,15 +13,28 @@ class CreateGenerationEvent(BaseEvent): body: CreateGenerationBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/create_observation_event.py b/langfuse/api/resources/ingestion/types/create_observation_event.py index 7a72cc017..adfefc793 100644 --- a/langfuse/api/resources/ingestion/types/create_observation_event.py +++ b/langfuse/api/resources/ingestion/types/create_observation_event.py @@ -13,15 +13,28 @@ class CreateObservationEvent(BaseEvent): body: ObservationBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/create_span_body.py b/langfuse/api/resources/ingestion/types/create_span_body.py index 21ef5aaf3..c31fde567 100644 --- a/langfuse/api/resources/ingestion/types/create_span_body.py +++ b/langfuse/api/resources/ingestion/types/create_span_body.py @@ -9,18 +9,33 @@ class CreateSpanBody(CreateEventBody): - end_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="endTime", default=None) + end_time: typing.Optional[dt.datetime] = pydantic_v1.Field( + alias="endTime", default=None + ) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/create_span_event.py b/langfuse/api/resources/ingestion/types/create_span_event.py index 042124a93..7a8e8154c 100644 --- a/langfuse/api/resources/ingestion/types/create_span_event.py +++ b/langfuse/api/resources/ingestion/types/create_span_event.py @@ -13,15 +13,28 @@ class CreateSpanEvent(BaseEvent): body: CreateSpanBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/ingestion_error.py b/langfuse/api/resources/ingestion/types/ingestion_error.py index 14c661961..b9028ce1d 100644 --- a/langfuse/api/resources/ingestion/types/ingestion_error.py +++ b/langfuse/api/resources/ingestion/types/ingestion_error.py @@ -14,15 +14,28 @@ class IngestionError(pydantic_v1.BaseModel): error: typing.Optional[typing.Any] = None def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/ingestion_event.py b/langfuse/api/resources/ingestion/types/ingestion_event.py index b8093f89b..e083c9354 100644 --- a/langfuse/api/resources/ingestion/types/ingestion_event.py +++ b/langfuse/api/resources/ingestion/types/ingestion_event.py @@ -26,15 +26,28 @@ class IngestionEvent_TraceCreate(pydantic_v1.BaseModel): type: typing.Literal["trace-create"] = "trace-create" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -52,15 +65,28 @@ class IngestionEvent_ScoreCreate(pydantic_v1.BaseModel): type: typing.Literal["score-create"] = "score-create" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -78,15 +104,28 @@ class IngestionEvent_SpanCreate(pydantic_v1.BaseModel): type: typing.Literal["span-create"] = "span-create" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -104,15 +143,28 @@ class IngestionEvent_SpanUpdate(pydantic_v1.BaseModel): type: typing.Literal["span-update"] = "span-update" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -130,15 +182,28 @@ class IngestionEvent_GenerationCreate(pydantic_v1.BaseModel): type: typing.Literal["generation-create"] = "generation-create" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -156,15 +221,28 @@ class IngestionEvent_GenerationUpdate(pydantic_v1.BaseModel): type: typing.Literal["generation-update"] = "generation-update" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -182,15 +260,28 @@ class IngestionEvent_EventCreate(pydantic_v1.BaseModel): type: typing.Literal["event-create"] = "event-create" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -208,15 +299,28 @@ class IngestionEvent_SdkLog(pydantic_v1.BaseModel): type: typing.Literal["sdk-log"] = "sdk-log" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -234,15 +338,28 @@ class IngestionEvent_ObservationCreate(pydantic_v1.BaseModel): type: typing.Literal["observation-create"] = "observation-create" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -260,15 +377,28 @@ class IngestionEvent_ObservationUpdate(pydantic_v1.BaseModel): type: typing.Literal["observation-update"] = "observation-update" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/ingestion_response.py b/langfuse/api/resources/ingestion/types/ingestion_response.py index deadc1cb9..b4e66349c 100644 --- a/langfuse/api/resources/ingestion/types/ingestion_response.py +++ b/langfuse/api/resources/ingestion/types/ingestion_response.py @@ -14,15 +14,28 @@ class IngestionResponse(pydantic_v1.BaseModel): errors: typing.List[IngestionError] def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/ingestion_success.py b/langfuse/api/resources/ingestion/types/ingestion_success.py index 043533491..481e64752 100644 --- a/langfuse/api/resources/ingestion/types/ingestion_success.py +++ b/langfuse/api/resources/ingestion/types/ingestion_success.py @@ -12,15 +12,28 @@ class IngestionSuccess(pydantic_v1.BaseModel): status: int def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/observation_body.py b/langfuse/api/resources/ingestion/types/observation_body.py index de88ad69f..254c600da 100644 --- a/langfuse/api/resources/ingestion/types/observation_body.py +++ b/langfuse/api/resources/ingestion/types/observation_body.py @@ -16,9 +16,15 @@ class ObservationBody(pydantic_v1.BaseModel): trace_id: typing.Optional[str] = pydantic_v1.Field(alias="traceId", default=None) type: ObservationType name: typing.Optional[str] = None - start_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="startTime", default=None) - end_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="endTime", default=None) - completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="completionStartTime", default=None) + start_time: typing.Optional[dt.datetime] = pydantic_v1.Field( + alias="startTime", default=None + ) + end_time: typing.Optional[dt.datetime] = pydantic_v1.Field( + alias="endTime", default=None + ) + completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field( + alias="completionStartTime", default=None + ) model: typing.Optional[str] = None model_parameters: typing.Optional[typing.Dict[str, MapValue]] = pydantic_v1.Field( alias="modelParameters", default=None @@ -29,19 +35,36 @@ class ObservationBody(pydantic_v1.BaseModel): output: typing.Optional[typing.Any] = None usage: typing.Optional[Usage] = None level: typing.Optional[ObservationLevel] = None - status_message: typing.Optional[str] = pydantic_v1.Field(alias="statusMessage", default=None) - parent_observation_id: typing.Optional[str] = pydantic_v1.Field(alias="parentObservationId", default=None) + status_message: typing.Optional[str] = pydantic_v1.Field( + alias="statusMessage", default=None + ) + parent_observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="parentObservationId", default=None + ) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/open_ai_usage.py b/langfuse/api/resources/ingestion/types/open_ai_usage.py index c5a8ade45..86e7ebd82 100644 --- a/langfuse/api/resources/ingestion/types/open_ai_usage.py +++ b/langfuse/api/resources/ingestion/types/open_ai_usage.py @@ -12,20 +12,39 @@ class OpenAiUsage(pydantic_v1.BaseModel): Usage interface of OpenAI for improved compatibility. """ - prompt_tokens: typing.Optional[int] = pydantic_v1.Field(alias="promptTokens", default=None) - completion_tokens: typing.Optional[int] = pydantic_v1.Field(alias="completionTokens", default=None) - total_tokens: typing.Optional[int] = pydantic_v1.Field(alias="totalTokens", default=None) + prompt_tokens: typing.Optional[int] = pydantic_v1.Field( + alias="promptTokens", default=None + ) + completion_tokens: typing.Optional[int] = pydantic_v1.Field( + alias="completionTokens", default=None + ) + total_tokens: typing.Optional[int] = pydantic_v1.Field( + alias="totalTokens", default=None + ) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/open_ai_usage_schema.py b/langfuse/api/resources/ingestion/types/open_ai_usage_schema.py index 04055f84a..ecf755bb3 100644 --- a/langfuse/api/resources/ingestion/types/open_ai_usage_schema.py +++ b/langfuse/api/resources/ingestion/types/open_ai_usage_schema.py @@ -15,15 +15,28 @@ class OpenAiUsageSchema(pydantic_v1.BaseModel): completion_tokens_details: typing.Optional[typing.Dict[str, int]] = None def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/optional_observation_body.py b/langfuse/api/resources/ingestion/types/optional_observation_body.py index d38e07da4..bd7cb5808 100644 --- a/langfuse/api/resources/ingestion/types/optional_observation_body.py +++ b/langfuse/api/resources/ingestion/types/optional_observation_body.py @@ -11,25 +11,44 @@ class OptionalObservationBody(pydantic_v1.BaseModel): trace_id: typing.Optional[str] = pydantic_v1.Field(alias="traceId", default=None) name: typing.Optional[str] = None - start_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="startTime", default=None) + start_time: typing.Optional[dt.datetime] = pydantic_v1.Field( + alias="startTime", default=None + ) metadata: typing.Optional[typing.Any] = None input: typing.Optional[typing.Any] = None output: typing.Optional[typing.Any] = None level: typing.Optional[ObservationLevel] = None - status_message: typing.Optional[str] = pydantic_v1.Field(alias="statusMessage", default=None) - parent_observation_id: typing.Optional[str] = pydantic_v1.Field(alias="parentObservationId", default=None) + status_message: typing.Optional[str] = pydantic_v1.Field( + alias="statusMessage", default=None + ) + parent_observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="parentObservationId", default=None + ) version: typing.Optional[str] = None def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/score_body.py b/langfuse/api/resources/ingestion/types/score_body.py index 3b41d5d61..aad152dd8 100644 --- a/langfuse/api/resources/ingestion/types/score_body.py +++ b/langfuse/api/resources/ingestion/types/score_body.py @@ -30,9 +30,13 @@ class ScoreBody(pydantic_v1.BaseModel): The value of the score. Must be passed as string for categorical scores, and numeric for boolean and numeric scores. Boolean score values must equal either 1 or 0 (true or false) """ - observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) + observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="observationId", default=None + ) comment: typing.Optional[str] = None - data_type: typing.Optional[ScoreDataType] = pydantic_v1.Field(alias="dataType", default=None) + data_type: typing.Optional[ScoreDataType] = pydantic_v1.Field( + alias="dataType", default=None + ) """ When set, must match the score value's type. If not set, will be inferred from the score value or config """ @@ -43,15 +47,28 @@ class ScoreBody(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/score_event.py b/langfuse/api/resources/ingestion/types/score_event.py index 36e4e1424..ea05aedef 100644 --- a/langfuse/api/resources/ingestion/types/score_event.py +++ b/langfuse/api/resources/ingestion/types/score_event.py @@ -13,15 +13,28 @@ class ScoreEvent(BaseEvent): body: ScoreBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/sdk_log_body.py b/langfuse/api/resources/ingestion/types/sdk_log_body.py index 7bf69e4d4..df8972860 100644 --- a/langfuse/api/resources/ingestion/types/sdk_log_body.py +++ b/langfuse/api/resources/ingestion/types/sdk_log_body.py @@ -11,15 +11,28 @@ class SdkLogBody(pydantic_v1.BaseModel): log: typing.Any def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/sdk_log_event.py b/langfuse/api/resources/ingestion/types/sdk_log_event.py index e4fcc2672..d7ad87de8 100644 --- a/langfuse/api/resources/ingestion/types/sdk_log_event.py +++ b/langfuse/api/resources/ingestion/types/sdk_log_event.py @@ -13,15 +13,28 @@ class SdkLogEvent(BaseEvent): body: SdkLogBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/trace_body.py b/langfuse/api/resources/ingestion/types/trace_body.py index de01c2f02..42cb4f197 100644 --- a/langfuse/api/resources/ingestion/types/trace_body.py +++ b/langfuse/api/resources/ingestion/types/trace_body.py @@ -14,7 +14,9 @@ class TraceBody(pydantic_v1.BaseModel): user_id: typing.Optional[str] = pydantic_v1.Field(alias="userId", default=None) input: typing.Optional[typing.Any] = None output: typing.Optional[typing.Any] = None - session_id: typing.Optional[str] = pydantic_v1.Field(alias="sessionId", default=None) + session_id: typing.Optional[str] = pydantic_v1.Field( + alias="sessionId", default=None + ) release: typing.Optional[str] = None version: typing.Optional[str] = None metadata: typing.Optional[typing.Any] = None @@ -25,15 +27,28 @@ class TraceBody(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/trace_event.py b/langfuse/api/resources/ingestion/types/trace_event.py index c2e39defa..b84ddd615 100644 --- a/langfuse/api/resources/ingestion/types/trace_event.py +++ b/langfuse/api/resources/ingestion/types/trace_event.py @@ -13,15 +13,28 @@ class TraceEvent(BaseEvent): body: TraceBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/update_event_body.py b/langfuse/api/resources/ingestion/types/update_event_body.py index 12c0b0f45..35bbb359b 100644 --- a/langfuse/api/resources/ingestion/types/update_event_body.py +++ b/langfuse/api/resources/ingestion/types/update_event_body.py @@ -12,15 +12,28 @@ class UpdateEventBody(OptionalObservationBody): id: str def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/update_generation_body.py b/langfuse/api/resources/ingestion/types/update_generation_body.py index b1305bbe6..2058543af 100644 --- a/langfuse/api/resources/ingestion/types/update_generation_body.py +++ b/langfuse/api/resources/ingestion/types/update_generation_body.py @@ -12,27 +12,50 @@ class UpdateGenerationBody(UpdateSpanBody): - completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="completionStartTime", default=None) + completion_start_time: typing.Optional[dt.datetime] = pydantic_v1.Field( + alias="completionStartTime", default=None + ) model: typing.Optional[str] = None model_parameters: typing.Optional[typing.Dict[str, MapValue]] = pydantic_v1.Field( alias="modelParameters", default=None ) usage: typing.Optional[IngestionUsage] = None - prompt_name: typing.Optional[str] = pydantic_v1.Field(alias="promptName", default=None) - usage_details: typing.Optional[UsageDetails] = pydantic_v1.Field(alias="usageDetails", default=None) - cost_details: typing.Optional[typing.Dict[str, float]] = pydantic_v1.Field(alias="costDetails", default=None) - prompt_version: typing.Optional[int] = pydantic_v1.Field(alias="promptVersion", default=None) + prompt_name: typing.Optional[str] = pydantic_v1.Field( + alias="promptName", default=None + ) + usage_details: typing.Optional[UsageDetails] = pydantic_v1.Field( + alias="usageDetails", default=None + ) + cost_details: typing.Optional[typing.Dict[str, float]] = pydantic_v1.Field( + alias="costDetails", default=None + ) + prompt_version: typing.Optional[int] = pydantic_v1.Field( + alias="promptVersion", default=None + ) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/update_generation_event.py b/langfuse/api/resources/ingestion/types/update_generation_event.py index 33c8b42f0..da8f6a9fa 100644 --- a/langfuse/api/resources/ingestion/types/update_generation_event.py +++ b/langfuse/api/resources/ingestion/types/update_generation_event.py @@ -13,15 +13,28 @@ class UpdateGenerationEvent(BaseEvent): body: UpdateGenerationBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/update_observation_event.py b/langfuse/api/resources/ingestion/types/update_observation_event.py index ebc1353cf..9d7af357f 100644 --- a/langfuse/api/resources/ingestion/types/update_observation_event.py +++ b/langfuse/api/resources/ingestion/types/update_observation_event.py @@ -13,15 +13,28 @@ class UpdateObservationEvent(BaseEvent): body: ObservationBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/update_span_body.py b/langfuse/api/resources/ingestion/types/update_span_body.py index 1575ba553..e3484879b 100644 --- a/langfuse/api/resources/ingestion/types/update_span_body.py +++ b/langfuse/api/resources/ingestion/types/update_span_body.py @@ -9,18 +9,33 @@ class UpdateSpanBody(UpdateEventBody): - end_time: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="endTime", default=None) + end_time: typing.Optional[dt.datetime] = pydantic_v1.Field( + alias="endTime", default=None + ) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/ingestion/types/update_span_event.py b/langfuse/api/resources/ingestion/types/update_span_event.py index 3ad1b61b4..ec7d83b15 100644 --- a/langfuse/api/resources/ingestion/types/update_span_event.py +++ b/langfuse/api/resources/ingestion/types/update_span_event.py @@ -13,15 +13,28 @@ class UpdateSpanEvent(BaseEvent): body: UpdateSpanBody def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/media/client.py b/langfuse/api/resources/media/client.py index b6815cc8f..0dcd75e8e 100644 --- a/langfuse/api/resources/media/client.py +++ b/langfuse/api/resources/media/client.py @@ -26,7 +26,9 @@ class MediaClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def get(self, media_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetMediaResponse: + def get( + self, media_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetMediaResponse: """ Get a media record @@ -59,7 +61,9 @@ def get(self, media_id: str, *, request_options: typing.Optional[RequestOptions] ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/media/{jsonable_encoder(media_id)}", method="GET", request_options=request_options + f"api/public/media/{jsonable_encoder(media_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -67,20 +71,32 @@ def get(self, media_id: str, *, request_options: typing.Optional[RequestOptions] if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def patch( - self, media_id: str, *, request: PatchMediaBody, request_options: typing.Optional[RequestOptions] = None + self, + media_id: str, + *, + request: PatchMediaBody, + request_options: typing.Optional[RequestOptions] = None, ) -> None: """ Patch a media record @@ -139,20 +155,31 @@ def patch( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def get_upload_url( - self, *, request: GetMediaUploadUrlRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: GetMediaUploadUrlRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> GetMediaUploadUrlResponse: """ Get a presigned upload URL for a media record @@ -193,21 +220,35 @@ def get_upload_url( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/media", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/media", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetMediaUploadUrlResponse, _response.json()) # type: ignore + return pydantic_v1.parse_obj_as( + GetMediaUploadUrlResponse, _response.json() + ) # type: ignore if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -218,7 +259,9 @@ class AsyncMediaClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def get(self, media_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetMediaResponse: + async def get( + self, media_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetMediaResponse: """ Get a media record @@ -259,7 +302,9 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/media/{jsonable_encoder(media_id)}", method="GET", request_options=request_options + f"api/public/media/{jsonable_encoder(media_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -267,20 +312,32 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def patch( - self, media_id: str, *, request: PatchMediaBody, request_options: typing.Optional[RequestOptions] = None + self, + media_id: str, + *, + request: PatchMediaBody, + request_options: typing.Optional[RequestOptions] = None, ) -> None: """ Patch a media record @@ -346,20 +403,31 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def get_upload_url( - self, *, request: GetMediaUploadUrlRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: GetMediaUploadUrlRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> GetMediaUploadUrlResponse: """ Get a presigned upload URL for a media record @@ -408,21 +476,35 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/media", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/media", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetMediaUploadUrlResponse, _response.json()) # type: ignore + return pydantic_v1.parse_obj_as( + GetMediaUploadUrlResponse, _response.json() + ) # type: ignore if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/media/types/get_media_response.py b/langfuse/api/resources/media/types/get_media_response.py index 102816e8f..fa5368872 100644 --- a/langfuse/api/resources/media/types/get_media_response.py +++ b/langfuse/api/resources/media/types/get_media_response.py @@ -39,15 +39,28 @@ class GetMediaResponse(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/media/types/get_media_upload_url_request.py b/langfuse/api/resources/media/types/get_media_upload_url_request.py index 33514f397..d0cde59fe 100644 --- a/langfuse/api/resources/media/types/get_media_upload_url_request.py +++ b/langfuse/api/resources/media/types/get_media_upload_url_request.py @@ -14,7 +14,9 @@ class GetMediaUploadUrlRequest(pydantic_v1.BaseModel): The trace ID associated with the media record """ - observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) + observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="observationId", default=None + ) """ The observation ID associated with the media record. If the media record is associated directly with a trace, this will be null. """ @@ -36,15 +38,28 @@ class GetMediaUploadUrlRequest(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/media/types/get_media_upload_url_response.py b/langfuse/api/resources/media/types/get_media_upload_url_response.py index 06e2e8742..fadc76c01 100644 --- a/langfuse/api/resources/media/types/get_media_upload_url_response.py +++ b/langfuse/api/resources/media/types/get_media_upload_url_response.py @@ -8,7 +8,9 @@ class GetMediaUploadUrlResponse(pydantic_v1.BaseModel): - upload_url: typing.Optional[str] = pydantic_v1.Field(alias="uploadUrl", default=None) + upload_url: typing.Optional[str] = pydantic_v1.Field( + alias="uploadUrl", default=None + ) """ The presigned upload URL. If the asset is already uploaded, this will be null """ @@ -19,15 +21,28 @@ class GetMediaUploadUrlResponse(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/media/types/patch_media_body.py b/langfuse/api/resources/media/types/patch_media_body.py index 49108c175..49f0c3432 100644 --- a/langfuse/api/resources/media/types/patch_media_body.py +++ b/langfuse/api/resources/media/types/patch_media_body.py @@ -18,26 +18,43 @@ class PatchMediaBody(pydantic_v1.BaseModel): The HTTP status code of the upload """ - upload_http_error: typing.Optional[str] = pydantic_v1.Field(alias="uploadHttpError", default=None) + upload_http_error: typing.Optional[str] = pydantic_v1.Field( + alias="uploadHttpError", default=None + ) """ The HTTP error message of the upload """ - upload_time_ms: typing.Optional[int] = pydantic_v1.Field(alias="uploadTimeMs", default=None) + upload_time_ms: typing.Optional[int] = pydantic_v1.Field( + alias="uploadTimeMs", default=None + ) """ The time in milliseconds it took to upload the media record """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/metrics/client.py b/langfuse/api/resources/metrics/client.py index 6d80a605a..6447b1133 100644 --- a/langfuse/api/resources/metrics/client.py +++ b/langfuse/api/resources/metrics/client.py @@ -31,7 +31,7 @@ def daily( tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, from_timestamp: typing.Optional[dt.datetime] = None, to_timestamp: typing.Optional[dt.datetime] = None, - request_options: typing.Optional[RequestOptions] = None + request_options: typing.Optional[RequestOptions] = None, ) -> DailyMetrics: """ Get daily metrics of the Langfuse project @@ -103,8 +103,12 @@ def daily( "traceName": trace_name, "userId": user_id, "tags": tags, - "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, - "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, + "fromTimestamp": serialize_datetime(from_timestamp) + if from_timestamp is not None + else None, + "toTimestamp": serialize_datetime(to_timestamp) + if to_timestamp is not None + else None, }, request_options=request_options, ) @@ -114,13 +118,21 @@ def daily( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -141,7 +153,7 @@ async def daily( tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, from_timestamp: typing.Optional[dt.datetime] = None, to_timestamp: typing.Optional[dt.datetime] = None, - request_options: typing.Optional[RequestOptions] = None + request_options: typing.Optional[RequestOptions] = None, ) -> DailyMetrics: """ Get daily metrics of the Langfuse project @@ -220,8 +232,12 @@ async def main() -> None: "traceName": trace_name, "userId": user_id, "tags": tags, - "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, - "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, + "fromTimestamp": serialize_datetime(from_timestamp) + if from_timestamp is not None + else None, + "toTimestamp": serialize_datetime(to_timestamp) + if to_timestamp is not None + else None, }, request_options=request_options, ) @@ -231,13 +247,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/metrics/types/daily_metrics.py b/langfuse/api/resources/metrics/types/daily_metrics.py index 52d5f151d..36a12a3d6 100644 --- a/langfuse/api/resources/metrics/types/daily_metrics.py +++ b/langfuse/api/resources/metrics/types/daily_metrics.py @@ -18,15 +18,28 @@ class DailyMetrics(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/metrics/types/daily_metrics_details.py b/langfuse/api/resources/metrics/types/daily_metrics_details.py index 3a208ab10..e97f65446 100644 --- a/langfuse/api/resources/metrics/types/daily_metrics_details.py +++ b/langfuse/api/resources/metrics/types/daily_metrics_details.py @@ -20,15 +20,28 @@ class DailyMetricsDetails(pydantic_v1.BaseModel): usage: typing.List[UsageByModel] def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/metrics/types/usage_by_model.py b/langfuse/api/resources/metrics/types/usage_by_model.py index b94cc02ac..3ff6de59c 100644 --- a/langfuse/api/resources/metrics/types/usage_by_model.py +++ b/langfuse/api/resources/metrics/types/usage_by_model.py @@ -36,15 +36,28 @@ class UsageByModel(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/models/client.py b/langfuse/api/resources/models/client.py index c819df2fb..1ebac9d07 100644 --- a/langfuse/api/resources/models/client.py +++ b/langfuse/api/resources/models/client.py @@ -25,7 +25,12 @@ class ModelsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def create(self, *, request: CreateModelRequest, request_options: typing.Optional[RequestOptions] = None) -> Model: + def create( + self, + *, + request: CreateModelRequest, + request_options: typing.Optional[RequestOptions] = None, + ) -> Model: """ Create a model @@ -72,7 +77,11 @@ def create(self, *, request: CreateModelRequest, request_options: typing.Optiona ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/models", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/models", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -80,13 +89,21 @@ def create(self, *, request: CreateModelRequest, request_options: typing.Optiona if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -135,7 +152,10 @@ def list( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/models", method="GET", params={"page": page, "limit": limit}, request_options=request_options + "api/public/models", + method="GET", + params={"page": page, "limit": limit}, + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -143,19 +163,29 @@ def list( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Model: + def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> Model: """ Get a model @@ -187,7 +217,9 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/models/{jsonable_encoder(id)}", method="GET", request_options=request_options + f"api/public/models/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -195,19 +227,29 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: + def delete( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> None: """ Delete a model. Cannot delete models managed by Langfuse. You can create your own definition with the same modelName to override the definition though. @@ -239,7 +281,9 @@ def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/models/{jsonable_encoder(id)}", method="DELETE", request_options=request_options + f"api/public/models/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -247,13 +291,21 @@ def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -265,7 +317,10 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def create( - self, *, request: CreateModelRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreateModelRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> Model: """ Create a model @@ -320,7 +375,11 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/models", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/models", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -328,13 +387,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -391,7 +458,10 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/models", method="GET", params={"page": page, "limit": limit}, request_options=request_options + "api/public/models", + method="GET", + params={"page": page, "limit": limit}, + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -399,19 +469,29 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Model: + async def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> Model: """ Get a model @@ -451,7 +531,9 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/models/{jsonable_encoder(id)}", method="GET", request_options=request_options + f"api/public/models/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -459,19 +541,29 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: + async def delete( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> None: """ Delete a model. Cannot delete models managed by Langfuse. You can create your own definition with the same modelName to override the definition though. @@ -511,7 +603,9 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/models/{jsonable_encoder(id)}", method="DELETE", request_options=request_options + f"api/public/models/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -519,13 +613,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/models/types/create_model_request.py b/langfuse/api/resources/models/types/create_model_request.py index a2c5fedb5..b3d8a6462 100644 --- a/langfuse/api/resources/models/types/create_model_request.py +++ b/langfuse/api/resources/models/types/create_model_request.py @@ -19,7 +19,9 @@ class CreateModelRequest(pydantic_v1.BaseModel): Regex pattern which matches this model definition to generation.model. Useful in case of fine-tuned models. If you want to exact match, use `(?i)^modelname$` """ - start_date: typing.Optional[dt.datetime] = pydantic_v1.Field(alias="startDate", default=None) + start_date: typing.Optional[dt.datetime] = pydantic_v1.Field( + alias="startDate", default=None + ) """ Apply only to generations which are newer than this ISO date. """ @@ -29,41 +31,64 @@ class CreateModelRequest(pydantic_v1.BaseModel): Unit used by this model. """ - input_price: typing.Optional[float] = pydantic_v1.Field(alias="inputPrice", default=None) + input_price: typing.Optional[float] = pydantic_v1.Field( + alias="inputPrice", default=None + ) """ Price (USD) per input unit """ - output_price: typing.Optional[float] = pydantic_v1.Field(alias="outputPrice", default=None) + output_price: typing.Optional[float] = pydantic_v1.Field( + alias="outputPrice", default=None + ) """ Price (USD) per output unit """ - total_price: typing.Optional[float] = pydantic_v1.Field(alias="totalPrice", default=None) + total_price: typing.Optional[float] = pydantic_v1.Field( + alias="totalPrice", default=None + ) """ Price (USD) per total units. Cannot be set if input or output price is set. """ - tokenizer_id: typing.Optional[str] = pydantic_v1.Field(alias="tokenizerId", default=None) + tokenizer_id: typing.Optional[str] = pydantic_v1.Field( + alias="tokenizerId", default=None + ) """ Optional. Tokenizer to be applied to observations which match to this model. See docs for more details. """ - tokenizer_config: typing.Optional[typing.Any] = pydantic_v1.Field(alias="tokenizerConfig", default=None) + tokenizer_config: typing.Optional[typing.Any] = pydantic_v1.Field( + alias="tokenizerConfig", default=None + ) """ Optional. Configuration for the selected tokenizer. Needs to be JSON. See docs for more details. """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/models/types/paginated_models.py b/langfuse/api/resources/models/types/paginated_models.py index 308054c12..3469a1fe6 100644 --- a/langfuse/api/resources/models/types/paginated_models.py +++ b/langfuse/api/resources/models/types/paginated_models.py @@ -14,15 +14,28 @@ class PaginatedModels(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/observations/client.py b/langfuse/api/resources/observations/client.py index 93078238d..d937841b9 100644 --- a/langfuse/api/resources/observations/client.py +++ b/langfuse/api/resources/observations/client.py @@ -23,7 +23,12 @@ class ObservationsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def get(self, observation_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ObservationsView: + def get( + self, + observation_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> ObservationsView: """ Get a observation @@ -56,7 +61,9 @@ def get(self, observation_id: str, *, request_options: typing.Optional[RequestOp ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/observations/{jsonable_encoder(observation_id)}", method="GET", request_options=request_options + f"api/public/observations/{jsonable_encoder(observation_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -64,13 +71,21 @@ def get(self, observation_id: str, *, request_options: typing.Optional[RequestOp if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -170,8 +185,12 @@ def get_many( "type": type, "traceId": trace_id, "parentObservationId": parent_observation_id, - "fromStartTime": serialize_datetime(from_start_time) if from_start_time is not None else None, - "toStartTime": serialize_datetime(to_start_time) if to_start_time is not None else None, + "fromStartTime": serialize_datetime(from_start_time) + if from_start_time is not None + else None, + "toStartTime": serialize_datetime(to_start_time) + if to_start_time is not None + else None, "version": version, }, request_options=request_options, @@ -182,13 +201,21 @@ def get_many( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -200,7 +227,10 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def get( - self, observation_id: str, *, request_options: typing.Optional[RequestOptions] = None + self, + observation_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, ) -> ObservationsView: """ Get a observation @@ -242,7 +272,9 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/observations/{jsonable_encoder(observation_id)}", method="GET", request_options=request_options + f"api/public/observations/{jsonable_encoder(observation_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -250,13 +282,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -363,8 +403,12 @@ async def main() -> None: "type": type, "traceId": trace_id, "parentObservationId": parent_observation_id, - "fromStartTime": serialize_datetime(from_start_time) if from_start_time is not None else None, - "toStartTime": serialize_datetime(to_start_time) if to_start_time is not None else None, + "fromStartTime": serialize_datetime(from_start_time) + if from_start_time is not None + else None, + "toStartTime": serialize_datetime(to_start_time) + if to_start_time is not None + else None, "version": version, }, request_options=request_options, @@ -375,13 +419,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/observations/types/observations.py b/langfuse/api/resources/observations/types/observations.py index 4cf452cb2..1534dc87e 100644 --- a/langfuse/api/resources/observations/types/observations.py +++ b/langfuse/api/resources/observations/types/observations.py @@ -14,15 +14,28 @@ class Observations(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/observations/types/observations_views.py b/langfuse/api/resources/observations/types/observations_views.py index 5ff652f67..ed86b7d1e 100644 --- a/langfuse/api/resources/observations/types/observations_views.py +++ b/langfuse/api/resources/observations/types/observations_views.py @@ -14,15 +14,28 @@ class ObservationsViews(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/projects/client.py b/langfuse/api/resources/projects/client.py index 6973753d3..3f4e38e6e 100644 --- a/langfuse/api/resources/projects/client.py +++ b/langfuse/api/resources/projects/client.py @@ -19,7 +19,9 @@ class ProjectsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Projects: + def get( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> Projects: """ Get Project associated with API key @@ -55,13 +57,21 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Pro if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -72,7 +82,9 @@ class AsyncProjectsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Projects: + async def get( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> Projects: """ Get Project associated with API key @@ -116,13 +128,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/projects/types/project.py b/langfuse/api/resources/projects/types/project.py index 8c0f5fcbd..ad2b48cd2 100644 --- a/langfuse/api/resources/projects/types/project.py +++ b/langfuse/api/resources/projects/types/project.py @@ -12,15 +12,28 @@ class Project(pydantic_v1.BaseModel): name: str def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/projects/types/projects.py b/langfuse/api/resources/projects/types/projects.py index 9e0be782d..c5eaabfbd 100644 --- a/langfuse/api/resources/projects/types/projects.py +++ b/langfuse/api/resources/projects/types/projects.py @@ -12,15 +12,28 @@ class Projects(pydantic_v1.BaseModel): data: typing.List[Project] def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/prompt_version/client.py b/langfuse/api/resources/prompt_version/client.py index 781dba7e5..9b7b9a74f 100644 --- a/langfuse/api/resources/prompt_version/client.py +++ b/langfuse/api/resources/prompt_version/client.py @@ -83,13 +83,21 @@ def update( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -168,13 +176,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/prompts/client.py b/langfuse/api/resources/prompts/client.py index 9d0ac5d22..c21052d19 100644 --- a/langfuse/api/resources/prompts/client.py +++ b/langfuse/api/resources/prompts/client.py @@ -86,13 +86,21 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -177,31 +185,48 @@ def list( "tag": tag, "page": page, "limit": limit, - "fromUpdatedAt": serialize_datetime(from_updated_at) if from_updated_at is not None else None, - "toUpdatedAt": serialize_datetime(to_updated_at) if to_updated_at is not None else None, + "fromUpdatedAt": serialize_datetime(from_updated_at) + if from_updated_at is not None + else None, + "toUpdatedAt": serialize_datetime(to_updated_at) + if to_updated_at is not None + else None, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(PromptMetaListResponse, _response.json()) # type: ignore + return pydantic_v1.parse_obj_as( + PromptMetaListResponse, _response.json() + ) # type: ignore if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) def create( - self, *, request: CreatePromptRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreatePromptRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> Prompt: """ Create a new version for the prompt with the given `name` @@ -246,7 +271,11 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/v2/prompts", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/v2/prompts", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -254,13 +283,21 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -338,13 +375,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -436,31 +481,48 @@ async def main() -> None: "tag": tag, "page": page, "limit": limit, - "fromUpdatedAt": serialize_datetime(from_updated_at) if from_updated_at is not None else None, - "toUpdatedAt": serialize_datetime(to_updated_at) if to_updated_at is not None else None, + "fromUpdatedAt": serialize_datetime(from_updated_at) + if from_updated_at is not None + else None, + "toUpdatedAt": serialize_datetime(to_updated_at) + if to_updated_at is not None + else None, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(PromptMetaListResponse, _response.json()) # type: ignore + return pydantic_v1.parse_obj_as( + PromptMetaListResponse, _response.json() + ) # type: ignore if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def create( - self, *, request: CreatePromptRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreatePromptRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> Prompt: """ Create a new version for the prompt with the given `name` @@ -513,7 +575,11 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/v2/prompts", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/v2/prompts", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -521,13 +587,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/prompts/types/__init__.py b/langfuse/api/resources/prompts/types/__init__.py index 99bcf4011..403efcc68 100644 --- a/langfuse/api/resources/prompts/types/__init__.py +++ b/langfuse/api/resources/prompts/types/__init__.py @@ -1,7 +1,11 @@ # This file was auto-generated by Fern from our API Definition. from .create_chat_prompt_request import CreateChatPromptRequest -from .create_prompt_request import CreatePromptRequest, CreatePromptRequest_Chat, CreatePromptRequest_Text +from .create_prompt_request import ( + CreatePromptRequest, + CreatePromptRequest_Chat, + CreatePromptRequest_Text, +) from .create_text_prompt_request import CreateTextPromptRequest from .prompt_meta import PromptMeta from .prompt_meta_list_response import PromptMetaListResponse diff --git a/langfuse/api/resources/prompts/types/create_chat_prompt_request.py b/langfuse/api/resources/prompts/types/create_chat_prompt_request.py index e2b40102d..f101f8d75 100644 --- a/langfuse/api/resources/prompts/types/create_chat_prompt_request.py +++ b/langfuse/api/resources/prompts/types/create_chat_prompt_request.py @@ -23,15 +23,28 @@ class CreateChatPromptRequest(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/prompts/types/create_prompt_request.py b/langfuse/api/resources/prompts/types/create_prompt_request.py index 2c9b0f877..e18167f0c 100644 --- a/langfuse/api/resources/prompts/types/create_prompt_request.py +++ b/langfuse/api/resources/prompts/types/create_prompt_request.py @@ -19,15 +19,28 @@ class CreatePromptRequest_Chat(pydantic_v1.BaseModel): type: typing.Literal["chat"] = "chat" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -46,15 +59,28 @@ class CreatePromptRequest_Text(pydantic_v1.BaseModel): type: typing.Literal["text"] = "text" def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/prompts/types/create_text_prompt_request.py b/langfuse/api/resources/prompts/types/create_text_prompt_request.py index 751b4492c..31b1c0eee 100644 --- a/langfuse/api/resources/prompts/types/create_text_prompt_request.py +++ b/langfuse/api/resources/prompts/types/create_text_prompt_request.py @@ -22,15 +22,28 @@ class CreateTextPromptRequest(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/prompts/types/prompt_meta.py b/langfuse/api/resources/prompts/types/prompt_meta.py index f0621e105..bbb028fb2 100644 --- a/langfuse/api/resources/prompts/types/prompt_meta.py +++ b/langfuse/api/resources/prompts/types/prompt_meta.py @@ -19,15 +19,28 @@ class PromptMeta(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/prompts/types/prompt_meta_list_response.py b/langfuse/api/resources/prompts/types/prompt_meta_list_response.py index 6ebf13c4a..d3dccf650 100644 --- a/langfuse/api/resources/prompts/types/prompt_meta_list_response.py +++ b/langfuse/api/resources/prompts/types/prompt_meta_list_response.py @@ -14,15 +14,28 @@ class PromptMetaListResponse(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/score/client.py b/langfuse/api/resources/score/client.py index 4f7fc0e4f..2c911449d 100644 --- a/langfuse/api/resources/score/client.py +++ b/langfuse/api/resources/score/client.py @@ -31,7 +31,10 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def create( - self, *, request: CreateScoreRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreateScoreRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> CreateScoreResponse: """ Create a score @@ -69,7 +72,11 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/scores", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/scores", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -77,13 +84,21 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -105,7 +120,9 @@ def get( config_id: typing.Optional[str] = None, queue_id: typing.Optional[str] = None, data_type: typing.Optional[ScoreDataType] = None, - trace_tags: typing.Optional[typing.Union[typing.Sequence[str], typing.Sequence[typing.Sequence[str]]]] = None, + trace_tags: typing.Optional[ + typing.Union[typing.Sequence[str], typing.Sequence[typing.Sequence[str]]] + ] = None, request_options: typing.Optional[RequestOptions] = None, ) -> GetScoresResponse: """ @@ -206,8 +223,12 @@ def get( "limit": limit, "userId": user_id, "name": name, - "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, - "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, + "fromTimestamp": serialize_datetime(from_timestamp) + if from_timestamp is not None + else None, + "toTimestamp": serialize_datetime(to_timestamp) + if to_timestamp is not None + else None, "source": source, "operator": operator, "value": value, @@ -225,19 +246,29 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def get_by_id(self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Score: + def get_by_id( + self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> Score: """ Get a score @@ -270,7 +301,9 @@ def get_by_id(self, score_id: str, *, request_options: typing.Optional[RequestOp ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/scores/{jsonable_encoder(score_id)}", method="GET", request_options=request_options + f"api/public/scores/{jsonable_encoder(score_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -278,19 +311,29 @@ def get_by_id(self, score_id: str, *, request_options: typing.Optional[RequestOp if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def delete(self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: + def delete( + self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> None: """ Delete a score @@ -323,7 +366,9 @@ def delete(self, score_id: str, *, request_options: typing.Optional[RequestOptio ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/scores/{jsonable_encoder(score_id)}", method="DELETE", request_options=request_options + f"api/public/scores/{jsonable_encoder(score_id)}", + method="DELETE", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -331,13 +376,21 @@ def delete(self, score_id: str, *, request_options: typing.Optional[RequestOptio if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -349,7 +402,10 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def create( - self, *, request: CreateScoreRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreateScoreRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> CreateScoreResponse: """ Create a score @@ -395,7 +451,11 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/scores", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/scores", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -403,13 +463,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -431,7 +499,9 @@ async def get( config_id: typing.Optional[str] = None, queue_id: typing.Optional[str] = None, data_type: typing.Optional[ScoreDataType] = None, - trace_tags: typing.Optional[typing.Union[typing.Sequence[str], typing.Sequence[typing.Sequence[str]]]] = None, + trace_tags: typing.Optional[ + typing.Union[typing.Sequence[str], typing.Sequence[typing.Sequence[str]]] + ] = None, request_options: typing.Optional[RequestOptions] = None, ) -> GetScoresResponse: """ @@ -539,8 +609,12 @@ async def main() -> None: "limit": limit, "userId": user_id, "name": name, - "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, - "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, + "fromTimestamp": serialize_datetime(from_timestamp) + if from_timestamp is not None + else None, + "toTimestamp": serialize_datetime(to_timestamp) + if to_timestamp is not None + else None, "source": source, "operator": operator, "value": value, @@ -558,19 +632,29 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def get_by_id(self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Score: + async def get_by_id( + self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> Score: """ Get a score @@ -611,7 +695,9 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/scores/{jsonable_encoder(score_id)}", method="GET", request_options=request_options + f"api/public/scores/{jsonable_encoder(score_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -619,19 +705,29 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def delete(self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: + async def delete( + self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> None: """ Delete a score @@ -672,7 +768,9 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/scores/{jsonable_encoder(score_id)}", method="DELETE", request_options=request_options + f"api/public/scores/{jsonable_encoder(score_id)}", + method="DELETE", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -680,13 +778,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/score/types/create_score_request.py b/langfuse/api/resources/score/types/create_score_request.py index d08990189..8a76f464e 100644 --- a/langfuse/api/resources/score/types/create_score_request.py +++ b/langfuse/api/resources/score/types/create_score_request.py @@ -30,9 +30,13 @@ class CreateScoreRequest(pydantic_v1.BaseModel): The value of the score. Must be passed as string for categorical scores, and numeric for boolean and numeric scores. Boolean score values must equal either 1 or 0 (true or false) """ - observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) + observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="observationId", default=None + ) comment: typing.Optional[str] = None - data_type: typing.Optional[ScoreDataType] = pydantic_v1.Field(alias="dataType", default=None) + data_type: typing.Optional[ScoreDataType] = pydantic_v1.Field( + alias="dataType", default=None + ) """ The data type of the score. When passing a configId this field is inferred. Otherwise, this field must be passed or will default to numeric. """ @@ -43,15 +47,28 @@ class CreateScoreRequest(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/score/types/create_score_response.py b/langfuse/api/resources/score/types/create_score_response.py index db7fba163..a8c90fce2 100644 --- a/langfuse/api/resources/score/types/create_score_response.py +++ b/langfuse/api/resources/score/types/create_score_response.py @@ -14,15 +14,28 @@ class CreateScoreResponse(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/score/types/get_scores_response.py b/langfuse/api/resources/score/types/get_scores_response.py index 820697ec7..777bb799b 100644 --- a/langfuse/api/resources/score/types/get_scores_response.py +++ b/langfuse/api/resources/score/types/get_scores_response.py @@ -14,15 +14,28 @@ class GetScoresResponse(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/score/types/get_scores_response_data.py b/langfuse/api/resources/score/types/get_scores_response_data.py index dbc65673f..e1b317975 100644 --- a/langfuse/api/resources/score/types/get_scores_response_data.py +++ b/langfuse/api/resources/score/types/get_scores_response_data.py @@ -18,26 +18,45 @@ class GetScoresResponseData_Numeric(pydantic_v1.BaseModel): trace_id: str = pydantic_v1.Field(alias="traceId") name: str source: ScoreSource - observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) + observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="observationId", default=None + ) timestamp: dt.datetime created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") - author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) + author_user_id: typing.Optional[str] = pydantic_v1.Field( + alias="authorUserId", default=None + ) comment: typing.Optional[str] = None config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) - data_type: typing.Literal["NUMERIC"] = pydantic_v1.Field(alias="dataType", default="NUMERIC") + data_type: typing.Literal["NUMERIC"] = pydantic_v1.Field( + alias="dataType", default="NUMERIC" + ) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -57,26 +76,45 @@ class GetScoresResponseData_Categorical(pydantic_v1.BaseModel): trace_id: str = pydantic_v1.Field(alias="traceId") name: str source: ScoreSource - observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) + observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="observationId", default=None + ) timestamp: dt.datetime created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") - author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) + author_user_id: typing.Optional[str] = pydantic_v1.Field( + alias="authorUserId", default=None + ) comment: typing.Optional[str] = None config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) - data_type: typing.Literal["CATEGORICAL"] = pydantic_v1.Field(alias="dataType", default="CATEGORICAL") + data_type: typing.Literal["CATEGORICAL"] = pydantic_v1.Field( + alias="dataType", default="CATEGORICAL" + ) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -96,26 +134,45 @@ class GetScoresResponseData_Boolean(pydantic_v1.BaseModel): trace_id: str = pydantic_v1.Field(alias="traceId") name: str source: ScoreSource - observation_id: typing.Optional[str] = pydantic_v1.Field(alias="observationId", default=None) + observation_id: typing.Optional[str] = pydantic_v1.Field( + alias="observationId", default=None + ) timestamp: dt.datetime created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") - author_user_id: typing.Optional[str] = pydantic_v1.Field(alias="authorUserId", default=None) + author_user_id: typing.Optional[str] = pydantic_v1.Field( + alias="authorUserId", default=None + ) comment: typing.Optional[str] = None config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) - data_type: typing.Literal["BOOLEAN"] = pydantic_v1.Field(alias="dataType", default="BOOLEAN") + data_type: typing.Literal["BOOLEAN"] = pydantic_v1.Field( + alias="dataType", default="BOOLEAN" + ) def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: @@ -128,5 +185,7 @@ class Config: GetScoresResponseData = typing.Union[ - GetScoresResponseData_Numeric, GetScoresResponseData_Categorical, GetScoresResponseData_Boolean + GetScoresResponseData_Numeric, + GetScoresResponseData_Categorical, + GetScoresResponseData_Boolean, ] diff --git a/langfuse/api/resources/score/types/get_scores_response_data_boolean.py b/langfuse/api/resources/score/types/get_scores_response_data_boolean.py index 00df659d1..4dbf85af2 100644 --- a/langfuse/api/resources/score/types/get_scores_response_data_boolean.py +++ b/langfuse/api/resources/score/types/get_scores_response_data_boolean.py @@ -13,15 +13,28 @@ class GetScoresResponseDataBoolean(BooleanScore): trace: GetScoresResponseTraceData def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/score/types/get_scores_response_data_categorical.py b/langfuse/api/resources/score/types/get_scores_response_data_categorical.py index 4cb2de853..3c619779f 100644 --- a/langfuse/api/resources/score/types/get_scores_response_data_categorical.py +++ b/langfuse/api/resources/score/types/get_scores_response_data_categorical.py @@ -13,15 +13,28 @@ class GetScoresResponseDataCategorical(CategoricalScore): trace: GetScoresResponseTraceData def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/score/types/get_scores_response_data_numeric.py b/langfuse/api/resources/score/types/get_scores_response_data_numeric.py index 8f5814973..127d8f028 100644 --- a/langfuse/api/resources/score/types/get_scores_response_data_numeric.py +++ b/langfuse/api/resources/score/types/get_scores_response_data_numeric.py @@ -13,15 +13,28 @@ class GetScoresResponseDataNumeric(NumericScore): trace: GetScoresResponseTraceData def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/score/types/get_scores_response_trace_data.py b/langfuse/api/resources/score/types/get_scores_response_trace_data.py index 42d14fe5f..efbafadf4 100644 --- a/langfuse/api/resources/score/types/get_scores_response_trace_data.py +++ b/langfuse/api/resources/score/types/get_scores_response_trace_data.py @@ -19,15 +19,28 @@ class GetScoresResponseTraceData(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/score_configs/client.py b/langfuse/api/resources/score_configs/client.py index 886ac95fe..5f8463612 100644 --- a/langfuse/api/resources/score_configs/client.py +++ b/langfuse/api/resources/score_configs/client.py @@ -26,7 +26,10 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper def create( - self, *, request: CreateScoreConfigRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreateScoreConfigRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> ScoreConfig: """ Create a score configuration (config). Score configs are used to define the structure of scores @@ -72,7 +75,11 @@ def create( ) """ _response = self._client_wrapper.httpx_client.request( - "api/public/score-configs", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/score-configs", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -80,13 +87,21 @@ def create( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -146,19 +161,29 @@ def get( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def get_by_id(self, config_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ScoreConfig: + def get_by_id( + self, config_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ScoreConfig: """ Get a score config @@ -191,7 +216,9 @@ def get_by_id(self, config_id: str, *, request_options: typing.Optional[RequestO ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/score-configs/{jsonable_encoder(config_id)}", method="GET", request_options=request_options + f"api/public/score-configs/{jsonable_encoder(config_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -199,13 +226,21 @@ def get_by_id(self, config_id: str, *, request_options: typing.Optional[RequestO if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -217,7 +252,10 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper async def create( - self, *, request: CreateScoreConfigRequest, request_options: typing.Optional[RequestOptions] = None + self, + *, + request: CreateScoreConfigRequest, + request_options: typing.Optional[RequestOptions] = None, ) -> ScoreConfig: """ Create a score configuration (config). Score configs are used to define the structure of scores @@ -271,7 +309,11 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "api/public/score-configs", method="POST", json=request, request_options=request_options, omit=OMIT + "api/public/score-configs", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, ) try: if 200 <= _response.status_code < 300: @@ -279,13 +321,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -353,13 +403,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -408,7 +466,9 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/score-configs/{jsonable_encoder(config_id)}", method="GET", request_options=request_options + f"api/public/score-configs/{jsonable_encoder(config_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -416,13 +476,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/score_configs/types/create_score_config_request.py b/langfuse/api/resources/score_configs/types/create_score_config_request.py index bec260d3b..e136af157 100644 --- a/langfuse/api/resources/score_configs/types/create_score_config_request.py +++ b/langfuse/api/resources/score_configs/types/create_score_config_request.py @@ -12,17 +12,23 @@ class CreateScoreConfigRequest(pydantic_v1.BaseModel): name: str data_type: ScoreDataType = pydantic_v1.Field(alias="dataType") - categories: typing.Optional[typing.List[ConfigCategory]] = pydantic_v1.Field(default=None) + categories: typing.Optional[typing.List[ConfigCategory]] = pydantic_v1.Field( + default=None + ) """ Configure custom categories for categorical scores. Pass a list of objects with `label` and `value` properties. Categories are autogenerated for boolean configs and cannot be passed """ - min_value: typing.Optional[float] = pydantic_v1.Field(alias="minValue", default=None) + min_value: typing.Optional[float] = pydantic_v1.Field( + alias="minValue", default=None + ) """ Configure a minimum value for numerical scores. If not set, the minimum value defaults to -∞ """ - max_value: typing.Optional[float] = pydantic_v1.Field(alias="maxValue", default=None) + max_value: typing.Optional[float] = pydantic_v1.Field( + alias="maxValue", default=None + ) """ Configure a maximum value for numerical scores. If not set, the maximum value defaults to +∞ """ @@ -33,15 +39,28 @@ class CreateScoreConfigRequest(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/score_configs/types/score_configs.py b/langfuse/api/resources/score_configs/types/score_configs.py index 6efb652c1..fc84e28a3 100644 --- a/langfuse/api/resources/score_configs/types/score_configs.py +++ b/langfuse/api/resources/score_configs/types/score_configs.py @@ -14,15 +14,28 @@ class ScoreConfigs(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/sessions/client.py b/langfuse/api/resources/sessions/client.py index 5add5230c..98c56e0fc 100644 --- a/langfuse/api/resources/sessions/client.py +++ b/langfuse/api/resources/sessions/client.py @@ -87,8 +87,12 @@ def list( params={ "page": page, "limit": limit, - "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, - "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, + "fromTimestamp": serialize_datetime(from_timestamp) + if from_timestamp is not None + else None, + "toTimestamp": serialize_datetime(to_timestamp) + if to_timestamp is not None + else None, }, request_options=request_options, ) @@ -98,19 +102,32 @@ def list( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def get(self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> SessionWithTraces: + def get( + self, + session_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> SessionWithTraces: """ Get a session. Please note that `traces` on this endpoint are not paginated, if you plan to fetch large sessions, consider `GET /api/public/traces?sessionId=` @@ -143,7 +160,9 @@ def get(self, session_id: str, *, request_options: typing.Optional[RequestOption ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/sessions/{jsonable_encoder(session_id)}", method="GET", request_options=request_options + f"api/public/sessions/{jsonable_encoder(session_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -151,13 +170,21 @@ def get(self, session_id: str, *, request_options: typing.Optional[RequestOption if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -239,8 +266,12 @@ async def main() -> None: params={ "page": page, "limit": limit, - "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, - "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, + "fromTimestamp": serialize_datetime(from_timestamp) + if from_timestamp is not None + else None, + "toTimestamp": serialize_datetime(to_timestamp) + if to_timestamp is not None + else None, }, request_options=request_options, ) @@ -250,20 +281,31 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) async def get( - self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None + self, + session_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, ) -> SessionWithTraces: """ Get a session. Please note that `traces` on this endpoint are not paginated, if you plan to fetch large sessions, consider `GET /api/public/traces?sessionId=` @@ -305,7 +347,9 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/sessions/{jsonable_encoder(session_id)}", method="GET", request_options=request_options + f"api/public/sessions/{jsonable_encoder(session_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -313,13 +357,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/sessions/types/paginated_sessions.py b/langfuse/api/resources/sessions/types/paginated_sessions.py index c220490b9..5dd9fb497 100644 --- a/langfuse/api/resources/sessions/types/paginated_sessions.py +++ b/langfuse/api/resources/sessions/types/paginated_sessions.py @@ -14,15 +14,28 @@ class PaginatedSessions(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/trace/client.py b/langfuse/api/resources/trace/client.py index 8010105a1..0c33e90d5 100644 --- a/langfuse/api/resources/trace/client.py +++ b/langfuse/api/resources/trace/client.py @@ -23,7 +23,9 @@ class TraceClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def get(self, trace_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> TraceWithFullDetails: + def get( + self, trace_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> TraceWithFullDetails: """ Get a specific trace @@ -56,7 +58,9 @@ def get(self, trace_id: str, *, request_options: typing.Optional[RequestOptions] ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/traces/{jsonable_encoder(trace_id)}", method="GET", request_options=request_options + f"api/public/traces/{jsonable_encoder(trace_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -64,13 +68,21 @@ def get(self, trace_id: str, *, request_options: typing.Optional[RequestOptions] if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -175,8 +187,12 @@ def list( "userId": user_id, "name": name, "sessionId": session_id, - "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, - "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, + "fromTimestamp": serialize_datetime(from_timestamp) + if from_timestamp is not None + else None, + "toTimestamp": serialize_datetime(to_timestamp) + if to_timestamp is not None + else None, "orderBy": order_by, "tags": tags, "version": version, @@ -190,13 +206,21 @@ def list( if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -250,7 +274,9 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/traces/{jsonable_encoder(trace_id)}", method="GET", request_options=request_options + f"api/public/traces/{jsonable_encoder(trace_id)}", + method="GET", + request_options=request_options, ) try: if 200 <= _response.status_code < 300: @@ -258,13 +284,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -376,8 +410,12 @@ async def main() -> None: "userId": user_id, "name": name, "sessionId": session_id, - "fromTimestamp": serialize_datetime(from_timestamp) if from_timestamp is not None else None, - "toTimestamp": serialize_datetime(to_timestamp) if to_timestamp is not None else None, + "fromTimestamp": serialize_datetime(from_timestamp) + if from_timestamp is not None + else None, + "toTimestamp": serialize_datetime(to_timestamp) + if to_timestamp is not None + else None, "orderBy": order_by, "tags": tags, "version": version, @@ -391,13 +429,21 @@ async def main() -> None: if _response.status_code == 400: raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore if _response.status_code == 401: - raise UnauthorizedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 403: - raise AccessDeniedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 405: - raise MethodNotAllowedError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/langfuse/api/resources/trace/types/sort.py b/langfuse/api/resources/trace/types/sort.py index b1e6bb79e..76a5045b6 100644 --- a/langfuse/api/resources/trace/types/sort.py +++ b/langfuse/api/resources/trace/types/sort.py @@ -11,15 +11,28 @@ class Sort(pydantic_v1.BaseModel): id: str def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/trace/types/traces.py b/langfuse/api/resources/trace/types/traces.py index e31dcce71..09f58978f 100644 --- a/langfuse/api/resources/trace/types/traces.py +++ b/langfuse/api/resources/trace/types/traces.py @@ -14,15 +14,28 @@ class Traces(pydantic_v1.BaseModel): meta: MetaResponse def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/resources/utils/resources/pagination/types/meta_response.py b/langfuse/api/resources/utils/resources/pagination/types/meta_response.py index 8918812de..2d082c68f 100644 --- a/langfuse/api/resources/utils/resources/pagination/types/meta_response.py +++ b/langfuse/api/resources/utils/resources/pagination/types/meta_response.py @@ -29,15 +29,28 @@ class MetaResponse(pydantic_v1.BaseModel): """ def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), ) class Config: diff --git a/langfuse/api/tests/utils/test_http_client.py b/langfuse/api/tests/utils/test_http_client.py index d1b274bde..b83b23383 100644 --- a/langfuse/api/tests/utils/test_http_client.py +++ b/langfuse/api/tests/utils/test_http_client.py @@ -9,12 +9,17 @@ def get_request_options() -> RequestOptions: def test_get_json_request_body() -> None: - json_body, data_body = get_request_body(json={"hello": "world"}, data=None, request_options=None, omit=None) + json_body, data_body = get_request_body( + json={"hello": "world"}, data=None, request_options=None, omit=None + ) assert json_body == {"hello": "world"} assert data_body is None json_body_extras, data_body_extras = get_request_body( - json={"goodbye": "world"}, data=None, request_options=get_request_options(), omit=None + json={"goodbye": "world"}, + data=None, + request_options=get_request_options(), + omit=None, ) assert json_body_extras == {"goodbye": "world", "see you": "later"} @@ -22,12 +27,17 @@ def test_get_json_request_body() -> None: def test_get_files_request_body() -> None: - json_body, data_body = get_request_body(json=None, data={"hello": "world"}, request_options=None, omit=None) + json_body, data_body = get_request_body( + json=None, data={"hello": "world"}, request_options=None, omit=None + ) assert data_body == {"hello": "world"} assert json_body is None json_body_extras, data_body_extras = get_request_body( - json=None, data={"goodbye": "world"}, request_options=get_request_options(), omit=None + json=None, + data={"goodbye": "world"}, + request_options=get_request_options(), + omit=None, ) assert data_body_extras == {"goodbye": "world", "see you": "later"} @@ -35,7 +45,9 @@ def test_get_files_request_body() -> None: def test_get_none_request_body() -> None: - json_body, data_body = get_request_body(json=None, data=None, request_options=None, omit=None) + json_body, data_body = get_request_body( + json=None, data=None, request_options=None, omit=None + ) assert data_body is None assert json_body is None diff --git a/langfuse/api/tests/utils/test_query_encoding.py b/langfuse/api/tests/utils/test_query_encoding.py index d3e0d828b..482a16727 100644 --- a/langfuse/api/tests/utils/test_query_encoding.py +++ b/langfuse/api/tests/utils/test_query_encoding.py @@ -4,9 +4,15 @@ def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { + assert encode_query({"hello world": "hello world"}) == { + "hello world": "hello world" + } + assert encode_query({"hello_world": {"hello": "world"}}) == { + "hello_world[hello]": "world" + } + assert encode_query( + {"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"} + ) == { "hello_world[hello][world]": "today", "hello_world[test]": "this", "hi": "there", From 1301dcd0629f1c5ec43f3f7417d5be72d4ba210c Mon Sep 17 00:00:00 2001 From: Max Deichmann Date: Mon, 20 Jan 2025 21:33:12 +0100 Subject: [PATCH 05/14] feat: update prompts and invalidate cache --- langfuse/api/resources/__init__.py | 14 +++++++------- langfuse/api/resources/commons/__init__.py | 14 -------------- langfuse/api/resources/commons/types/__init__.py | 12 ------------ langfuse/api/resources/prompt_version/client.py | 2 +- langfuse/api/resources/prompts/__init__.py | 14 ++++++++++++++ langfuse/api/resources/prompts/client.py | 2 +- langfuse/api/resources/prompts/types/__init__.py | 12 ++++++++++++ .../{commons => prompts}/types/base_prompt.py | 0 .../{commons => prompts}/types/chat_message.py | 0 .../{commons => prompts}/types/chat_prompt.py | 0 .../prompts/types/create_chat_prompt_request.py | 2 +- .../prompts/types/create_prompt_request.py | 2 +- .../resources/{commons => prompts}/types/prompt.py | 0 .../{commons => prompts}/types/text_prompt.py | 0 14 files changed, 37 insertions(+), 37 deletions(-) rename langfuse/api/resources/{commons => prompts}/types/base_prompt.py (100%) rename langfuse/api/resources/{commons => prompts}/types/chat_message.py (100%) rename langfuse/api/resources/{commons => prompts}/types/chat_prompt.py (100%) rename langfuse/api/resources/{commons => prompts}/types/prompt.py (100%) rename langfuse/api/resources/{commons => prompts}/types/text_prompt.py (100%) diff --git a/langfuse/api/resources/__init__.py b/langfuse/api/resources/__init__.py index 80ce7dead..6ebdcbe69 100644 --- a/langfuse/api/resources/__init__.py +++ b/langfuse/api/resources/__init__.py @@ -24,12 +24,9 @@ from .comments import CreateCommentRequest, CreateCommentResponse, GetCommentsResponse from .commons import ( AccessDeniedError, - BasePrompt, BaseScore, BooleanScore, CategoricalScore, - ChatMessage, - ChatPrompt, Comment, CommentObjectType, ConfigCategory, @@ -50,9 +47,6 @@ Observation, ObservationLevel, ObservationsView, - Prompt, - Prompt_Chat, - Prompt_Text, Score, ScoreConfig, ScoreDataType, @@ -62,7 +56,6 @@ Score_Numeric, Session, SessionWithTraces, - TextPrompt, Trace, TraceWithDetails, TraceWithFullDetails, @@ -128,13 +121,20 @@ from .observations import Observations, ObservationsViews from .projects import Project, Projects from .prompts import ( + BasePrompt, + ChatMessage, + ChatPrompt, CreateChatPromptRequest, CreatePromptRequest, CreatePromptRequest_Chat, CreatePromptRequest_Text, CreateTextPromptRequest, + Prompt, PromptMeta, PromptMetaListResponse, + Prompt_Chat, + Prompt_Text, + TextPrompt, ) from .score import ( CreateScoreRequest, diff --git a/langfuse/api/resources/commons/__init__.py b/langfuse/api/resources/commons/__init__.py index cfaf5a993..e3e919f41 100644 --- a/langfuse/api/resources/commons/__init__.py +++ b/langfuse/api/resources/commons/__init__.py @@ -1,12 +1,9 @@ # This file was auto-generated by Fern from our API Definition. from .types import ( - BasePrompt, BaseScore, BooleanScore, CategoricalScore, - ChatMessage, - ChatPrompt, Comment, CommentObjectType, ConfigCategory, @@ -24,9 +21,6 @@ Observation, ObservationLevel, ObservationsView, - Prompt, - Prompt_Chat, - Prompt_Text, Score, ScoreConfig, ScoreDataType, @@ -36,7 +30,6 @@ Score_Numeric, Session, SessionWithTraces, - TextPrompt, Trace, TraceWithDetails, TraceWithFullDetails, @@ -52,12 +45,9 @@ __all__ = [ "AccessDeniedError", - "BasePrompt", "BaseScore", "BooleanScore", "CategoricalScore", - "ChatMessage", - "ChatPrompt", "Comment", "CommentObjectType", "ConfigCategory", @@ -78,9 +68,6 @@ "Observation", "ObservationLevel", "ObservationsView", - "Prompt", - "Prompt_Chat", - "Prompt_Text", "Score", "ScoreConfig", "ScoreDataType", @@ -90,7 +77,6 @@ "Score_Numeric", "Session", "SessionWithTraces", - "TextPrompt", "Trace", "TraceWithDetails", "TraceWithFullDetails", diff --git a/langfuse/api/resources/commons/types/__init__.py b/langfuse/api/resources/commons/types/__init__.py index 56c0f5d78..fcec85214 100644 --- a/langfuse/api/resources/commons/types/__init__.py +++ b/langfuse/api/resources/commons/types/__init__.py @@ -1,11 +1,8 @@ # This file was auto-generated by Fern from our API Definition. -from .base_prompt import BasePrompt from .base_score import BaseScore from .boolean_score import BooleanScore from .categorical_score import CategoricalScore -from .chat_message import ChatMessage -from .chat_prompt import ChatPrompt from .comment import Comment from .comment_object_type import CommentObjectType from .config_category import ConfigCategory @@ -23,26 +20,21 @@ from .observation import Observation from .observation_level import ObservationLevel from .observations_view import ObservationsView -from .prompt import Prompt, Prompt_Chat, Prompt_Text from .score import Score, Score_Boolean, Score_Categorical, Score_Numeric from .score_config import ScoreConfig from .score_data_type import ScoreDataType from .score_source import ScoreSource from .session import Session from .session_with_traces import SessionWithTraces -from .text_prompt import TextPrompt from .trace import Trace from .trace_with_details import TraceWithDetails from .trace_with_full_details import TraceWithFullDetails from .usage import Usage __all__ = [ - "BasePrompt", "BaseScore", "BooleanScore", "CategoricalScore", - "ChatMessage", - "ChatPrompt", "Comment", "CommentObjectType", "ConfigCategory", @@ -60,9 +52,6 @@ "Observation", "ObservationLevel", "ObservationsView", - "Prompt", - "Prompt_Chat", - "Prompt_Text", "Score", "ScoreConfig", "ScoreDataType", @@ -72,7 +61,6 @@ "Score_Numeric", "Session", "SessionWithTraces", - "TextPrompt", "Trace", "TraceWithDetails", "TraceWithFullDetails", diff --git a/langfuse/api/resources/prompt_version/client.py b/langfuse/api/resources/prompt_version/client.py index 9b7b9a74f..6542fce48 100644 --- a/langfuse/api/resources/prompt_version/client.py +++ b/langfuse/api/resources/prompt_version/client.py @@ -13,7 +13,7 @@ from ..commons.errors.method_not_allowed_error import MethodNotAllowedError from ..commons.errors.not_found_error import NotFoundError from ..commons.errors.unauthorized_error import UnauthorizedError -from ..commons.types.prompt import Prompt +from ..prompts.types.prompt import Prompt # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) diff --git a/langfuse/api/resources/prompts/__init__.py b/langfuse/api/resources/prompts/__init__.py index 75b546741..73dcf38b0 100644 --- a/langfuse/api/resources/prompts/__init__.py +++ b/langfuse/api/resources/prompts/__init__.py @@ -1,21 +1,35 @@ # This file was auto-generated by Fern from our API Definition. from .types import ( + BasePrompt, + ChatMessage, + ChatPrompt, CreateChatPromptRequest, CreatePromptRequest, CreatePromptRequest_Chat, CreatePromptRequest_Text, CreateTextPromptRequest, + Prompt, PromptMeta, PromptMetaListResponse, + Prompt_Chat, + Prompt_Text, + TextPrompt, ) __all__ = [ + "BasePrompt", + "ChatMessage", + "ChatPrompt", "CreateChatPromptRequest", "CreatePromptRequest", "CreatePromptRequest_Chat", "CreatePromptRequest_Text", "CreateTextPromptRequest", + "Prompt", "PromptMeta", "PromptMetaListResponse", + "Prompt_Chat", + "Prompt_Text", + "TextPrompt", ] diff --git a/langfuse/api/resources/prompts/client.py b/langfuse/api/resources/prompts/client.py index c21052d19..ebaa07909 100644 --- a/langfuse/api/resources/prompts/client.py +++ b/langfuse/api/resources/prompts/client.py @@ -15,8 +15,8 @@ from ..commons.errors.method_not_allowed_error import MethodNotAllowedError from ..commons.errors.not_found_error import NotFoundError from ..commons.errors.unauthorized_error import UnauthorizedError -from ..commons.types.prompt import Prompt from .types.create_prompt_request import CreatePromptRequest +from .types.prompt import Prompt from .types.prompt_meta_list_response import PromptMetaListResponse # this is used as the default value for optional parameters diff --git a/langfuse/api/resources/prompts/types/__init__.py b/langfuse/api/resources/prompts/types/__init__.py index 403efcc68..cb5ba920c 100644 --- a/langfuse/api/resources/prompts/types/__init__.py +++ b/langfuse/api/resources/prompts/types/__init__.py @@ -1,5 +1,8 @@ # This file was auto-generated by Fern from our API Definition. +from .base_prompt import BasePrompt +from .chat_message import ChatMessage +from .chat_prompt import ChatPrompt from .create_chat_prompt_request import CreateChatPromptRequest from .create_prompt_request import ( CreatePromptRequest, @@ -7,15 +10,24 @@ CreatePromptRequest_Text, ) from .create_text_prompt_request import CreateTextPromptRequest +from .prompt import Prompt, Prompt_Chat, Prompt_Text from .prompt_meta import PromptMeta from .prompt_meta_list_response import PromptMetaListResponse +from .text_prompt import TextPrompt __all__ = [ + "BasePrompt", + "ChatMessage", + "ChatPrompt", "CreateChatPromptRequest", "CreatePromptRequest", "CreatePromptRequest_Chat", "CreatePromptRequest_Text", "CreateTextPromptRequest", + "Prompt", "PromptMeta", "PromptMetaListResponse", + "Prompt_Chat", + "Prompt_Text", + "TextPrompt", ] diff --git a/langfuse/api/resources/commons/types/base_prompt.py b/langfuse/api/resources/prompts/types/base_prompt.py similarity index 100% rename from langfuse/api/resources/commons/types/base_prompt.py rename to langfuse/api/resources/prompts/types/base_prompt.py diff --git a/langfuse/api/resources/commons/types/chat_message.py b/langfuse/api/resources/prompts/types/chat_message.py similarity index 100% rename from langfuse/api/resources/commons/types/chat_message.py rename to langfuse/api/resources/prompts/types/chat_message.py diff --git a/langfuse/api/resources/commons/types/chat_prompt.py b/langfuse/api/resources/prompts/types/chat_prompt.py similarity index 100% rename from langfuse/api/resources/commons/types/chat_prompt.py rename to langfuse/api/resources/prompts/types/chat_prompt.py diff --git a/langfuse/api/resources/prompts/types/create_chat_prompt_request.py b/langfuse/api/resources/prompts/types/create_chat_prompt_request.py index f101f8d75..a7c9f113b 100644 --- a/langfuse/api/resources/prompts/types/create_chat_prompt_request.py +++ b/langfuse/api/resources/prompts/types/create_chat_prompt_request.py @@ -5,7 +5,7 @@ from ....core.datetime_utils import serialize_datetime from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from ...commons.types.chat_message import ChatMessage +from .chat_message import ChatMessage class CreateChatPromptRequest(pydantic_v1.BaseModel): diff --git a/langfuse/api/resources/prompts/types/create_prompt_request.py b/langfuse/api/resources/prompts/types/create_prompt_request.py index e18167f0c..9b23bd12d 100644 --- a/langfuse/api/resources/prompts/types/create_prompt_request.py +++ b/langfuse/api/resources/prompts/types/create_prompt_request.py @@ -7,7 +7,7 @@ from ....core.datetime_utils import serialize_datetime from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from ...commons.types.chat_message import ChatMessage +from .chat_message import ChatMessage class CreatePromptRequest_Chat(pydantic_v1.BaseModel): diff --git a/langfuse/api/resources/commons/types/prompt.py b/langfuse/api/resources/prompts/types/prompt.py similarity index 100% rename from langfuse/api/resources/commons/types/prompt.py rename to langfuse/api/resources/prompts/types/prompt.py diff --git a/langfuse/api/resources/commons/types/text_prompt.py b/langfuse/api/resources/prompts/types/text_prompt.py similarity index 100% rename from langfuse/api/resources/commons/types/text_prompt.py rename to langfuse/api/resources/prompts/types/text_prompt.py From 68472802bd428fd6492d2645eae58dd6c98db96c Mon Sep 17 00:00:00 2001 From: Max Deichmann Date: Mon, 20 Jan 2025 21:54:36 +0100 Subject: [PATCH 06/14] push --- langfuse/client.py | 1 + tests/test_updating_prompt.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/langfuse/client.py b/langfuse/client.py index 4430114d2..b096bfdaf 100644 --- a/langfuse/client.py +++ b/langfuse/client.py @@ -1359,6 +1359,7 @@ def create_prompt( def update_prompt( self, + *, prompt_name: str, prompt_version: int, new_labels: List[str] = [], diff --git a/tests/test_updating_prompt.py b/tests/test_updating_prompt.py index 81c60c311..54867e767 100644 --- a/tests/test_updating_prompt.py +++ b/tests/test_updating_prompt.py @@ -15,7 +15,9 @@ def test_update_prompt(): # Update prompt labels updated_prompt = langfuse.update_prompt( - prompt_name=prompt_name, prompt_version=1, new_labels=["john", "doe"] + prompt_name=prompt_name, + prompt_version=1, + new_labels=["john", "doe"], ) # Fetch prompt after update (should be invalidated) @@ -24,5 +26,10 @@ def test_update_prompt(): # Verify the fetched prompt matches the updated values assert fetched_prompt.name == prompt_name assert fetched_prompt.version == 1 - assert fetched_prompt.labels == ["john", "doe"] - assert updated_prompt.labels == ["john", "doe"] + print(f"Fetched prompt labels: {fetched_prompt.labels}") + print(f"Updated prompt labels: {updated_prompt.labels}") + + # production was set by the first call, latest is managed and set by Langfuse + expected_labels = sorted(["latest", "doe", "production", "john"]) + assert sorted(fetched_prompt.labels) == expected_labels + assert sorted(updated_prompt.labels) == expected_labels From 66e8dc65d45712b690eebdb3261591bd59ea2d06 Mon Sep 17 00:00:00 2001 From: Hassieb Pakzad <68423100+hassiebp@users.noreply.github.com> Date: Tue, 21 Jan 2025 09:40:59 +0100 Subject: [PATCH 07/14] revert fern test client import path --- langfuse/api/tests/utils/test_http_client.py | 4 ++-- langfuse/api/tests/utils/test_query_encoding.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/langfuse/api/tests/utils/test_http_client.py b/langfuse/api/tests/utils/test_http_client.py index b83b23383..950fcdeb1 100644 --- a/langfuse/api/tests/utils/test_http_client.py +++ b/langfuse/api/tests/utils/test_http_client.py @@ -1,7 +1,7 @@ # This file was auto-generated by Fern from our API Definition. -from langfuse.core.http_client import get_request_body -from langfuse.core.request_options import RequestOptions +from langfuse.api.core.http_client import get_request_body +from langfuse.api.core.request_options import RequestOptions def get_request_options() -> RequestOptions: diff --git a/langfuse/api/tests/utils/test_query_encoding.py b/langfuse/api/tests/utils/test_query_encoding.py index 482a16727..9afa0ea78 100644 --- a/langfuse/api/tests/utils/test_query_encoding.py +++ b/langfuse/api/tests/utils/test_query_encoding.py @@ -1,6 +1,6 @@ # This file was auto-generated by Fern from our API Definition. -from langfuse.core.query_encoder import encode_query +from langfuse.api.core.query_encoder import encode_query def test_query_encoding() -> None: From 28a98836949f7c120344bfe36ab6911915551c62 Mon Sep 17 00:00:00 2001 From: Max Deichmann Date: Mon, 27 Jan 2025 16:22:10 +0100 Subject: [PATCH 08/14] push --- langfuse/client.py | 14 +++++++------- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/langfuse/client.py b/langfuse/client.py index b096bfdaf..e9a4a5a59 100644 --- a/langfuse/client.py +++ b/langfuse/client.py @@ -1360,15 +1360,15 @@ def create_prompt( def update_prompt( self, *, - prompt_name: str, - prompt_version: int, + name: str, + version: int, new_labels: List[str] = [], ): """Update an existing prompt version in Langfuse. The Langfuse SDK prompt cache is invalidated for all prompts witht he specified name. Args: - prompt_id (str): The name/id of the prompt to update. - prompt_version (int): The version number of the prompt to update. + name (str): The name of the prompt to update. + version (int): The version number of the prompt to update. new_labels (List[str], optional): New labels to assign to the prompt version. Labels are unique across versions. The "latest" label is reserved and managed by Langfuse. Defaults to []. Returns: @@ -1376,11 +1376,11 @@ def update_prompt( """ updated_prompt = self.client.prompt_version.update( - prompt_name=prompt_name, - version=prompt_version, + name=name, + version=version, new_labels=new_labels, ) - self.prompt_cache.invalidate(prompt_name) + self.prompt_cache.invalidate(name) return updated_prompt def _url_encode(self, url: str) -> str: diff --git a/pyproject.toml b/pyproject.toml index 6c2c7416f..a2dc0da34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langfuse" -version = "2.57.12" +version = "2.57.13a0" description = "A client library for accessing langfuse" authors = ["langfuse "] license = "MIT" From 09fdedb0d50e8dfbcea58751b6140d917fdc09d5 Mon Sep 17 00:00:00 2001 From: Max Deichmann Date: Mon, 27 Jan 2025 16:22:28 +0100 Subject: [PATCH 09/14] push --- langfuse/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langfuse/version.py b/langfuse/version.py index ffdd4fd85..d42e9812e 100644 --- a/langfuse/version.py +++ b/langfuse/version.py @@ -1,3 +1,3 @@ """@private""" -__version__ = "2.57.12" +__version__ = "2.57.13a0" From 80ca5e8321ef221d2d1f264194589622a5f90b5a Mon Sep 17 00:00:00 2001 From: Max Deichmann Date: Mon, 27 Jan 2025 16:23:18 +0100 Subject: [PATCH 10/14] fix --- tests/test_updating_prompt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_updating_prompt.py b/tests/test_updating_prompt.py index 54867e767..addcd4528 100644 --- a/tests/test_updating_prompt.py +++ b/tests/test_updating_prompt.py @@ -15,8 +15,8 @@ def test_update_prompt(): # Update prompt labels updated_prompt = langfuse.update_prompt( - prompt_name=prompt_name, - prompt_version=1, + name=prompt_name, + version=1, new_labels=["john", "doe"], ) From 74bb976d260dbb4f03c188620a6a81b239229a17 Mon Sep 17 00:00:00 2001 From: Max Deichmann Date: Mon, 27 Jan 2025 17:15:25 +0100 Subject: [PATCH 11/14] push --- langfuse/api/reference.md | 4 ++-- langfuse/api/resources/prompt_version/client.py | 16 ++++++++-------- langfuse/api/tests/utils/test_http_client.py | 4 ++-- langfuse/api/tests/utils/test_query_encoding.py | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/langfuse/api/reference.md b/langfuse/api/reference.md index 2694bac8c..2fc0a48fd 100644 --- a/langfuse/api/reference.md +++ b/langfuse/api/reference.md @@ -2280,7 +2280,7 @@ client = FernLangfuse( base_url="https://yourhost.com/path/to/api", ) client.prompt_version.update( - prompt_name="string", + name="string", version=1, new_labels=["string"], ) @@ -2299,7 +2299,7 @@ client.prompt_version.update(
-**prompt_name:** `str` — The name of the prompt +**name:** `str` — The name of the prompt
diff --git a/langfuse/api/resources/prompt_version/client.py b/langfuse/api/resources/prompt_version/client.py index 6542fce48..408afe381 100644 --- a/langfuse/api/resources/prompt_version/client.py +++ b/langfuse/api/resources/prompt_version/client.py @@ -25,7 +25,7 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): def update( self, - prompt_name: str, + name: str, version: int, *, new_labels: typing.Sequence[str], @@ -36,7 +36,7 @@ def update( Parameters ---------- - prompt_name : str + name : str The name of the prompt version : int @@ -65,13 +65,13 @@ def update( base_url="https://yourhost.com/path/to/api", ) client.prompt_version.update( - prompt_name="string", + name="string", version=1, new_labels=["string"], ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/v2/prompts/{jsonable_encoder(prompt_name)}/version/{jsonable_encoder(version)}", + f"api/public/v2/prompts/{jsonable_encoder(name)}/version/{jsonable_encoder(version)}", method="PATCH", json={"newLabels": new_labels}, request_options=request_options, @@ -110,7 +110,7 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): async def update( self, - prompt_name: str, + name: str, version: int, *, new_labels: typing.Sequence[str], @@ -121,7 +121,7 @@ async def update( Parameters ---------- - prompt_name : str + name : str The name of the prompt version : int @@ -155,7 +155,7 @@ async def update( async def main() -> None: await client.prompt_version.update( - prompt_name="string", + name="string", version=1, new_labels=["string"], ) @@ -164,7 +164,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/v2/prompts/{jsonable_encoder(prompt_name)}/version/{jsonable_encoder(version)}", + f"api/public/v2/prompts/{jsonable_encoder(name)}/version/{jsonable_encoder(version)}", method="PATCH", json={"newLabels": new_labels}, request_options=request_options, diff --git a/langfuse/api/tests/utils/test_http_client.py b/langfuse/api/tests/utils/test_http_client.py index 950fcdeb1..b83b23383 100644 --- a/langfuse/api/tests/utils/test_http_client.py +++ b/langfuse/api/tests/utils/test_http_client.py @@ -1,7 +1,7 @@ # This file was auto-generated by Fern from our API Definition. -from langfuse.api.core.http_client import get_request_body -from langfuse.api.core.request_options import RequestOptions +from langfuse.core.http_client import get_request_body +from langfuse.core.request_options import RequestOptions def get_request_options() -> RequestOptions: diff --git a/langfuse/api/tests/utils/test_query_encoding.py b/langfuse/api/tests/utils/test_query_encoding.py index 9afa0ea78..482a16727 100644 --- a/langfuse/api/tests/utils/test_query_encoding.py +++ b/langfuse/api/tests/utils/test_query_encoding.py @@ -1,6 +1,6 @@ # This file was auto-generated by Fern from our API Definition. -from langfuse.api.core.query_encoder import encode_query +from langfuse.core.query_encoder import encode_query def test_query_encoding() -> None: From 682e25dfb654f7ffdb98b72b0fdcc6addce9ba0c Mon Sep 17 00:00:00 2001 From: Max Deichmann Date: Mon, 27 Jan 2025 20:40:48 +0100 Subject: [PATCH 12/14] fix --- langfuse/api/tests/utils/test_http_client.py | 4 ++-- langfuse/api/tests/utils/test_query_encoding.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/langfuse/api/tests/utils/test_http_client.py b/langfuse/api/tests/utils/test_http_client.py index b83b23383..950fcdeb1 100644 --- a/langfuse/api/tests/utils/test_http_client.py +++ b/langfuse/api/tests/utils/test_http_client.py @@ -1,7 +1,7 @@ # This file was auto-generated by Fern from our API Definition. -from langfuse.core.http_client import get_request_body -from langfuse.core.request_options import RequestOptions +from langfuse.api.core.http_client import get_request_body +from langfuse.api.core.request_options import RequestOptions def get_request_options() -> RequestOptions: diff --git a/langfuse/api/tests/utils/test_query_encoding.py b/langfuse/api/tests/utils/test_query_encoding.py index 482a16727..9afa0ea78 100644 --- a/langfuse/api/tests/utils/test_query_encoding.py +++ b/langfuse/api/tests/utils/test_query_encoding.py @@ -1,6 +1,6 @@ # This file was auto-generated by Fern from our API Definition. -from langfuse.core.query_encoder import encode_query +from langfuse.api.core.query_encoder import encode_query def test_query_encoding() -> None: From 71c83cd82ac715bd160725694ac067a18c774286 Mon Sep 17 00:00:00 2001 From: Max Deichmann Date: Mon, 27 Jan 2025 23:08:49 +0100 Subject: [PATCH 13/14] push --- tests/test_core_sdk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_core_sdk.py b/tests/test_core_sdk.py index e8ac49f9a..5c65c0e27 100644 --- a/tests/test_core_sdk.py +++ b/tests/test_core_sdk.py @@ -1297,7 +1297,7 @@ def test_fetch_traces(): fetched_trace = response.data[0] assert fetched_trace.name == name assert fetched_trace.session_id == "session-1" - assert fetched_trace.input == '{"key":"value"}' + assert fetched_trace.input == {"key": "value"} assert fetched_trace.output == "output-value" # compare timestamps without microseconds and in UTC assert fetched_trace.timestamp.replace(microsecond=0) == trace_params[1][ From bb9528ebb99d1ff315e7c4bf7bae473ceae7f10b Mon Sep 17 00:00:00 2001 From: Max Deichmann Date: Mon, 27 Jan 2025 23:34:39 +0100 Subject: [PATCH 14/14] push --- langfuse/api/reference.md | 6 ++---- .../api/resources/prompt_version/client.py | 4 ++-- langfuse/api/resources/score/client.py | 20 ++++++++----------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/langfuse/api/reference.md b/langfuse/api/reference.md index 2fc0a48fd..41d43849a 100644 --- a/langfuse/api/reference.md +++ b/langfuse/api/reference.md @@ -3038,7 +3038,7 @@ client.score.get( config_id="string", queue_id="string", data_type=ScoreDataType.NUMERIC, - trace_tags=["string"], + trace_tags="string", ) ``` @@ -3159,9 +3159,7 @@ client.score.get(
-**trace_tags:** `typing.Optional[ - typing.Union[typing.Sequence[str], typing.Sequence[typing.Sequence[str]]] -]` — Only scores linked to traces that include all of these tags will be returned. +**trace_tags:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` — Only scores linked to traces that include all of these tags will be returned.
diff --git a/langfuse/api/resources/prompt_version/client.py b/langfuse/api/resources/prompt_version/client.py index 408afe381..638871082 100644 --- a/langfuse/api/resources/prompt_version/client.py +++ b/langfuse/api/resources/prompt_version/client.py @@ -71,7 +71,7 @@ def update( ) """ _response = self._client_wrapper.httpx_client.request( - f"api/public/v2/prompts/{jsonable_encoder(name)}/version/{jsonable_encoder(version)}", + f"api/public/v2/prompts/{jsonable_encoder(name)}/versions/{jsonable_encoder(version)}", method="PATCH", json={"newLabels": new_labels}, request_options=request_options, @@ -164,7 +164,7 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"api/public/v2/prompts/{jsonable_encoder(name)}/version/{jsonable_encoder(version)}", + f"api/public/v2/prompts/{jsonable_encoder(name)}/versions/{jsonable_encoder(version)}", method="PATCH", json={"newLabels": new_labels}, request_options=request_options, diff --git a/langfuse/api/resources/score/client.py b/langfuse/api/resources/score/client.py index 2c911449d..9c40a48f7 100644 --- a/langfuse/api/resources/score/client.py +++ b/langfuse/api/resources/score/client.py @@ -120,9 +120,7 @@ def get( config_id: typing.Optional[str] = None, queue_id: typing.Optional[str] = None, data_type: typing.Optional[ScoreDataType] = None, - trace_tags: typing.Optional[ - typing.Union[typing.Sequence[str], typing.Sequence[typing.Sequence[str]]] - ] = None, + trace_tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, request_options: typing.Optional[RequestOptions] = None, ) -> GetScoresResponse: """ @@ -169,7 +167,7 @@ def get( data_type : typing.Optional[ScoreDataType] Retrieve only scores with a specific dataType. - trace_tags : typing.Optional[typing.Union[typing.Sequence[str], typing.Sequence[typing.Sequence[str]]]] + trace_tags : typing.Optional[typing.Union[str, typing.Sequence[str]]] Only scores linked to traces that include all of these tags will be returned. request_options : typing.Optional[RequestOptions] @@ -212,7 +210,7 @@ def get( config_id="string", queue_id="string", data_type=ScoreDataType.NUMERIC, - trace_tags=["string"], + trace_tags="string", ) """ _response = self._client_wrapper.httpx_client.request( @@ -236,7 +234,7 @@ def get( "configId": config_id, "queueId": queue_id, "dataType": data_type, - "traceTags": jsonable_encoder(trace_tags), + "traceTags": trace_tags, }, request_options=request_options, ) @@ -499,9 +497,7 @@ async def get( config_id: typing.Optional[str] = None, queue_id: typing.Optional[str] = None, data_type: typing.Optional[ScoreDataType] = None, - trace_tags: typing.Optional[ - typing.Union[typing.Sequence[str], typing.Sequence[typing.Sequence[str]]] - ] = None, + trace_tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, request_options: typing.Optional[RequestOptions] = None, ) -> GetScoresResponse: """ @@ -548,7 +544,7 @@ async def get( data_type : typing.Optional[ScoreDataType] Retrieve only scores with a specific dataType. - trace_tags : typing.Optional[typing.Union[typing.Sequence[str], typing.Sequence[typing.Sequence[str]]]] + trace_tags : typing.Optional[typing.Union[str, typing.Sequence[str]]] Only scores linked to traces that include all of these tags will be returned. request_options : typing.Optional[RequestOptions] @@ -595,7 +591,7 @@ async def main() -> None: config_id="string", queue_id="string", data_type=ScoreDataType.NUMERIC, - trace_tags=["string"], + trace_tags="string", ) @@ -622,7 +618,7 @@ async def main() -> None: "configId": config_id, "queueId": queue_id, "dataType": data_type, - "traceTags": jsonable_encoder(trace_tags), + "traceTags": trace_tags, }, request_options=request_options, )