diff --git a/.mock/definition/__package__.yml b/.mock/definition/__package__.yml index ecdaa9a6..05f08477 100644 --- a/.mock/definition/__package__.yml +++ b/.mock/definition/__package__.yml @@ -2358,6 +2358,15 @@ types: total_cost_usd: type: optional docs: Total cost of the inference (in USD) + error: + type: optional + docs: Whether an error occurred or not + error_type: + type: optional + docs: Type of error (e.g. "Timeout", "Rate Limit", etc) + error_message: + type: optional + docs: Error message details source: openapi: openapi/openapi.yaml RefinedPromptResponseRefinementStatus: diff --git a/.mock/definition/prompts/versions.yml b/.mock/definition/prompts/versions.yml index 241777d8..ccf3f6ea 100644 --- a/.mock/definition/prompts/versions.yml +++ b/.mock/definition/prompts/versions.yml @@ -205,6 +205,9 @@ service: prompt_cost_usd: prompt_cost_usd completion_cost_usd: completion_cost_usd total_cost_usd: total_cost_usd + error: true + error_type: error_type + error_message: error_message audiences: - public get_refined_prompt: diff --git a/poetry.lock b/poetry.lock index 8a690afc..15b2184a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -16,13 +16,13 @@ typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} [[package]] name = "anyio" -version = "4.5.0" +version = "4.5.2" description = "High level compatibility layer for multiple asynchronous event loop implementations" optional = false python-versions = ">=3.8" files = [ - {file = "anyio-4.5.0-py3-none-any.whl", hash = "sha256:fdeb095b7cc5a5563175eedd926ec4ae55413bb4be5770c424af0ba46ccb4a78"}, - {file = "anyio-4.5.0.tar.gz", hash = "sha256:c5a275fe5ca0afd788001f58fca1e69e29ce706d746e317d660e21f70c530ef9"}, + {file = "anyio-4.5.2-py3-none-any.whl", hash = "sha256:c011ee36bc1e8ba40e5a81cb9df91925c218fe9b778554e0b56a21e1b5d4716f"}, + {file = "anyio-4.5.2.tar.gz", hash = "sha256:23009af4ed04ce05991845451e11ef02fc7c5ed29179ac9a420e5ad0ac7ddc5b"}, ] [package.dependencies] @@ -33,7 +33,7 @@ typing-extensions = {version = ">=4.1", markers = "python_version < \"3.11\""} [package.extras] doc = ["Sphinx (>=7.4,<8.0)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] -test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.21.0b1)"] +test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "truststore (>=0.9.1)", "uvloop (>=0.21.0b1)"] trio = ["trio (>=0.26.1)"] [[package]] diff --git a/src/label_studio_sdk/types/inference_run_cost_estimate.py b/src/label_studio_sdk/types/inference_run_cost_estimate.py index 550ccc8a..6c7b2bc4 100644 --- a/src/label_studio_sdk/types/inference_run_cost_estimate.py +++ b/src/label_studio_sdk/types/inference_run_cost_estimate.py @@ -23,6 +23,21 @@ class InferenceRunCostEstimate(pydantic_v1.BaseModel): Total cost of the inference (in USD) """ + error: typing.Optional[bool] = pydantic_v1.Field(default=None) + """ + Whether an error occurred or not + """ + + error_type: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Type of error (e.g. "Timeout", "Rate Limit", etc) + """ + + error_message: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + Error message details + """ + def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) diff --git a/tests/prompts/test_versions.py b/tests/prompts/test_versions.py index d150204d..c58d53af 100644 --- a/tests/prompts/test_versions.py +++ b/tests/prompts/test_versions.py @@ -154,8 +154,18 @@ async def test_cost_estimate(client: LabelStudio, async_client: AsyncLabelStudio "prompt_cost_usd": "prompt_cost_usd", "completion_cost_usd": "completion_cost_usd", "total_cost_usd": "total_cost_usd", + "error": True, + "error_type": "error_type", + "error_message": "error_message", + } + expected_types: typing.Any = { + "prompt_cost_usd": None, + "completion_cost_usd": None, + "total_cost_usd": None, + "error": None, + "error_type": None, + "error_message": None, } - expected_types: typing.Any = {"prompt_cost_usd": None, "completion_cost_usd": None, "total_cost_usd": None} response = client.prompts.versions.cost_estimate(prompt_id=1, version_id=1, project_id=1, project_subset=1) validate_response(response, expected_response, expected_types)