From 52a5c7f6a5ad14111f0885418fc5e31d350a98da Mon Sep 17 00:00:00 2001 From: Michael Bishoff Date: Wed, 4 Jun 2025 18:06:07 -0700 Subject: [PATCH 1/2] Update SDK with new Annotation Types --- .gitignore | 2 + .openapi-generator/FILES | 26 +++- .pre-commit-config.yaml | 8 +- docs/developer_guide.md | 2 +- scaleapi/api_client/v2/__init__.py | 106 +++++++++++-- scaleapi/api_client/v2/models/__init__.py | 106 +++++++++++-- scaleapi/api_client/v2/models/annotation.py | 147 ++++++++++++++++-- .../v2/models/annotation_boolean.py | 113 ++++++++++++++ .../models/annotation_boolean_properties.py | 88 +++++++++++ .../api_client/v2/models/annotation_file.py | 115 ++++++++++++++ .../v2/models/annotation_file_properties.py | 90 +++++++++++ .../annotation_file_properties_value.py | 139 +++++++++++++++++ .../v2/models/annotation_ranked_choices.py | 111 +++++++++++++ .../annotation_ranked_choices_properties.py | 86 ++++++++++ .../v2/models/annotation_ranked_groups.py | 111 +++++++++++++ .../annotation_ranked_groups_properties.py | 86 ++++++++++ .../api_client/v2/models/annotation_type.py | 23 +-- .../models/annotation_workspace_container.py | 115 ++++++++++++++ ...notation_workspace_container_properties.py | 90 +++++++++++ scaleapi/api_client/v2/models/audio_file.py | 4 +- scaleapi/api_client/v2/models/base_chunk.py | 96 ++++++++++++ scaleapi/api_client/v2/models/basic_file.py | 94 +++++++++++ scaleapi/api_client/v2/models/batch.py | 2 +- scaleapi/api_client/v2/models/chunk.py | 124 +++++++++++++++ scaleapi/api_client/v2/models/chunk_text.py | 98 ++++++++++++ .../v2/models/chunk_text_properties.py | 86 ++++++++++ .../api_client/v2/models/content_and_url.py | 90 +++++++++++ .../api_client/v2/models/detailed_file.py | 32 ++-- scaleapi/api_client/v2/models/error_detail.py | 2 +- scaleapi/api_client/v2/models/error_type.py | 1 + .../api_client/v2/models/message_content.py | 24 ++- .../api_client/v2/models/model_parameters.py | 8 +- scaleapi/api_client/v2/models/project.py | 2 +- scaleapi/api_client/v2/models/reasoning.py | 86 ++++++++++ .../v2/models/sensitive_content_report.py | 88 +++++++++++ scaleapi/api_client/v2/models/task.py | 16 +- scaleapi/api_client/v2/models/thread.py | 2 +- .../v2/models/workspace_container_config.py | 98 ++++++++++++ .../v2/models/workspace_container_value.py | 128 +++++++++++++++ .../v2/models/workspace_execution_data.py | 92 +++++++++++ .../models/workspace_execution_data_result.py | 94 +++++++++++ .../workspace_execution_data_result_status.py | 88 +++++++++++ .../api_client/v2/models/workspace_file.py | 94 +++++++++++ 43 files changed, 2925 insertions(+), 88 deletions(-) create mode 100644 scaleapi/api_client/v2/models/annotation_boolean.py create mode 100644 scaleapi/api_client/v2/models/annotation_boolean_properties.py create mode 100644 scaleapi/api_client/v2/models/annotation_file.py create mode 100644 scaleapi/api_client/v2/models/annotation_file_properties.py create mode 100644 scaleapi/api_client/v2/models/annotation_file_properties_value.py create mode 100644 scaleapi/api_client/v2/models/annotation_ranked_choices.py create mode 100644 scaleapi/api_client/v2/models/annotation_ranked_choices_properties.py create mode 100644 scaleapi/api_client/v2/models/annotation_ranked_groups.py create mode 100644 scaleapi/api_client/v2/models/annotation_ranked_groups_properties.py create mode 100644 scaleapi/api_client/v2/models/annotation_workspace_container.py create mode 100644 scaleapi/api_client/v2/models/annotation_workspace_container_properties.py create mode 100644 scaleapi/api_client/v2/models/base_chunk.py create mode 100644 scaleapi/api_client/v2/models/basic_file.py create mode 100644 scaleapi/api_client/v2/models/chunk.py create mode 100644 scaleapi/api_client/v2/models/chunk_text.py create mode 100644 scaleapi/api_client/v2/models/chunk_text_properties.py create mode 100644 scaleapi/api_client/v2/models/content_and_url.py create mode 100644 scaleapi/api_client/v2/models/reasoning.py create mode 100644 scaleapi/api_client/v2/models/sensitive_content_report.py create mode 100644 scaleapi/api_client/v2/models/workspace_container_config.py create mode 100644 scaleapi/api_client/v2/models/workspace_container_value.py create mode 100644 scaleapi/api_client/v2/models/workspace_execution_data.py create mode 100644 scaleapi/api_client/v2/models/workspace_execution_data_result.py create mode 100644 scaleapi/api_client/v2/models/workspace_execution_data_result_status.py create mode 100644 scaleapi/api_client/v2/models/workspace_file.py diff --git a/.gitignore b/.gitignore index 4145e91..2658638 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ coverage.xml *.cover .idea + +venv diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 3952232..1c97c22 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -7,19 +7,36 @@ scaleapi/api_client/v2/api_response.py scaleapi/api_client/v2/configuration.py scaleapi/api_client/v2/exceptions.py scaleapi/api_client/v2/models/__init__.py +scaleapi/api_client/v2/models/annotation_boolean.py +scaleapi/api_client/v2/models/annotation_boolean_properties.py scaleapi/api_client/v2/models/annotation_category.py scaleapi/api_client/v2/models/annotation_category_multiple.py scaleapi/api_client/v2/models/annotation_category_multiple_properties.py scaleapi/api_client/v2/models/annotation_category_properties.py +scaleapi/api_client/v2/models/annotation_file.py +scaleapi/api_client/v2/models/annotation_file_properties.py +scaleapi/api_client/v2/models/annotation_file_properties_value.py scaleapi/api_client/v2/models/annotation_integer.py scaleapi/api_client/v2/models/annotation_integer_properties.py scaleapi/api_client/v2/models/annotation_metadata.py +scaleapi/api_client/v2/models/annotation_ranked_choices.py +scaleapi/api_client/v2/models/annotation_ranked_choices_properties.py +scaleapi/api_client/v2/models/annotation_ranked_groups.py +scaleapi/api_client/v2/models/annotation_ranked_groups_properties.py scaleapi/api_client/v2/models/annotation_text.py scaleapi/api_client/v2/models/annotation_text_properties.py scaleapi/api_client/v2/models/annotation_type.py +scaleapi/api_client/v2/models/annotation_workspace_container.py +scaleapi/api_client/v2/models/annotation_workspace_container_properties.py scaleapi/api_client/v2/models/audio_file.py scaleapi/api_client/v2/models/base_annotation.py +scaleapi/api_client/v2/models/base_chunk.py +scaleapi/api_client/v2/models/basic_file.py scaleapi/api_client/v2/models/batch.py +scaleapi/api_client/v2/models/chunk.py +scaleapi/api_client/v2/models/chunk_text.py +scaleapi/api_client/v2/models/chunk_text_properties.py +scaleapi/api_client/v2/models/content_and_url.py scaleapi/api_client/v2/models/delivery.py scaleapi/api_client/v2/models/detailed_file.py scaleapi/api_client/v2/models/error_detail.py @@ -32,7 +49,6 @@ scaleapi/api_client/v2/models/expandable_enum_deliveries.py scaleapi/api_client/v2/models/expandable_enum_delivery.py scaleapi/api_client/v2/models/expandable_enum_task.py scaleapi/api_client/v2/models/expandable_project.py -scaleapi/api_client/v2/models/file.py scaleapi/api_client/v2/models/get_delivered_tasks_response.py scaleapi/api_client/v2/models/get_deliveries_response.py scaleapi/api_client/v2/models/get_task500_response.py @@ -44,7 +60,9 @@ scaleapi/api_client/v2/models/message_role.py scaleapi/api_client/v2/models/model_parameters.py scaleapi/api_client/v2/models/option.py scaleapi/api_client/v2/models/project.py +scaleapi/api_client/v2/models/reasoning.py scaleapi/api_client/v2/models/reference_text.py +scaleapi/api_client/v2/models/sensitive_content_report.py scaleapi/api_client/v2/models/submission.py scaleapi/api_client/v2/models/task.py scaleapi/api_client/v2/models/task_status.py @@ -52,4 +70,10 @@ scaleapi/api_client/v2/models/thread.py scaleapi/api_client/v2/models/turn.py scaleapi/api_client/v2/models/v1_task_task_id_get200_response.py scaleapi/api_client/v2/models/v1_task_task_id_get200_response_response.py +scaleapi/api_client/v2/models/workspace_container_config.py +scaleapi/api_client/v2/models/workspace_container_value.py +scaleapi/api_client/v2/models/workspace_execution_data.py +scaleapi/api_client/v2/models/workspace_execution_data_result.py +scaleapi/api_client/v2/models/workspace_execution_data_result_status.py +scaleapi/api_client/v2/models/workspace_file.py scaleapi/api_client/v2/rest.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 05b4e14..511bd00 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ default_language_version: - python: python3.8 + python: python3.9 default_stages: [commit] repos: @@ -12,19 +12,19 @@ repos: - id: check-yaml - id: check-case-conflict - repo: https://github.com/pycqa/isort - rev: 5.8.0 + rev: 5.13.2 hooks: - id: isort name: isort args: ["--profile", "black"] exclude: ^scaleapi/api_client/ - repo: https://github.com/psf/black - rev: 20.8b1 + rev: 25.1.0 hooks: - id: black exclude: ^scaleapi/api_client/ - repo: https://github.com/PyCQA/flake8 - rev: 3.8.4 + rev: 7.2.0 hooks: - id: flake8 exclude: ^scaleapi/api_client/ diff --git a/docs/developer_guide.md b/docs/developer_guide.md index 1e1dab8..87b073b 100644 --- a/docs/developer_guide.md +++ b/docs/developer_guide.md @@ -98,7 +98,7 @@ tests/test_client.py::test_transcription_ok PASSED [ ......... ``` -#### 7. Updating auto-generated v2 client +### 7. Updating auto-generated v2 client The V2 API client is auto-generated from openapi.yaml using the v2_generator.json config. Run this to update the client: diff --git a/scaleapi/api_client/v2/__init__.py b/scaleapi/api_client/v2/__init__.py index a602032..7e51674 100644 --- a/scaleapi/api_client/v2/__init__.py +++ b/scaleapi/api_client/v2/__init__.py @@ -3,14 +3,14 @@ # flake8: noqa """ - GenAI API Spec +GenAI API Spec - Data Engine: Generative AI API Specification +Data Engine: Generative AI API Specification - The version of the OpenAPI document: 0.0.1 - Generated by OpenAPI Generator (https://openapi-generator.tech) +The version of the OpenAPI document: 0.0.1 +Generated by OpenAPI Generator (https://openapi-generator.tech) - Do not edit the class manually. +Do not edit the class manually. """ # noqa: E501 @@ -32,19 +32,64 @@ # import models into sdk package from scaleapi.api_client.v2.models.annotation import Annotation +from scaleapi.api_client.v2.models.annotation_boolean import AnnotationBoolean +from scaleapi.api_client.v2.models.annotation_boolean_properties import ( + AnnotationBooleanProperties, +) from scaleapi.api_client.v2.models.annotation_category import AnnotationCategory -from scaleapi.api_client.v2.models.annotation_category_multiple import AnnotationCategoryMultiple -from scaleapi.api_client.v2.models.annotation_category_multiple_properties import AnnotationCategoryMultipleProperties -from scaleapi.api_client.v2.models.annotation_category_properties import AnnotationCategoryProperties +from scaleapi.api_client.v2.models.annotation_category_multiple import ( + AnnotationCategoryMultiple, +) +from scaleapi.api_client.v2.models.annotation_category_multiple_properties import ( + AnnotationCategoryMultipleProperties, +) +from scaleapi.api_client.v2.models.annotation_category_properties import ( + AnnotationCategoryProperties, +) +from scaleapi.api_client.v2.models.annotation_file import AnnotationFile +from scaleapi.api_client.v2.models.annotation_file_properties import ( + AnnotationFileProperties, +) +from scaleapi.api_client.v2.models.annotation_file_properties_value import ( + AnnotationFilePropertiesValue, +) from scaleapi.api_client.v2.models.annotation_integer import AnnotationInteger -from scaleapi.api_client.v2.models.annotation_integer_properties import AnnotationIntegerProperties +from scaleapi.api_client.v2.models.annotation_integer_properties import ( + AnnotationIntegerProperties, +) from scaleapi.api_client.v2.models.annotation_metadata import AnnotationMetadata +from scaleapi.api_client.v2.models.annotation_ranked_choices import ( + AnnotationRankedChoices, +) +from scaleapi.api_client.v2.models.annotation_ranked_choices_properties import ( + AnnotationRankedChoicesProperties, +) +from scaleapi.api_client.v2.models.annotation_ranked_groups import ( + AnnotationRankedGroups, +) +from scaleapi.api_client.v2.models.annotation_ranked_groups_properties import ( + AnnotationRankedGroupsProperties, +) from scaleapi.api_client.v2.models.annotation_text import AnnotationText -from scaleapi.api_client.v2.models.annotation_text_properties import AnnotationTextProperties +from scaleapi.api_client.v2.models.annotation_text_properties import ( + AnnotationTextProperties, +) from scaleapi.api_client.v2.models.annotation_type import AnnotationType +from scaleapi.api_client.v2.models.annotation_workspace_container import ( + AnnotationWorkspaceContainer, +) +from scaleapi.api_client.v2.models.annotation_workspace_container_properties import ( + AnnotationWorkspaceContainerProperties, +) from scaleapi.api_client.v2.models.audio_file import AudioFile from scaleapi.api_client.v2.models.base_annotation import BaseAnnotation +from scaleapi.api_client.v2.models.base_chunk import BaseChunk +from scaleapi.api_client.v2.models.basic_file import BasicFile from scaleapi.api_client.v2.models.batch import Batch +from scaleapi.api_client.v2.models.chunk import Chunk +from scaleapi.api_client.v2.models.chunk_text import ChunkText +from scaleapi.api_client.v2.models.chunk_text_properties import ChunkTextProperties +from scaleapi.api_client.v2.models.content_and_url import ContentAndUrl from scaleapi.api_client.v2.models.delivery import Delivery from scaleapi.api_client.v2.models.detailed_file import DetailedFile from scaleapi.api_client.v2.models.error_detail import ErrorDetail @@ -53,12 +98,17 @@ from scaleapi.api_client.v2.models.expandable_annotation import ExpandableAnnotation from scaleapi.api_client.v2.models.expandable_batch import ExpandableBatch from scaleapi.api_client.v2.models.expandable_delivery import ExpandableDelivery -from scaleapi.api_client.v2.models.expandable_enum_deliveries import ExpandableEnumDeliveries -from scaleapi.api_client.v2.models.expandable_enum_delivery import ExpandableEnumDelivery +from scaleapi.api_client.v2.models.expandable_enum_deliveries import ( + ExpandableEnumDeliveries, +) +from scaleapi.api_client.v2.models.expandable_enum_delivery import ( + ExpandableEnumDelivery, +) from scaleapi.api_client.v2.models.expandable_enum_task import ExpandableEnumTask from scaleapi.api_client.v2.models.expandable_project import ExpandableProject -from scaleapi.api_client.v2.models.file import File -from scaleapi.api_client.v2.models.get_delivered_tasks_response import GetDeliveredTasksResponse +from scaleapi.api_client.v2.models.get_delivered_tasks_response import ( + GetDeliveredTasksResponse, +) from scaleapi.api_client.v2.models.get_deliveries_response import GetDeliveriesResponse from scaleapi.api_client.v2.models.get_task500_response import GetTask500Response from scaleapi.api_client.v2.models.get_tasks_response import GetTasksResponse @@ -69,11 +119,35 @@ from scaleapi.api_client.v2.models.model_parameters import ModelParameters from scaleapi.api_client.v2.models.option import Option from scaleapi.api_client.v2.models.project import Project +from scaleapi.api_client.v2.models.reasoning import Reasoning from scaleapi.api_client.v2.models.reference_text import ReferenceText +from scaleapi.api_client.v2.models.sensitive_content_report import ( + SensitiveContentReport, +) from scaleapi.api_client.v2.models.submission import Submission from scaleapi.api_client.v2.models.task import Task from scaleapi.api_client.v2.models.task_status import TaskStatus from scaleapi.api_client.v2.models.thread import Thread from scaleapi.api_client.v2.models.turn import Turn -from scaleapi.api_client.v2.models.v1_task_task_id_get200_response import V1TaskTaskIdGet200Response -from scaleapi.api_client.v2.models.v1_task_task_id_get200_response_response import V1TaskTaskIdGet200ResponseResponse +from scaleapi.api_client.v2.models.v1_task_task_id_get200_response import ( + V1TaskTaskIdGet200Response, +) +from scaleapi.api_client.v2.models.v1_task_task_id_get200_response_response import ( + V1TaskTaskIdGet200ResponseResponse, +) +from scaleapi.api_client.v2.models.workspace_container_config import ( + WorkspaceContainerConfig, +) +from scaleapi.api_client.v2.models.workspace_container_value import ( + WorkspaceContainerValue, +) +from scaleapi.api_client.v2.models.workspace_execution_data import ( + WorkspaceExecutionData, +) +from scaleapi.api_client.v2.models.workspace_execution_data_result import ( + WorkspaceExecutionDataResult, +) +from scaleapi.api_client.v2.models.workspace_execution_data_result_status import ( + WorkspaceExecutionDataResultStatus, +) +from scaleapi.api_client.v2.models.workspace_file import WorkspaceFile diff --git a/scaleapi/api_client/v2/models/__init__.py b/scaleapi/api_client/v2/models/__init__.py index 945d0dc..3624988 100644 --- a/scaleapi/api_client/v2/models/__init__.py +++ b/scaleapi/api_client/v2/models/__init__.py @@ -2,32 +2,77 @@ # flake8: noqa """ - GenAI API Spec +GenAI API Spec - Data Engine: Generative AI API Specification +Data Engine: Generative AI API Specification - The version of the OpenAPI document: 0.0.1 - Generated by OpenAPI Generator (https://openapi-generator.tech) +The version of the OpenAPI document: 0.0.1 +Generated by OpenAPI Generator (https://openapi-generator.tech) - Do not edit the class manually. +Do not edit the class manually. """ # noqa: E501 # import models into model package from scaleapi.api_client.v2.models.annotation import Annotation +from scaleapi.api_client.v2.models.annotation_boolean import AnnotationBoolean +from scaleapi.api_client.v2.models.annotation_boolean_properties import ( + AnnotationBooleanProperties, +) from scaleapi.api_client.v2.models.annotation_category import AnnotationCategory -from scaleapi.api_client.v2.models.annotation_category_multiple import AnnotationCategoryMultiple -from scaleapi.api_client.v2.models.annotation_category_multiple_properties import AnnotationCategoryMultipleProperties -from scaleapi.api_client.v2.models.annotation_category_properties import AnnotationCategoryProperties +from scaleapi.api_client.v2.models.annotation_category_multiple import ( + AnnotationCategoryMultiple, +) +from scaleapi.api_client.v2.models.annotation_category_multiple_properties import ( + AnnotationCategoryMultipleProperties, +) +from scaleapi.api_client.v2.models.annotation_category_properties import ( + AnnotationCategoryProperties, +) +from scaleapi.api_client.v2.models.annotation_file import AnnotationFile +from scaleapi.api_client.v2.models.annotation_file_properties import ( + AnnotationFileProperties, +) +from scaleapi.api_client.v2.models.annotation_file_properties_value import ( + AnnotationFilePropertiesValue, +) from scaleapi.api_client.v2.models.annotation_integer import AnnotationInteger -from scaleapi.api_client.v2.models.annotation_integer_properties import AnnotationIntegerProperties +from scaleapi.api_client.v2.models.annotation_integer_properties import ( + AnnotationIntegerProperties, +) from scaleapi.api_client.v2.models.annotation_metadata import AnnotationMetadata +from scaleapi.api_client.v2.models.annotation_ranked_choices import ( + AnnotationRankedChoices, +) +from scaleapi.api_client.v2.models.annotation_ranked_choices_properties import ( + AnnotationRankedChoicesProperties, +) +from scaleapi.api_client.v2.models.annotation_ranked_groups import ( + AnnotationRankedGroups, +) +from scaleapi.api_client.v2.models.annotation_ranked_groups_properties import ( + AnnotationRankedGroupsProperties, +) from scaleapi.api_client.v2.models.annotation_text import AnnotationText -from scaleapi.api_client.v2.models.annotation_text_properties import AnnotationTextProperties +from scaleapi.api_client.v2.models.annotation_text_properties import ( + AnnotationTextProperties, +) from scaleapi.api_client.v2.models.annotation_type import AnnotationType +from scaleapi.api_client.v2.models.annotation_workspace_container import ( + AnnotationWorkspaceContainer, +) +from scaleapi.api_client.v2.models.annotation_workspace_container_properties import ( + AnnotationWorkspaceContainerProperties, +) from scaleapi.api_client.v2.models.audio_file import AudioFile from scaleapi.api_client.v2.models.base_annotation import BaseAnnotation +from scaleapi.api_client.v2.models.base_chunk import BaseChunk +from scaleapi.api_client.v2.models.basic_file import BasicFile from scaleapi.api_client.v2.models.batch import Batch +from scaleapi.api_client.v2.models.chunk import Chunk +from scaleapi.api_client.v2.models.chunk_text import ChunkText +from scaleapi.api_client.v2.models.chunk_text_properties import ChunkTextProperties +from scaleapi.api_client.v2.models.content_and_url import ContentAndUrl from scaleapi.api_client.v2.models.delivery import Delivery from scaleapi.api_client.v2.models.detailed_file import DetailedFile from scaleapi.api_client.v2.models.error_detail import ErrorDetail @@ -36,12 +81,17 @@ from scaleapi.api_client.v2.models.expandable_annotation import ExpandableAnnotation from scaleapi.api_client.v2.models.expandable_batch import ExpandableBatch from scaleapi.api_client.v2.models.expandable_delivery import ExpandableDelivery -from scaleapi.api_client.v2.models.expandable_enum_deliveries import ExpandableEnumDeliveries -from scaleapi.api_client.v2.models.expandable_enum_delivery import ExpandableEnumDelivery +from scaleapi.api_client.v2.models.expandable_enum_deliveries import ( + ExpandableEnumDeliveries, +) +from scaleapi.api_client.v2.models.expandable_enum_delivery import ( + ExpandableEnumDelivery, +) from scaleapi.api_client.v2.models.expandable_enum_task import ExpandableEnumTask from scaleapi.api_client.v2.models.expandable_project import ExpandableProject -from scaleapi.api_client.v2.models.file import File -from scaleapi.api_client.v2.models.get_delivered_tasks_response import GetDeliveredTasksResponse +from scaleapi.api_client.v2.models.get_delivered_tasks_response import ( + GetDeliveredTasksResponse, +) from scaleapi.api_client.v2.models.get_deliveries_response import GetDeliveriesResponse from scaleapi.api_client.v2.models.get_task500_response import GetTask500Response from scaleapi.api_client.v2.models.get_tasks_response import GetTasksResponse @@ -52,11 +102,35 @@ from scaleapi.api_client.v2.models.model_parameters import ModelParameters from scaleapi.api_client.v2.models.option import Option from scaleapi.api_client.v2.models.project import Project +from scaleapi.api_client.v2.models.reasoning import Reasoning from scaleapi.api_client.v2.models.reference_text import ReferenceText +from scaleapi.api_client.v2.models.sensitive_content_report import ( + SensitiveContentReport, +) from scaleapi.api_client.v2.models.submission import Submission from scaleapi.api_client.v2.models.task import Task from scaleapi.api_client.v2.models.task_status import TaskStatus from scaleapi.api_client.v2.models.thread import Thread from scaleapi.api_client.v2.models.turn import Turn -from scaleapi.api_client.v2.models.v1_task_task_id_get200_response import V1TaskTaskIdGet200Response -from scaleapi.api_client.v2.models.v1_task_task_id_get200_response_response import V1TaskTaskIdGet200ResponseResponse +from scaleapi.api_client.v2.models.v1_task_task_id_get200_response import ( + V1TaskTaskIdGet200Response, +) +from scaleapi.api_client.v2.models.v1_task_task_id_get200_response_response import ( + V1TaskTaskIdGet200ResponseResponse, +) +from scaleapi.api_client.v2.models.workspace_container_config import ( + WorkspaceContainerConfig, +) +from scaleapi.api_client.v2.models.workspace_container_value import ( + WorkspaceContainerValue, +) +from scaleapi.api_client.v2.models.workspace_execution_data import ( + WorkspaceExecutionData, +) +from scaleapi.api_client.v2.models.workspace_execution_data_result import ( + WorkspaceExecutionDataResult, +) +from scaleapi.api_client.v2.models.workspace_execution_data_result_status import ( + WorkspaceExecutionDataResultStatus, +) +from scaleapi.api_client.v2.models.workspace_file import WorkspaceFile diff --git a/scaleapi/api_client/v2/models/annotation.py b/scaleapi/api_client/v2/models/annotation.py index fbd475e..d256448 100644 --- a/scaleapi/api_client/v2/models/annotation.py +++ b/scaleapi/api_client/v2/models/annotation.py @@ -1,14 +1,14 @@ # coding: utf-8 """ - GenAI API Spec +GenAI API Spec - Data Engine: Generative AI API Specification +Data Engine: Generative AI API Specification - The version of the OpenAPI document: 0.0.1 - Generated by OpenAPI Generator (https://openapi-generator.tech) +The version of the OpenAPI document: 0.0.1 +Generated by OpenAPI Generator (https://openapi-generator.tech) - Do not edit the class manually. +Do not edit the class manually. """ # noqa: E501 @@ -16,23 +16,26 @@ import json import pprint -from typing import Any, Dict, List, Optional, Set, Union +from typing import Any, Dict, Optional, Set, Union from pydantic import ( BaseModel, ConfigDict, - Field, - StrictStr, ValidationError, field_validator, ) from typing_extensions import Literal, Self ANNOTATION_ONE_OF_SCHEMAS = [ + "AnnotationBoolean", "AnnotationCategory", "AnnotationCategoryMultiple", + "AnnotationFile", "AnnotationInteger", + "AnnotationRankedChoices", + "AnnotationRankedGroups", "AnnotationText", + "AnnotationWorkspaceContainer", ] @@ -41,27 +44,47 @@ class Annotation(BaseModel): Represents a generic annotation. """ + # data type: AnnotationBoolean + oneof_schema_1_validator: Optional[AnnotationBoolean] = None # data type: AnnotationInteger - oneof_schema_1_validator: Optional[AnnotationInteger] = None + oneof_schema_2_validator: Optional[AnnotationInteger] = None # data type: AnnotationText - oneof_schema_2_validator: Optional[AnnotationText] = None + oneof_schema_3_validator: Optional[AnnotationText] = None # data type: AnnotationCategory - oneof_schema_3_validator: Optional[AnnotationCategory] = None + oneof_schema_4_validator: Optional[AnnotationCategory] = None # data type: AnnotationCategoryMultiple - oneof_schema_4_validator: Optional[AnnotationCategoryMultiple] = None + oneof_schema_5_validator: Optional[AnnotationCategoryMultiple] = None + # data type: AnnotationFile + oneof_schema_6_validator: Optional[AnnotationFile] = None + # data type: AnnotationRankedChoices + oneof_schema_7_validator: Optional[AnnotationRankedChoices] = None + # data type: AnnotationRankedGroups + oneof_schema_8_validator: Optional[AnnotationRankedGroups] = None + # data type: AnnotationWorkspaceContainer + oneof_schema_9_validator: Optional[AnnotationWorkspaceContainer] = None actual_instance: Optional[ Union[ + AnnotationBoolean, AnnotationCategory, AnnotationCategoryMultiple, + AnnotationFile, AnnotationInteger, + AnnotationRankedChoices, + AnnotationRankedGroups, AnnotationText, + AnnotationWorkspaceContainer, ] ] = None one_of_schemas: Set[str] = { + "AnnotationBoolean", "AnnotationCategory", "AnnotationCategoryMultiple", + "AnnotationFile", "AnnotationInteger", + "AnnotationRankedChoices", + "AnnotationRankedGroups", "AnnotationText", + "AnnotationWorkspaceContainer", } model_config = ConfigDict( @@ -90,6 +113,13 @@ def actual_instance_must_validate_oneof(cls, v): instance = Annotation.model_construct() error_messages = [] match = 0 + # validate data type: AnnotationBoolean + if not isinstance(v, AnnotationBoolean): + error_messages.append( + f"Error! Input type `{type(v)}` is not `AnnotationBoolean`" + ) + else: + match += 1 # validate data type: AnnotationInteger if not isinstance(v, AnnotationInteger): error_messages.append( @@ -118,6 +148,34 @@ def actual_instance_must_validate_oneof(cls, v): ) else: match += 1 + # validate data type: AnnotationFile + if not isinstance(v, AnnotationFile): + error_messages.append( + f"Error! Input type `{type(v)}` is not `AnnotationFile`" + ) + else: + match += 1 + # validate data type: AnnotationRankedChoices + if not isinstance(v, AnnotationRankedChoices): + error_messages.append( + f"Error! Input type `{type(v)}` is not `AnnotationRankedChoices`" + ) + else: + match += 1 + # validate data type: AnnotationRankedGroups + if not isinstance(v, AnnotationRankedGroups): + error_messages.append( + f"Error! Input type `{type(v)}` is not `AnnotationRankedGroups`" + ) + else: + match += 1 + # validate data type: AnnotationWorkspaceContainer + if not isinstance(v, AnnotationWorkspaceContainer): + error_messages.append( + f"Error! Input type `{type(v)}` is not `AnnotationWorkspaceContainer`" + ) + else: + match += 1 if match > 1: # more than 1 match raise ValueError( @@ -148,7 +206,10 @@ def from_json(cls, json_str: str) -> Self: # https://github.com/swagger-api/swagger-codegen/issues/10962 try: - if annotation_type == "integer": + if annotation_type == "boolean": + instance.actual_instance = AnnotationBoolean.from_json(json_str) + return instance + elif annotation_type == "integer": instance.actual_instance = AnnotationInteger.from_json(json_str) return instance elif annotation_type == "text": @@ -162,6 +223,20 @@ def from_json(cls, json_str: str) -> Self: json_str ) return instance + elif annotation_type == "file": + instance.actual_instance = AnnotationFile.from_json(json_str) + return instance + elif annotation_type == "ranked_choices": + instance.actual_instance = AnnotationRankedChoices.from_json(json_str) + return instance + elif annotation_type == "ranked_groups": + instance.actual_instance = AnnotationRankedGroups.from_json(json_str) + return instance + elif annotation_type == "workspace_container": + instance.actual_instance = AnnotationWorkspaceContainer.from_json( + json_str + ) + return instance except (ValidationError, ValueError) as e: error_messages.append(str(e)) raise ValueError( @@ -171,6 +246,12 @@ def from_json(cls, json_str: str) -> Self: match = 0 + # deserialize data into AnnotationBoolean + try: + instance.actual_instance = AnnotationBoolean.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) # deserialize data into AnnotationInteger try: instance.actual_instance = AnnotationInteger.from_json(json_str) @@ -195,6 +276,30 @@ def from_json(cls, json_str: str) -> Self: match += 1 except (ValidationError, ValueError) as e: error_messages.append(str(e)) + # deserialize data into AnnotationFile + try: + instance.actual_instance = AnnotationFile.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into AnnotationRankedChoices + try: + instance.actual_instance = AnnotationRankedChoices.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into AnnotationRankedGroups + try: + instance.actual_instance = AnnotationRankedGroups.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into AnnotationWorkspaceContainer + try: + instance.actual_instance = AnnotationWorkspaceContainer.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) if match > 1: # more than 1 match @@ -228,10 +333,15 @@ def to_dict( ) -> Optional[ Union[ Dict[str, Any], + AnnotationBoolean, AnnotationCategory, AnnotationCategoryMultiple, + AnnotationFile, AnnotationInteger, + AnnotationRankedChoices, + AnnotationRankedGroups, AnnotationText, + AnnotationWorkspaceContainer, ] ]: """Returns the dict representation of the actual instance""" @@ -251,12 +361,23 @@ def to_str(self) -> str: return pprint.pformat(self.model_dump()) +from scaleapi.api_client.v2.models.annotation_boolean import AnnotationBoolean from scaleapi.api_client.v2.models.annotation_category import AnnotationCategory from scaleapi.api_client.v2.models.annotation_category_multiple import ( AnnotationCategoryMultiple, ) +from scaleapi.api_client.v2.models.annotation_file import AnnotationFile from scaleapi.api_client.v2.models.annotation_integer import AnnotationInteger +from scaleapi.api_client.v2.models.annotation_ranked_choices import ( + AnnotationRankedChoices, +) +from scaleapi.api_client.v2.models.annotation_ranked_groups import ( + AnnotationRankedGroups, +) from scaleapi.api_client.v2.models.annotation_text import AnnotationText +from scaleapi.api_client.v2.models.annotation_workspace_container import ( + AnnotationWorkspaceContainer, +) # TODO: Rewrite to not use raise_errors Annotation.model_rebuild(raise_errors=False) diff --git a/scaleapi/api_client/v2/models/annotation_boolean.py b/scaleapi/api_client/v2/models/annotation_boolean.py new file mode 100644 index 0000000..0dfc560 --- /dev/null +++ b/scaleapi/api_client/v2/models/annotation_boolean.py @@ -0,0 +1,113 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class AnnotationBoolean(BaseModel): + """ + AnnotationBoolean + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for an annotation.") + key: StrictStr = Field(description="Key for the annotation.") + type: StrictStr = Field(description="The type of the value and the possible_values, if they exist.") + title: Optional[StrictStr] = Field(default=None, description="Title of the annotation.") + description: Optional[StrictStr] = Field(default=None, description="Further details about the question.") + labels: Optional[List[StrictStr]] = Field(default=None, description="String representation of the possible options.") + not_applicable: Optional[StrictBool] = Field(default=None, description="This is set when the annotation is not applicable in the context.") + cannot_assess: Optional[StrictBool] = Field(default=None, description="This is set when the annotation cannot be assessed in the context.") + metadata: Optional[AnnotationMetadata] = None + value: Optional[StrictBool] = Field(default=None, description="Boolean type annotation value.") + possible_values: Optional[List[StrictBool]] = Field(default=None, description="The possible values for this annotation.") + __properties: ClassVar[List[str]] = ["id", "key", "type", "title", "description", "labels", "not_applicable", "cannot_assess", "metadata", "value", "possible_values"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AnnotationBoolean from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of metadata + if self.metadata: + _dict['metadata'] = self.metadata.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AnnotationBoolean from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "key": obj.get("key"), + "type": obj.get("type"), + "title": obj.get("title"), + "description": obj.get("description"), + "labels": obj.get("labels"), + "not_applicable": obj.get("not_applicable"), + "cannot_assess": obj.get("cannot_assess"), + "metadata": AnnotationMetadata.from_dict(obj["metadata"]) if obj.get("metadata") is not None else None, + "value": obj.get("value"), + "possible_values": obj.get("possible_values") + }) + return _obj + +from scaleapi.api_client.v2.models.annotation_metadata import AnnotationMetadata +# TODO: Rewrite to not use raise_errors +AnnotationBoolean.model_rebuild(raise_errors=False) diff --git a/scaleapi/api_client/v2/models/annotation_boolean_properties.py b/scaleapi/api_client/v2/models/annotation_boolean_properties.py new file mode 100644 index 0000000..8ffe057 --- /dev/null +++ b/scaleapi/api_client/v2/models/annotation_boolean_properties.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class AnnotationBooleanProperties(BaseModel): + """ + AnnotationBooleanProperties + """ # noqa: E501 + value: Optional[StrictBool] = Field(default=None, description="Boolean type annotation value.") + possible_values: Optional[List[StrictBool]] = Field(default=None, description="The possible values for this annotation.") + __properties: ClassVar[List[str]] = ["value", "possible_values"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AnnotationBooleanProperties from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AnnotationBooleanProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "value": obj.get("value"), + "possible_values": obj.get("possible_values") + }) + return _obj diff --git a/scaleapi/api_client/v2/models/annotation_file.py b/scaleapi/api_client/v2/models/annotation_file.py new file mode 100644 index 0000000..9b70edb --- /dev/null +++ b/scaleapi/api_client/v2/models/annotation_file.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from scaleapi.api_client.v2.models.annotation_file_properties_value import AnnotationFilePropertiesValue +from typing import Optional, Set +from typing_extensions import Self + +class AnnotationFile(BaseModel): + """ + AnnotationFile + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for an annotation.") + key: StrictStr = Field(description="Key for the annotation.") + type: StrictStr = Field(description="The type of the value and the possible_values, if they exist.") + title: Optional[StrictStr] = Field(default=None, description="Title of the annotation.") + description: Optional[StrictStr] = Field(default=None, description="Further details about the question.") + labels: Optional[List[StrictStr]] = Field(default=None, description="String representation of the possible options.") + not_applicable: Optional[StrictBool] = Field(default=None, description="This is set when the annotation is not applicable in the context.") + cannot_assess: Optional[StrictBool] = Field(default=None, description="This is set when the annotation cannot be assessed in the context.") + metadata: Optional[AnnotationMetadata] = None + value: Optional[AnnotationFilePropertiesValue] = None + __properties: ClassVar[List[str]] = ["id", "key", "type", "title", "description", "labels", "not_applicable", "cannot_assess", "metadata", "value"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AnnotationFile from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of metadata + if self.metadata: + _dict['metadata'] = self.metadata.to_dict() + # override the default output from pydantic by calling `to_dict()` of value + if self.value: + _dict['value'] = self.value.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AnnotationFile from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "key": obj.get("key"), + "type": obj.get("type"), + "title": obj.get("title"), + "description": obj.get("description"), + "labels": obj.get("labels"), + "not_applicable": obj.get("not_applicable"), + "cannot_assess": obj.get("cannot_assess"), + "metadata": AnnotationMetadata.from_dict(obj["metadata"]) if obj.get("metadata") is not None else None, + "value": AnnotationFilePropertiesValue.from_dict(obj["value"]) if obj.get("value") is not None else None + }) + return _obj + +from scaleapi.api_client.v2.models.annotation_metadata import AnnotationMetadata +# TODO: Rewrite to not use raise_errors +AnnotationFile.model_rebuild(raise_errors=False) diff --git a/scaleapi/api_client/v2/models/annotation_file_properties.py b/scaleapi/api_client/v2/models/annotation_file_properties.py new file mode 100644 index 0000000..56ab79a --- /dev/null +++ b/scaleapi/api_client/v2/models/annotation_file_properties.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List, Optional +from scaleapi.api_client.v2.models.annotation_file_properties_value import AnnotationFilePropertiesValue +from typing import Optional, Set +from typing_extensions import Self + +class AnnotationFileProperties(BaseModel): + """ + AnnotationFileProperties + """ # noqa: E501 + value: Optional[AnnotationFilePropertiesValue] = None + __properties: ClassVar[List[str]] = ["value"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AnnotationFileProperties from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of value + if self.value: + _dict['value'] = self.value.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AnnotationFileProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "value": AnnotationFilePropertiesValue.from_dict(obj["value"]) if obj.get("value") is not None else None + }) + return _obj diff --git a/scaleapi/api_client/v2/models/annotation_file_properties_value.py b/scaleapi/api_client/v2/models/annotation_file_properties_value.py new file mode 100644 index 0000000..3565236 --- /dev/null +++ b/scaleapi/api_client/v2/models/annotation_file_properties_value.py @@ -0,0 +1,139 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import json +import pprint +from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator +from typing import Any, List, Optional +from scaleapi.api_client.v2.models.basic_file import BasicFile +from scaleapi.api_client.v2.models.detailed_file import DetailedFile +from pydantic import StrictStr, Field +from typing import Union, List, Set, Optional, Dict +from typing_extensions import Literal, Self + +ANNOTATIONFILEPROPERTIESVALUE_ONE_OF_SCHEMAS = ["DetailedFile", "List[BasicFile]"] + +class AnnotationFilePropertiesValue(BaseModel): + """ + AnnotationFilePropertiesValue + """ + # data type: DetailedFile + oneof_schema_1_validator: Optional[DetailedFile] = None + # data type: List[BasicFile] + oneof_schema_2_validator: Optional[List[BasicFile]] = None + actual_instance: Optional[Union[DetailedFile, List[BasicFile]]] = None + one_of_schemas: Set[str] = { "DetailedFile", "List[BasicFile]" } + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator('actual_instance') + def actual_instance_must_validate_oneof(cls, v): + instance = AnnotationFilePropertiesValue.model_construct() + error_messages = [] + match = 0 + # validate data type: DetailedFile + if not isinstance(v, DetailedFile): + error_messages.append(f"Error! Input type `{type(v)}` is not `DetailedFile`") + else: + match += 1 + # validate data type: List[BasicFile] + try: + instance.oneof_schema_2_validator = v + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when setting `actual_instance` in AnnotationFilePropertiesValue with oneOf schemas: DetailedFile, List[BasicFile]. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when setting `actual_instance` in AnnotationFilePropertiesValue with oneOf schemas: DetailedFile, List[BasicFile]. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # deserialize data into DetailedFile + try: + instance.actual_instance = DetailedFile.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into List[BasicFile] + try: + # validation + instance.oneof_schema_2_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.oneof_schema_2_validator + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when deserializing the JSON string into AnnotationFilePropertiesValue with oneOf schemas: DetailedFile, List[BasicFile]. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when deserializing the JSON string into AnnotationFilePropertiesValue with oneOf schemas: DetailedFile, List[BasicFile]. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], DetailedFile, List[BasicFile]]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/scaleapi/api_client/v2/models/annotation_ranked_choices.py b/scaleapi/api_client/v2/models/annotation_ranked_choices.py new file mode 100644 index 0000000..74f94cf --- /dev/null +++ b/scaleapi/api_client/v2/models/annotation_ranked_choices.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class AnnotationRankedChoices(BaseModel): + """ + A list of choices where the beginning of the list is preferred. Ties are not allowed. + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for an annotation.") + key: StrictStr = Field(description="Key for the annotation.") + type: StrictStr = Field(description="The type of the value and the possible_values, if they exist.") + title: Optional[StrictStr] = Field(default=None, description="Title of the annotation.") + description: Optional[StrictStr] = Field(default=None, description="Further details about the question.") + labels: Optional[List[StrictStr]] = Field(default=None, description="String representation of the possible options.") + not_applicable: Optional[StrictBool] = Field(default=None, description="This is set when the annotation is not applicable in the context.") + cannot_assess: Optional[StrictBool] = Field(default=None, description="This is set when the annotation cannot be assessed in the context.") + metadata: Optional[AnnotationMetadata] = None + value: Optional[List[StrictStr]] = None + __properties: ClassVar[List[str]] = ["id", "key", "type", "title", "description", "labels", "not_applicable", "cannot_assess", "metadata", "value"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AnnotationRankedChoices from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of metadata + if self.metadata: + _dict['metadata'] = self.metadata.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AnnotationRankedChoices from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "key": obj.get("key"), + "type": obj.get("type"), + "title": obj.get("title"), + "description": obj.get("description"), + "labels": obj.get("labels"), + "not_applicable": obj.get("not_applicable"), + "cannot_assess": obj.get("cannot_assess"), + "metadata": AnnotationMetadata.from_dict(obj["metadata"]) if obj.get("metadata") is not None else None, + "value": obj.get("value") + }) + return _obj + +from scaleapi.api_client.v2.models.annotation_metadata import AnnotationMetadata +# TODO: Rewrite to not use raise_errors +AnnotationRankedChoices.model_rebuild(raise_errors=False) diff --git a/scaleapi/api_client/v2/models/annotation_ranked_choices_properties.py b/scaleapi/api_client/v2/models/annotation_ranked_choices_properties.py new file mode 100644 index 0000000..3cd6e81 --- /dev/null +++ b/scaleapi/api_client/v2/models/annotation_ranked_choices_properties.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class AnnotationRankedChoicesProperties(BaseModel): + """ + AnnotationRankedChoicesProperties + """ # noqa: E501 + value: Optional[List[StrictStr]] = None + __properties: ClassVar[List[str]] = ["value"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AnnotationRankedChoicesProperties from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AnnotationRankedChoicesProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "value": obj.get("value") + }) + return _obj diff --git a/scaleapi/api_client/v2/models/annotation_ranked_groups.py b/scaleapi/api_client/v2/models/annotation_ranked_groups.py new file mode 100644 index 0000000..a4da483 --- /dev/null +++ b/scaleapi/api_client/v2/models/annotation_ranked_groups.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class AnnotationRankedGroups(BaseModel): + """ + A list of choices where the beginning of the list is preferred. When there's a tie, multiple choices will be at the same index. + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for an annotation.") + key: StrictStr = Field(description="Key for the annotation.") + type: StrictStr = Field(description="The type of the value and the possible_values, if they exist.") + title: Optional[StrictStr] = Field(default=None, description="Title of the annotation.") + description: Optional[StrictStr] = Field(default=None, description="Further details about the question.") + labels: Optional[List[StrictStr]] = Field(default=None, description="String representation of the possible options.") + not_applicable: Optional[StrictBool] = Field(default=None, description="This is set when the annotation is not applicable in the context.") + cannot_assess: Optional[StrictBool] = Field(default=None, description="This is set when the annotation cannot be assessed in the context.") + metadata: Optional[AnnotationMetadata] = None + value: Optional[List[List[StrictStr]]] = None + __properties: ClassVar[List[str]] = ["id", "key", "type", "title", "description", "labels", "not_applicable", "cannot_assess", "metadata", "value"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AnnotationRankedGroups from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of metadata + if self.metadata: + _dict['metadata'] = self.metadata.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AnnotationRankedGroups from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "key": obj.get("key"), + "type": obj.get("type"), + "title": obj.get("title"), + "description": obj.get("description"), + "labels": obj.get("labels"), + "not_applicable": obj.get("not_applicable"), + "cannot_assess": obj.get("cannot_assess"), + "metadata": AnnotationMetadata.from_dict(obj["metadata"]) if obj.get("metadata") is not None else None, + "value": obj.get("value") + }) + return _obj + +from scaleapi.api_client.v2.models.annotation_metadata import AnnotationMetadata +# TODO: Rewrite to not use raise_errors +AnnotationRankedGroups.model_rebuild(raise_errors=False) diff --git a/scaleapi/api_client/v2/models/annotation_ranked_groups_properties.py b/scaleapi/api_client/v2/models/annotation_ranked_groups_properties.py new file mode 100644 index 0000000..c7bf385 --- /dev/null +++ b/scaleapi/api_client/v2/models/annotation_ranked_groups_properties.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class AnnotationRankedGroupsProperties(BaseModel): + """ + AnnotationRankedGroupsProperties + """ # noqa: E501 + value: Optional[List[List[StrictStr]]] = None + __properties: ClassVar[List[str]] = ["value"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AnnotationRankedGroupsProperties from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AnnotationRankedGroupsProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "value": obj.get("value") + }) + return _obj diff --git a/scaleapi/api_client/v2/models/annotation_type.py b/scaleapi/api_client/v2/models/annotation_type.py index ae9b685..f678f88 100644 --- a/scaleapi/api_client/v2/models/annotation_type.py +++ b/scaleapi/api_client/v2/models/annotation_type.py @@ -1,14 +1,14 @@ # coding: utf-8 """ - GenAI API Spec +GenAI API Spec - Data Engine: Generative AI API Specification +Data Engine: Generative AI API Specification - The version of the OpenAPI document: 0.0.1 - Generated by OpenAPI Generator (https://openapi-generator.tech) +The version of the OpenAPI document: 0.0.1 +Generated by OpenAPI Generator (https://openapi-generator.tech) - Do not edit the class manually. +Do not edit the class manually. """ # noqa: E501 @@ -26,10 +26,15 @@ class AnnotationType(str, Enum): """ allowed enum values """ - INTEGER = 'integer' - TEXT = 'text' - CATEGORY = 'category' - CATEGORY_MULTIPLE = 'category_multiple' + INTEGER = "integer" + BOOLEAN = "boolean" + TEXT = "text" + CATEGORY = "category" + CATEGORY_MULTIPLE = "category_multiple" + FILE = "file" + WORKSPACE_CONTAINER = "workspace_container" + RANKED_CHOICES = "ranked_choices" + RANKED_GROUPS = "ranked_groups" @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/scaleapi/api_client/v2/models/annotation_workspace_container.py b/scaleapi/api_client/v2/models/annotation_workspace_container.py new file mode 100644 index 0000000..b79ea48 --- /dev/null +++ b/scaleapi/api_client/v2/models/annotation_workspace_container.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from scaleapi.api_client.v2.models.workspace_container_value import WorkspaceContainerValue +from typing import Optional, Set +from typing_extensions import Self + +class AnnotationWorkspaceContainer(BaseModel): + """ + AnnotationWorkspaceContainer + """ # noqa: E501 + id: StrictStr = Field(description="Unique identifier for an annotation.") + key: StrictStr = Field(description="Key for the annotation.") + type: StrictStr = Field(description="The type of the value and the possible_values, if they exist.") + title: Optional[StrictStr] = Field(default=None, description="Title of the annotation.") + description: Optional[StrictStr] = Field(default=None, description="Further details about the question.") + labels: Optional[List[StrictStr]] = Field(default=None, description="String representation of the possible options.") + not_applicable: Optional[StrictBool] = Field(default=None, description="This is set when the annotation is not applicable in the context.") + cannot_assess: Optional[StrictBool] = Field(default=None, description="This is set when the annotation cannot be assessed in the context.") + metadata: Optional[AnnotationMetadata] = None + value: Optional[WorkspaceContainerValue] = None + __properties: ClassVar[List[str]] = ["id", "key", "type", "title", "description", "labels", "not_applicable", "cannot_assess", "metadata", "value"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AnnotationWorkspaceContainer from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of metadata + if self.metadata: + _dict['metadata'] = self.metadata.to_dict() + # override the default output from pydantic by calling `to_dict()` of value + if self.value: + _dict['value'] = self.value.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AnnotationWorkspaceContainer from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "key": obj.get("key"), + "type": obj.get("type"), + "title": obj.get("title"), + "description": obj.get("description"), + "labels": obj.get("labels"), + "not_applicable": obj.get("not_applicable"), + "cannot_assess": obj.get("cannot_assess"), + "metadata": AnnotationMetadata.from_dict(obj["metadata"]) if obj.get("metadata") is not None else None, + "value": WorkspaceContainerValue.from_dict(obj["value"]) if obj.get("value") is not None else None + }) + return _obj + +from scaleapi.api_client.v2.models.annotation_metadata import AnnotationMetadata +# TODO: Rewrite to not use raise_errors +AnnotationWorkspaceContainer.model_rebuild(raise_errors=False) diff --git a/scaleapi/api_client/v2/models/annotation_workspace_container_properties.py b/scaleapi/api_client/v2/models/annotation_workspace_container_properties.py new file mode 100644 index 0000000..ef7e426 --- /dev/null +++ b/scaleapi/api_client/v2/models/annotation_workspace_container_properties.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List, Optional +from scaleapi.api_client.v2.models.workspace_container_value import WorkspaceContainerValue +from typing import Optional, Set +from typing_extensions import Self + +class AnnotationWorkspaceContainerProperties(BaseModel): + """ + AnnotationWorkspaceContainerProperties + """ # noqa: E501 + value: Optional[WorkspaceContainerValue] = None + __properties: ClassVar[List[str]] = ["value"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AnnotationWorkspaceContainerProperties from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of value + if self.value: + _dict['value'] = self.value.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AnnotationWorkspaceContainerProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "value": WorkspaceContainerValue.from_dict(obj["value"]) if obj.get("value") is not None else None + }) + return _obj diff --git a/scaleapi/api_client/v2/models/audio_file.py b/scaleapi/api_client/v2/models/audio_file.py index b62f52d..b8860e6 100644 --- a/scaleapi/api_client/v2/models/audio_file.py +++ b/scaleapi/api_client/v2/models/audio_file.py @@ -28,12 +28,13 @@ class AudioFile(BaseModel): """ # noqa: E501 mime_type: Optional[StrictStr] = Field(default=None, description="The MIME type of the content, such as application/json or image/png.") scale_url: Optional[StrictStr] = Field(default=None, description="A URL string pointing to a resource.") + url: Optional[StrictStr] = Field(default=None, description="A URL string pointing to a resource.") duration: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The duration of the audio file in seconds.") transcript: Optional[StrictStr] = Field(default=None, description="The transcript of the audio file.") transcript_url: Optional[StrictStr] = Field(default=None, description="A URL string pointing to a resource.") transcript_start: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The start time of the transcript in seconds.") transcript_end: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The end time of the transcript in seconds.") - __properties: ClassVar[List[str]] = ["mime_type", "scale_url", "duration", "transcript", "transcript_url", "transcript_start", "transcript_end"] + __properties: ClassVar[List[str]] = ["mime_type", "scale_url", "url", "duration", "transcript", "transcript_url", "transcript_start", "transcript_end"] model_config = ConfigDict( populate_by_name=True, @@ -89,6 +90,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "mime_type": obj.get("mime_type"), "scale_url": obj.get("scale_url"), + "url": obj.get("url"), "duration": obj.get("duration"), "transcript": obj.get("transcript"), "transcript_url": obj.get("transcript_url"), diff --git a/scaleapi/api_client/v2/models/base_chunk.py b/scaleapi/api_client/v2/models/base_chunk.py new file mode 100644 index 0000000..2f0ce59 --- /dev/null +++ b/scaleapi/api_client/v2/models/base_chunk.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from scaleapi.api_client.v2.models.annotation import Annotation +from typing import Optional, Set +from typing_extensions import Self + +class BaseChunk(BaseModel): + """ + BaseChunk + """ # noqa: E501 + type: StrictStr = Field(description="The type of chunked data.") + annotations: List[Annotation] = Field(description="Array of annotations.") + __properties: ClassVar[List[str]] = ["type", "annotations"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of BaseChunk from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in annotations (list) + _items = [] + if self.annotations: + for _item_annotations in self.annotations: + if _item_annotations: + _items.append(_item_annotations.to_dict()) + _dict['annotations'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of BaseChunk from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "type": obj.get("type"), + "annotations": [Annotation.from_dict(_item) for _item in obj["annotations"]] if obj.get("annotations") is not None else None + }) + return _obj diff --git a/scaleapi/api_client/v2/models/basic_file.py b/scaleapi/api_client/v2/models/basic_file.py new file mode 100644 index 0000000..03fe451 --- /dev/null +++ b/scaleapi/api_client/v2/models/basic_file.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class BasicFile(BaseModel): + """ + BasicFile + """ # noqa: E501 + content: Optional[Union[StrictBytes, StrictStr]] = Field(default=None, description="Base-64 encoded data") + mime_type: Optional[StrictStr] = Field(default=None, description="The MIME type of the content, such as application/json or image/png.") + scale_url: Optional[StrictStr] = Field(default=None, description="A URL string pointing to a resource.") + url: Optional[StrictStr] = Field(default=None, description="A URL string pointing to a resource.") + name: Optional[StrictStr] = Field(default=None, description="The name of the file.") + __properties: ClassVar[List[str]] = ["content", "mime_type", "scale_url", "url", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of BasicFile from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of BasicFile from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "content": obj.get("content"), + "mime_type": obj.get("mime_type"), + "scale_url": obj.get("scale_url"), + "url": obj.get("url"), + "name": obj.get("name") + }) + return _obj diff --git a/scaleapi/api_client/v2/models/batch.py b/scaleapi/api_client/v2/models/batch.py index 6dceb4e..5c93787 100644 --- a/scaleapi/api_client/v2/models/batch.py +++ b/scaleapi/api_client/v2/models/batch.py @@ -24,7 +24,7 @@ class Batch(BaseModel): """ - Represents a batch. + Batch """ # noqa: E501 id: StrictStr = Field(description="A unique identifier for the batch.") name: StrictStr = Field(description="The name of the batch.") diff --git a/scaleapi/api_client/v2/models/chunk.py b/scaleapi/api_client/v2/models/chunk.py new file mode 100644 index 0000000..5835d8c --- /dev/null +++ b/scaleapi/api_client/v2/models/chunk.py @@ -0,0 +1,124 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import json +import pprint +from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator +from typing import Any, List, Optional +from scaleapi.api_client.v2.models.chunk_text import ChunkText +from pydantic import StrictStr, Field +from typing import Union, List, Set, Optional, Dict +from typing_extensions import Literal, Self + +CHUNK_ONE_OF_SCHEMAS = ["ChunkText"] + +class Chunk(BaseModel): + """ + Chunk + """ + # data type: ChunkText + oneof_schema_1_validator: Optional[ChunkText] = None + actual_instance: Optional[Union[ChunkText]] = None + one_of_schemas: Set[str] = { "ChunkText" } + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + + discriminator_value_class_map: Dict[str, str] = { + } + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator('actual_instance') + def actual_instance_must_validate_oneof(cls, v): + instance = Chunk.model_construct() + error_messages = [] + match = 0 + # validate data type: ChunkText + if not isinstance(v, ChunkText): + error_messages.append(f"Error! Input type `{type(v)}` is not `ChunkText`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when setting `actual_instance` in Chunk with oneOf schemas: ChunkText. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when setting `actual_instance` in Chunk with oneOf schemas: ChunkText. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # deserialize data into ChunkText + try: + instance.actual_instance = ChunkText.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when deserializing the JSON string into Chunk with oneOf schemas: ChunkText. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when deserializing the JSON string into Chunk with oneOf schemas: ChunkText. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], ChunkText]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/scaleapi/api_client/v2/models/chunk_text.py b/scaleapi/api_client/v2/models/chunk_text.py new file mode 100644 index 0000000..9527176 --- /dev/null +++ b/scaleapi/api_client/v2/models/chunk_text.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from scaleapi.api_client.v2.models.annotation import Annotation +from typing import Optional, Set +from typing_extensions import Self + +class ChunkText(BaseModel): + """ + ChunkText + """ # noqa: E501 + type: StrictStr = Field(description="The type of chunked data.") + annotations: List[Annotation] = Field(description="Array of annotations.") + text: StrictStr = Field(description="A plain text field.") + __properties: ClassVar[List[str]] = ["type", "annotations", "text"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ChunkText from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in annotations (list) + _items = [] + if self.annotations: + for _item_annotations in self.annotations: + if _item_annotations: + _items.append(_item_annotations.to_dict()) + _dict['annotations'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ChunkText from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "type": obj.get("type"), + "annotations": [Annotation.from_dict(_item) for _item in obj["annotations"]] if obj.get("annotations") is not None else None, + "text": obj.get("text") + }) + return _obj diff --git a/scaleapi/api_client/v2/models/chunk_text_properties.py b/scaleapi/api_client/v2/models/chunk_text_properties.py new file mode 100644 index 0000000..f10323d --- /dev/null +++ b/scaleapi/api_client/v2/models/chunk_text_properties.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class ChunkTextProperties(BaseModel): + """ + ChunkTextProperties + """ # noqa: E501 + text: StrictStr = Field(description="A plain text field.") + __properties: ClassVar[List[str]] = ["text"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ChunkTextProperties from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ChunkTextProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "text": obj.get("text") + }) + return _obj diff --git a/scaleapi/api_client/v2/models/content_and_url.py b/scaleapi/api_client/v2/models/content_and_url.py new file mode 100644 index 0000000..b7ad80f --- /dev/null +++ b/scaleapi/api_client/v2/models/content_and_url.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class ContentAndUrl(BaseModel): + """ + ContentAndUrl + """ # noqa: E501 + content: Optional[StrictStr] = Field(default=None, description="The content of the file.") + url: Optional[StrictStr] = Field(default=None, description="A URL string pointing to a resource.") + scale_url: Optional[StrictStr] = Field(default=None, description="A URL string pointing to a resource.") + __properties: ClassVar[List[str]] = ["content", "url", "scale_url"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ContentAndUrl from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ContentAndUrl from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "content": obj.get("content"), + "url": obj.get("url"), + "scale_url": obj.get("scale_url") + }) + return _obj diff --git a/scaleapi/api_client/v2/models/detailed_file.py b/scaleapi/api_client/v2/models/detailed_file.py index 4eece34..a6b07ee 100644 --- a/scaleapi/api_client/v2/models/detailed_file.py +++ b/scaleapi/api_client/v2/models/detailed_file.py @@ -18,26 +18,26 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from scaleapi.api_client.v2.models.audio_file import AudioFile -from scaleapi.api_client.v2.models.file import File +from scaleapi.api_client.v2.models.basic_file import BasicFile from scaleapi.api_client.v2.models.image_file import ImageFile from pydantic import StrictStr, Field from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self -DETAILEDFILE_ONE_OF_SCHEMAS = ["AudioFile", "File", "ImageFile"] +DETAILEDFILE_ONE_OF_SCHEMAS = ["AudioFile", "BasicFile", "ImageFile"] class DetailedFile(BaseModel): """ DetailedFile """ - # data type: File - oneof_schema_1_validator: Optional[File] = None + # data type: BasicFile + oneof_schema_1_validator: Optional[BasicFile] = None # data type: ImageFile oneof_schema_2_validator: Optional[ImageFile] = None # data type: AudioFile oneof_schema_3_validator: Optional[AudioFile] = None - actual_instance: Optional[Union[AudioFile, File, ImageFile]] = None - one_of_schemas: Set[str] = { "AudioFile", "File", "ImageFile" } + actual_instance: Optional[Union[AudioFile, BasicFile, ImageFile]] = None + one_of_schemas: Set[str] = { "AudioFile", "BasicFile", "ImageFile" } model_config = ConfigDict( validate_assignment=True, @@ -60,9 +60,9 @@ def actual_instance_must_validate_oneof(cls, v): instance = DetailedFile.model_construct() error_messages = [] match = 0 - # validate data type: File - if not isinstance(v, File): - error_messages.append(f"Error! Input type `{type(v)}` is not `File`") + # validate data type: BasicFile + if not isinstance(v, BasicFile): + error_messages.append(f"Error! Input type `{type(v)}` is not `BasicFile`") else: match += 1 # validate data type: ImageFile @@ -77,10 +77,10 @@ def actual_instance_must_validate_oneof(cls, v): match += 1 if match > 1: # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in DetailedFile with oneOf schemas: AudioFile, File, ImageFile. Details: " + ", ".join(error_messages)) + raise ValueError("Multiple matches found when setting `actual_instance` in DetailedFile with oneOf schemas: AudioFile, BasicFile, ImageFile. Details: " + ", ".join(error_messages)) elif match == 0: # no match - raise ValueError("No match found when setting `actual_instance` in DetailedFile with oneOf schemas: AudioFile, File, ImageFile. Details: " + ", ".join(error_messages)) + raise ValueError("No match found when setting `actual_instance` in DetailedFile with oneOf schemas: AudioFile, BasicFile, ImageFile. Details: " + ", ".join(error_messages)) else: return v @@ -95,9 +95,9 @@ def from_json(cls, json_str: str) -> Self: error_messages = [] match = 0 - # deserialize data into File + # deserialize data into BasicFile try: - instance.actual_instance = File.from_json(json_str) + instance.actual_instance = BasicFile.from_json(json_str) match += 1 except (ValidationError, ValueError) as e: error_messages.append(str(e)) @@ -116,10 +116,10 @@ def from_json(cls, json_str: str) -> Self: if match > 1: # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into DetailedFile with oneOf schemas: AudioFile, File, ImageFile. Details: " + ", ".join(error_messages)) + raise ValueError("Multiple matches found when deserializing the JSON string into DetailedFile with oneOf schemas: AudioFile, BasicFile, ImageFile. Details: " + ", ".join(error_messages)) elif match == 0: # no match - raise ValueError("No match found when deserializing the JSON string into DetailedFile with oneOf schemas: AudioFile, File, ImageFile. Details: " + ", ".join(error_messages)) + raise ValueError("No match found when deserializing the JSON string into DetailedFile with oneOf schemas: AudioFile, BasicFile, ImageFile. Details: " + ", ".join(error_messages)) else: return instance @@ -133,7 +133,7 @@ def to_json(self) -> str: else: return json.dumps(self.actual_instance) - def to_dict(self) -> Optional[Union[Dict[str, Any], AudioFile, File, ImageFile]]: + def to_dict(self) -> Optional[Union[Dict[str, Any], AudioFile, BasicFile, ImageFile]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None diff --git a/scaleapi/api_client/v2/models/error_detail.py b/scaleapi/api_client/v2/models/error_detail.py index 78f2eee..ac186ce 100644 --- a/scaleapi/api_client/v2/models/error_detail.py +++ b/scaleapi/api_client/v2/models/error_detail.py @@ -25,7 +25,7 @@ class ErrorDetail(BaseModel): """ - Details of the error on the task. Available when the task status is `error` + ErrorDetail """ # noqa: E501 type: Optional[ErrorType] = Field(default=None, description="Type of the error") message: Optional[StrictStr] = Field(default=None, description="Details of the error message") diff --git a/scaleapi/api_client/v2/models/error_type.py b/scaleapi/api_client/v2/models/error_type.py index 443ebb7..81503fa 100644 --- a/scaleapi/api_client/v2/models/error_type.py +++ b/scaleapi/api_client/v2/models/error_type.py @@ -30,6 +30,7 @@ class ErrorType(str, Enum): LANGUAGE_MISMATCH = 'LANGUAGE_MISMATCH' PROMPT_LENGTH_EXCEEDED = 'PROMPT_LENGTH_EXCEEDED' INVALID_CATEGORY = 'INVALID_CATEGORY' + PROMPT_INFEASIBLE = 'PROMPT_INFEASIBLE' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/scaleapi/api_client/v2/models/message_content.py b/scaleapi/api_client/v2/models/message_content.py index 9a2e029..c5280b9 100644 --- a/scaleapi/api_client/v2/models/message_content.py +++ b/scaleapi/api_client/v2/models/message_content.py @@ -19,7 +19,9 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional +from scaleapi.api_client.v2.models.chunk import Chunk from scaleapi.api_client.v2.models.detailed_file import DetailedFile +from scaleapi.api_client.v2.models.reasoning import Reasoning from scaleapi.api_client.v2.models.reference_text import ReferenceText from typing import Optional, Set from typing_extensions import Self @@ -31,7 +33,9 @@ class MessageContent(BaseModel): text: Optional[StrictStr] = Field(default=None, description="A plain text field.") reference_texts: Optional[List[ReferenceText]] = Field(default=None, description="A list of files or attachments associated with the message.") attachments: Optional[List[DetailedFile]] = Field(default=None, description="A list of files or attachments associated with the message.") - __properties: ClassVar[List[str]] = ["text", "reference_texts", "attachments"] + chunks: Optional[List[Chunk]] = None + reasoning: Optional[List[Reasoning]] = None + __properties: ClassVar[List[str]] = ["text", "reference_texts", "attachments", "chunks", "reasoning"] model_config = ConfigDict( populate_by_name=True, @@ -87,6 +91,20 @@ def to_dict(self) -> Dict[str, Any]: if _item_attachments: _items.append(_item_attachments.to_dict()) _dict['attachments'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in chunks (list) + _items = [] + if self.chunks: + for _item_chunks in self.chunks: + if _item_chunks: + _items.append(_item_chunks.to_dict()) + _dict['chunks'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in reasoning (list) + _items = [] + if self.reasoning: + for _item_reasoning in self.reasoning: + if _item_reasoning: + _items.append(_item_reasoning.to_dict()) + _dict['reasoning'] = _items return _dict @classmethod @@ -101,6 +119,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "text": obj.get("text"), "reference_texts": [ReferenceText.from_dict(_item) for _item in obj["reference_texts"]] if obj.get("reference_texts") is not None else None, - "attachments": [DetailedFile.from_dict(_item) for _item in obj["attachments"]] if obj.get("attachments") is not None else None + "attachments": [DetailedFile.from_dict(_item) for _item in obj["attachments"]] if obj.get("attachments") is not None else None, + "chunks": [Chunk.from_dict(_item) for _item in obj["chunks"]] if obj.get("chunks") is not None else None, + "reasoning": [Reasoning.from_dict(_item) for _item in obj["reasoning"]] if obj.get("reasoning") is not None else None }) return _obj diff --git a/scaleapi/api_client/v2/models/model_parameters.py b/scaleapi/api_client/v2/models/model_parameters.py index e31b351..5709ddd 100644 --- a/scaleapi/api_client/v2/models/model_parameters.py +++ b/scaleapi/api_client/v2/models/model_parameters.py @@ -29,7 +29,9 @@ class ModelParameters(BaseModel): model: Optional[StrictStr] = Field(default=None, description="The name of the model that generated the message.") temperature: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The temperature of the model that generated the message.") max_completion_tokens: Optional[StrictInt] = Field(default=None, description="The maximum number of tokens the model can generate.") - __properties: ClassVar[List[str]] = ["model", "temperature", "max_completion_tokens"] + top_p: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The top-p value of the model that generated the message.") + top_k: Optional[StrictInt] = Field(default=None, description="The top-k value of the model that generated the message.") + __properties: ClassVar[List[str]] = ["model", "temperature", "max_completion_tokens", "top_p", "top_k"] model_config = ConfigDict( populate_by_name=True, @@ -85,6 +87,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "model": obj.get("model"), "temperature": obj.get("temperature"), - "max_completion_tokens": obj.get("max_completion_tokens") + "max_completion_tokens": obj.get("max_completion_tokens"), + "top_p": obj.get("top_p"), + "top_k": obj.get("top_k") }) return _obj diff --git a/scaleapi/api_client/v2/models/project.py b/scaleapi/api_client/v2/models/project.py index 339841f..8a2aa0d 100644 --- a/scaleapi/api_client/v2/models/project.py +++ b/scaleapi/api_client/v2/models/project.py @@ -24,7 +24,7 @@ class Project(BaseModel): """ - Represents a project. + Project """ # noqa: E501 id: StrictStr = Field(description="A unique identifier for the project.") name: StrictStr = Field(description="The name of the project.") diff --git a/scaleapi/api_client/v2/models/reasoning.py b/scaleapi/api_client/v2/models/reasoning.py new file mode 100644 index 0000000..cbe7ffb --- /dev/null +++ b/scaleapi/api_client/v2/models/reasoning.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class Reasoning(BaseModel): + """ + The reasoning for the content of a message. + """ # noqa: E501 + content: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["content"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Reasoning from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Reasoning from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "content": obj.get("content") + }) + return _obj diff --git a/scaleapi/api_client/v2/models/sensitive_content_report.py b/scaleapi/api_client/v2/models/sensitive_content_report.py new file mode 100644 index 0000000..30adcdc --- /dev/null +++ b/scaleapi/api_client/v2/models/sensitive_content_report.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class SensitiveContentReport(BaseModel): + """ + SensitiveContentReport + """ # noqa: E501 + type: Optional[StrictStr] = None + message: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["type", "message"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of SensitiveContentReport from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of SensitiveContentReport from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "type": obj.get("type"), + "message": obj.get("message") + }) + return _obj diff --git a/scaleapi/api_client/v2/models/task.py b/scaleapi/api_client/v2/models/task.py index 47fba3a..4852d9d 100644 --- a/scaleapi/api_client/v2/models/task.py +++ b/scaleapi/api_client/v2/models/task.py @@ -23,6 +23,7 @@ from scaleapi.api_client.v2.models.error_detail import ErrorDetail from scaleapi.api_client.v2.models.expandable_batch import ExpandableBatch from scaleapi.api_client.v2.models.expandable_project import ExpandableProject +from scaleapi.api_client.v2.models.sensitive_content_report import SensitiveContentReport from scaleapi.api_client.v2.models.task_status import TaskStatus from scaleapi.api_client.v2.models.thread import Thread from typing import Optional, Set @@ -30,7 +31,7 @@ class Task(BaseModel): """ - Represents a single task + Task """ # noqa: E501 task_id: StrictStr = Field(description="Unique identifier for a task") project: ExpandableProject = Field(description="Project ID or [Project](/core-resources/project) associated with the task.") @@ -41,7 +42,8 @@ class Task(BaseModel): metadata: Optional[Dict[str, Any]] = Field(default=None, description="Task metadata defined during task creation.") threads: Optional[List[Thread]] = Field(default=None, description="Threads associated with the task. Tasks that do not have a `status` of `completed` will have an empty `threads` array.") errors: Optional[List[ErrorDetail]] = Field(default=None, description="Errors associated with the task. Available when the task status is `error`") - __properties: ClassVar[List[str]] = ["task_id", "project", "batch", "status", "created_at", "completed_at", "metadata", "threads", "errors"] + sensitive_content_reports: Optional[List[SensitiveContentReport]] = Field(default=None, description="Reports of sensitive content within the task. Available when the task status is `completed`. `threads` will not exist when the task is reported.") + __properties: ClassVar[List[str]] = ["task_id", "project", "batch", "status", "created_at", "completed_at", "metadata", "threads", "errors", "sensitive_content_reports"] model_config = ConfigDict( populate_by_name=True, @@ -103,6 +105,13 @@ def to_dict(self) -> Dict[str, Any]: if _item_errors: _items.append(_item_errors.to_dict()) _dict['errors'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in sensitive_content_reports (list) + _items = [] + if self.sensitive_content_reports: + for _item_sensitive_content_reports in self.sensitive_content_reports: + if _item_sensitive_content_reports: + _items.append(_item_sensitive_content_reports.to_dict()) + _dict['sensitive_content_reports'] = _items return _dict @classmethod @@ -123,6 +132,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "completed_at": obj.get("completed_at"), "metadata": obj.get("metadata"), "threads": [Thread.from_dict(_item) for _item in obj["threads"]] if obj.get("threads") is not None else None, - "errors": [ErrorDetail.from_dict(_item) for _item in obj["errors"]] if obj.get("errors") is not None else None + "errors": [ErrorDetail.from_dict(_item) for _item in obj["errors"]] if obj.get("errors") is not None else None, + "sensitive_content_reports": [SensitiveContentReport.from_dict(_item) for _item in obj["sensitive_content_reports"]] if obj.get("sensitive_content_reports") is not None else None }) return _obj diff --git a/scaleapi/api_client/v2/models/thread.py b/scaleapi/api_client/v2/models/thread.py index d194bf4..e95d2c1 100644 --- a/scaleapi/api_client/v2/models/thread.py +++ b/scaleapi/api_client/v2/models/thread.py @@ -27,7 +27,7 @@ class Thread(BaseModel): """ - Represents a thread of messages in a task. + Thread """ # noqa: E501 id: StrictStr = Field(description="Unique identifier for a thread") turns: List[Turn] = Field(description="[Turns](/core-resources/turn) within the thread. ") diff --git a/scaleapi/api_client/v2/models/workspace_container_config.py b/scaleapi/api_client/v2/models/workspace_container_config.py new file mode 100644 index 0000000..b2615e5 --- /dev/null +++ b/scaleapi/api_client/v2/models/workspace_container_config.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class WorkspaceContainerConfig(BaseModel): + """ + WorkspaceContainerConfig + """ # noqa: E501 + workspace_id: StrictStr = Field(description="ID of the workspace.") + workspace_url: StrictStr = Field(description="A URL string pointing to a resource.") + workspace_token: StrictStr = Field(description="Token of the workspace.") + expires_at: StrictStr = Field(description="Expiration time of the workspace.") + inactivity_freeze_time: StrictInt = Field(description="Inactivity freeze time of the workspace.") + force_enable_workspace_access: Optional[StrictBool] = Field(default=None, description="Force enable workspace access.") + workspace_image_version: Optional[StrictInt] = Field(default=None, description="Image version of the workspace.") + __properties: ClassVar[List[str]] = ["workspace_id", "workspace_url", "workspace_token", "expires_at", "inactivity_freeze_time", "force_enable_workspace_access", "workspace_image_version"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WorkspaceContainerConfig from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WorkspaceContainerConfig from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "workspace_id": obj.get("workspace_id"), + "workspace_url": obj.get("workspace_url"), + "workspace_token": obj.get("workspace_token"), + "expires_at": obj.get("expires_at"), + "inactivity_freeze_time": obj.get("inactivity_freeze_time"), + "force_enable_workspace_access": obj.get("force_enable_workspace_access"), + "workspace_image_version": obj.get("workspace_image_version") + }) + return _obj diff --git a/scaleapi/api_client/v2/models/workspace_container_value.py b/scaleapi/api_client/v2/models/workspace_container_value.py new file mode 100644 index 0000000..da97c2c --- /dev/null +++ b/scaleapi/api_client/v2/models/workspace_container_value.py @@ -0,0 +1,128 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from scaleapi.api_client.v2.models.content_and_url import ContentAndUrl +from scaleapi.api_client.v2.models.workspace_container_config import WorkspaceContainerConfig +from scaleapi.api_client.v2.models.workspace_file import WorkspaceFile +from typing import Optional, Set +from typing_extensions import Self + +class WorkspaceContainerValue(BaseModel): + """ + WorkspaceContainerValue + """ # noqa: E501 + workspace_id: Optional[StrictStr] = Field(default=None, description="ID of the workspace.") + workspace_config: Optional[WorkspaceContainerConfig] = None + last_code_run_event: Optional[Dict[str, Any]] = None + output_files: Optional[List[WorkspaceFile]] = None + stdout_output: Optional[ContentAndUrl] = Field(default=None, description="Standard output stream of the workspace.") + stderr_output: Optional[ContentAndUrl] = Field(default=None, description="Standard error stream of the workspace.") + test_stdout_output: Optional[ContentAndUrl] = Field(default=None, description="Standard output stream of the workspace for test cases.") + test_stderr_output: Optional[ContentAndUrl] = Field(default=None, description="Standard error stream of the workspace for test cases.") + __properties: ClassVar[List[str]] = ["workspace_id", "workspace_config", "last_code_run_event", "output_files", "stdout_output", "stderr_output", "test_stdout_output", "test_stderr_output"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WorkspaceContainerValue from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of workspace_config + if self.workspace_config: + _dict['workspace_config'] = self.workspace_config.to_dict() + # override the default output from pydantic by calling `to_dict()` of last_code_run_event + if self.last_code_run_event: + _dict['last_code_run_event'] = self.last_code_run_event.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in output_files (list) + _items = [] + if self.output_files: + for _item_output_files in self.output_files: + if _item_output_files: + _items.append(_item_output_files.to_dict()) + _dict['output_files'] = _items + # override the default output from pydantic by calling `to_dict()` of stdout_output + if self.stdout_output: + _dict['stdout_output'] = self.stdout_output.to_dict() + # override the default output from pydantic by calling `to_dict()` of stderr_output + if self.stderr_output: + _dict['stderr_output'] = self.stderr_output.to_dict() + # override the default output from pydantic by calling `to_dict()` of test_stdout_output + if self.test_stdout_output: + _dict['test_stdout_output'] = self.test_stdout_output.to_dict() + # override the default output from pydantic by calling `to_dict()` of test_stderr_output + if self.test_stderr_output: + _dict['test_stderr_output'] = self.test_stderr_output.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WorkspaceContainerValue from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "workspace_id": obj.get("workspace_id"), + "workspace_config": WorkspaceContainerConfig.from_dict(obj["workspace_config"]) if obj.get("workspace_config") is not None else None, + "last_code_run_event": WorkspaceExecutionData.from_dict(obj["last_code_run_event"]) if obj.get("last_code_run_event") is not None else None, + "output_files": [WorkspaceFile.from_dict(_item) for _item in obj["output_files"]] if obj.get("output_files") is not None else None, + "stdout_output": ContentAndUrl.from_dict(obj["stdout_output"]) if obj.get("stdout_output") is not None else None, + "stderr_output": ContentAndUrl.from_dict(obj["stderr_output"]) if obj.get("stderr_output") is not None else None, + "test_stdout_output": ContentAndUrl.from_dict(obj["test_stdout_output"]) if obj.get("test_stdout_output") is not None else None, + "test_stderr_output": ContentAndUrl.from_dict(obj["test_stderr_output"]) if obj.get("test_stderr_output") is not None else None + }) + return _obj diff --git a/scaleapi/api_client/v2/models/workspace_execution_data.py b/scaleapi/api_client/v2/models/workspace_execution_data.py new file mode 100644 index 0000000..300eb5c --- /dev/null +++ b/scaleapi/api_client/v2/models/workspace_execution_data.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from scaleapi.api_client.v2.models.workspace_execution_data_result import WorkspaceExecutionDataResult +from typing import Optional, Set +from typing_extensions import Self + +class WorkspaceExecutionData(BaseModel): + """ + WorkspaceExecutionData + """ # noqa: E501 + id: Optional[StrictStr] = Field(default=None, description="ID of the workspace.") + result: Optional[WorkspaceExecutionDataResult] = None + __properties: ClassVar[List[str]] = ["id", "result"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WorkspaceExecutionData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of result + if self.result: + _dict['result'] = self.result.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WorkspaceExecutionData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "result": WorkspaceExecutionDataResult.from_dict(obj["result"]) if obj.get("result") is not None else None + }) + return _obj diff --git a/scaleapi/api_client/v2/models/workspace_execution_data_result.py b/scaleapi/api_client/v2/models/workspace_execution_data_result.py new file mode 100644 index 0000000..457978b --- /dev/null +++ b/scaleapi/api_client/v2/models/workspace_execution_data_result.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from scaleapi.api_client.v2.models.workspace_execution_data_result_status import WorkspaceExecutionDataResultStatus +from typing import Optional, Set +from typing_extensions import Self + +class WorkspaceExecutionDataResult(BaseModel): + """ + WorkspaceExecutionDataResult + """ # noqa: E501 + status: Optional[WorkspaceExecutionDataResultStatus] = None + time: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Time taken for last execution.") + score: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Score of the output of last execution.") + __properties: ClassVar[List[str]] = ["status", "time", "score"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WorkspaceExecutionDataResult from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of status + if self.status: + _dict['status'] = self.status.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WorkspaceExecutionDataResult from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "status": WorkspaceExecutionDataResultStatus.from_dict(obj["status"]) if obj.get("status") is not None else None, + "time": obj.get("time"), + "score": obj.get("score") + }) + return _obj diff --git a/scaleapi/api_client/v2/models/workspace_execution_data_result_status.py b/scaleapi/api_client/v2/models/workspace_execution_data_result_status.py new file mode 100644 index 0000000..4dec1b2 --- /dev/null +++ b/scaleapi/api_client/v2/models/workspace_execution_data_result_status.py @@ -0,0 +1,88 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + +class WorkspaceExecutionDataResultStatus(BaseModel): + """ + WorkspaceExecutionDataResultStatus + """ # noqa: E501 + code: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Status code of the workspace execution.") + name: Optional[StrictStr] = Field(default=None, description="Execution full status.") + __properties: ClassVar[List[str]] = ["code", "name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WorkspaceExecutionDataResultStatus from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WorkspaceExecutionDataResultStatus from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "code": obj.get("code"), + "name": obj.get("name") + }) + return _obj diff --git a/scaleapi/api_client/v2/models/workspace_file.py b/scaleapi/api_client/v2/models/workspace_file.py new file mode 100644 index 0000000..3121ba1 --- /dev/null +++ b/scaleapi/api_client/v2/models/workspace_file.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + GenAI API Spec + + Data Engine: Generative AI API Specification + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class WorkspaceFile(BaseModel): + """ + WorkspaceFile + """ # noqa: E501 + file_name: Optional[StrictStr] = Field(default=None, description="File name") + scale_url: StrictStr = Field(description="A URL string pointing to a resource.") + url: Optional[StrictStr] = Field(default=None, description="A URL string pointing to a resource.") + file_language: Optional[StrictStr] = Field(default=None, description="Coding language of the file.") + file_content: Optional[StrictStr] = Field(default=None, description="Content of the file.") + __properties: ClassVar[List[str]] = ["file_name", "scale_url", "url", "file_language", "file_content"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + excluded_fields: Set[str] = set([ + ]) + return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of WorkspaceFile from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WorkspaceFile from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "file_name": obj.get("file_name"), + "scale_url": obj.get("scale_url"), + "url": obj.get("url"), + "file_language": obj.get("file_language"), + "file_content": obj.get("file_content") + }) + return _obj From a5b778b2152b041f9a1eb70c5adb2dafcae447dc Mon Sep 17 00:00:00 2001 From: Michael Bishoff Date: Wed, 4 Jun 2025 18:31:03 -0700 Subject: [PATCH 2/2] rm deleted file & update version --- scaleapi/_version.py | 2 +- scaleapi/api_client/v2/models/file.py | 92 --------------------------- 2 files changed, 1 insertion(+), 93 deletions(-) delete mode 100644 scaleapi/api_client/v2/models/file.py diff --git a/scaleapi/_version.py b/scaleapi/_version.py index 8852777..bc13e9b 100644 --- a/scaleapi/_version.py +++ b/scaleapi/_version.py @@ -1,2 +1,2 @@ -__version__ = "2.16.0" +__version__ = "2.17.0" __package_name__ = "scaleapi" diff --git a/scaleapi/api_client/v2/models/file.py b/scaleapi/api_client/v2/models/file.py deleted file mode 100644 index bfb8a99..0000000 --- a/scaleapi/api_client/v2/models/file.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding: utf-8 - -""" - GenAI API Spec - - Data Engine: Generative AI API Specification - - The version of the OpenAPI document: 0.0.1 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, Field, StrictBytes, StrictStr -from typing import Any, ClassVar, Dict, List, Optional, Union -from typing import Optional, Set -from typing_extensions import Self - -class File(BaseModel): - """ - File - """ # noqa: E501 - content: Optional[Union[StrictBytes, StrictStr]] = Field(default=None, description="Base-64 encoded data") - mime_type: Optional[StrictStr] = Field(default=None, description="The MIME type of the content, such as application/json or image/png.") - scale_url: Optional[StrictStr] = Field(default=None, description="A URL string pointing to a resource.") - url: Optional[StrictStr] = Field(default=None, description="A URL string pointing to a resource.") - __properties: ClassVar[List[str]] = ["content", "mime_type", "scale_url", "url"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - excluded_fields: Set[str] = set([ - ]) - return self.model_dump_json(by_alias=True, exclude_unset=True, exclude=excluded_fields) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of File from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of File from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "content": obj.get("content"), - "mime_type": obj.get("mime_type"), - "scale_url": obj.get("scale_url"), - "url": obj.get("url") - }) - return _obj