From 411d83f2da5913573e8e09c281a5dfb949670bf9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 03:35:02 +0000 Subject: [PATCH 1/6] feat(api): added latest OpenAPI specification (#29) --- .stats.yml | 2 +- README.md | 7 ++++-- .../resources/classifications/universal.py | 22 ++++++++++--------- .../universal_create_params.py | 13 ++++++----- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.stats.yml b/.stats.yml index 594d327..e2eefb1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/isaacus%2Fisaacus-472ef5f1174bab055fd83756f45445b5c0f1f3f442c531dfc275ea895ec229a7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/isaacus%2Fisaacus-ec269bff43481aeb5c72d3074aa31815ef915d435e78bc62b0290437a7b2992a.yml diff --git a/README.md b/README.md index 3360d06..664f0af 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,13 @@ The REST API documentation can be found on [docs.isaacus.com](https://docs.isaac ## Installation ```sh -# install from PyPI -pip install isaacus +# install from the production repo +pip install git+ssh://git@github.com/isaacus-dev/isaacus-python.git ``` +> [!NOTE] +> Once this package is [published to PyPI](https://app.stainless.com/docs/guides/publish), this will become: `pip install isaacus` + ## Usage The full API of this library can be found in [api.md](api.md). diff --git a/src/isaacus/resources/classifications/universal.py b/src/isaacus/resources/classifications/universal.py index b7445e8..99a39c1 100644 --- a/src/isaacus/resources/classifications/universal.py +++ b/src/isaacus/resources/classifications/universal.py @@ -68,10 +68,11 @@ def create( legal AI classifier. Args: - model: The ID of the model to use for universal classification. + model: The ID of the [model](https://docs.isaacus.com/models#universal-classification) + to use for universal classification. - query: The Isaacus Query Language (IQL) query or, if IQL is disabled, the statement, to - evaluate the text against. + query: The [Isaacus Query Language (IQL)](https://docs.isaacus.com/iql) query or, if + IQL is disabled, the statement, to evaluate the text against. The query must contain at least one non-whitespace character. @@ -84,8 +85,8 @@ def create( chunking_options: Options for how to split text into smaller chunks. - is_iql: Whether the query should be interpreted as an Isaacus Query Language (IQL) query - or else as a statement. + is_iql: Whether the query should be interpreted as an + [IQL](https://docs.isaacus.com/iql) query or else as a statement. scoring_method: The method to use for producing an overall confidence score. @@ -168,10 +169,11 @@ async def create( legal AI classifier. Args: - model: The ID of the model to use for universal classification. + model: The ID of the [model](https://docs.isaacus.com/models#universal-classification) + to use for universal classification. - query: The Isaacus Query Language (IQL) query or, if IQL is disabled, the statement, to - evaluate the text against. + query: The [Isaacus Query Language (IQL)](https://docs.isaacus.com/iql) query or, if + IQL is disabled, the statement, to evaluate the text against. The query must contain at least one non-whitespace character. @@ -184,8 +186,8 @@ async def create( chunking_options: Options for how to split text into smaller chunks. - is_iql: Whether the query should be interpreted as an Isaacus Query Language (IQL) query - or else as a statement. + is_iql: Whether the query should be interpreted as an + [IQL](https://docs.isaacus.com/iql) query or else as a statement. scoring_method: The method to use for producing an overall confidence score. diff --git a/src/isaacus/types/classifications/universal_create_params.py b/src/isaacus/types/classifications/universal_create_params.py index 63fa143..ae0e53c 100644 --- a/src/isaacus/types/classifications/universal_create_params.py +++ b/src/isaacus/types/classifications/universal_create_params.py @@ -10,12 +10,15 @@ class UniversalCreateParams(TypedDict, total=False): model: Required[Literal["kanon-universal-classifier", "kanon-universal-classifier-mini"]] - """The ID of the model to use for universal classification.""" + """ + The ID of the [model](https://docs.isaacus.com/models#universal-classification) + to use for universal classification. + """ query: Required[str] """ - The Isaacus Query Language (IQL) query or, if IQL is disabled, the statement, to - evaluate the text against. + The [Isaacus Query Language (IQL)](https://docs.isaacus.com/iql) query or, if + IQL is disabled, the statement, to evaluate the text against. The query must contain at least one non-whitespace character. @@ -34,8 +37,8 @@ class UniversalCreateParams(TypedDict, total=False): is_iql: bool """ - Whether the query should be interpreted as an Isaacus Query Language (IQL) query - or else as a statement. + Whether the query should be interpreted as an + [IQL](https://docs.isaacus.com/iql) query or else as a statement. """ scoring_method: Literal["auto", "chunk_max", "chunk_avg", "chunk_min"] From 371c2490695cd773b8202c8cd016360535609923 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 03:42:43 +0000 Subject: [PATCH 2/6] chore(internal): bump rye to 0.44.0 (#31) --- .devcontainer/Dockerfile | 2 +- .github/workflows/ci.yml | 4 ++-- .github/workflows/publish-pypi.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 55d2025..ff261ba 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,7 +3,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} USER vscode -RUN curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.35.0" RYE_INSTALL_OPTION="--yes" bash +RUN curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.44.0" RYE_INSTALL_OPTION="--yes" bash ENV PATH=/home/vscode/.rye/shims:$PATH RUN echo "[[ -d .venv ]] && source .venv/bin/activate || export PATH=\$PATH" >> /home/vscode/.bashrc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8a8a4f..3b286e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: curl -sSf https://rye.astral.sh/get | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: - RYE_VERSION: '0.35.0' + RYE_VERSION: '0.44.0' RYE_INSTALL_OPTION: '--yes' - name: Install dependencies @@ -42,7 +42,7 @@ jobs: curl -sSf https://rye.astral.sh/get | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: - RYE_VERSION: '0.35.0' + RYE_VERSION: '0.44.0' RYE_INSTALL_OPTION: '--yes' - name: Bootstrap diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 31d3cc0..04538cd 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -21,7 +21,7 @@ jobs: curl -sSf https://rye.astral.sh/get | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: - RYE_VERSION: '0.35.0' + RYE_VERSION: '0.44.0' RYE_INSTALL_OPTION: '--yes' - name: Publish to PyPI From 0644ad39f602b43ee03e4eb4ec58b05cb5ff28aa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 03:50:55 +0000 Subject: [PATCH 3/6] fix(types): handle more discriminated union shapes (#32) --- src/isaacus/_models.py | 7 +++++-- tests/test_models.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/isaacus/_models.py b/src/isaacus/_models.py index c4401ff..b51a1bf 100644 --- a/src/isaacus/_models.py +++ b/src/isaacus/_models.py @@ -65,7 +65,7 @@ from ._constants import RAW_RESPONSE_HEADER if TYPE_CHECKING: - from pydantic_core.core_schema import ModelField, LiteralSchema, ModelFieldsSchema + from pydantic_core.core_schema import ModelField, ModelSchema, LiteralSchema, ModelFieldsSchema __all__ = ["BaseModel", "GenericModel"] @@ -646,15 +646,18 @@ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, def _extract_field_schema_pv2(model: type[BaseModel], field_name: str) -> ModelField | None: schema = model.__pydantic_core_schema__ + if schema["type"] == "definitions": + schema = schema["schema"] + if schema["type"] != "model": return None + schema = cast("ModelSchema", schema) fields_schema = schema["schema"] if fields_schema["type"] != "model-fields": return None fields_schema = cast("ModelFieldsSchema", fields_schema) - field = fields_schema["fields"].get(field_name) if not field: return None diff --git a/tests/test_models.py b/tests/test_models.py index 93fe989..f465b46 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -854,3 +854,35 @@ class Model(BaseModel): m = construct_type(value={"cls": "foo"}, type_=Model) assert isinstance(m, Model) assert isinstance(m.cls, str) + + +def test_discriminated_union_case() -> None: + class A(BaseModel): + type: Literal["a"] + + data: bool + + class B(BaseModel): + type: Literal["b"] + + data: List[Union[A, object]] + + class ModelA(BaseModel): + type: Literal["modelA"] + + data: int + + class ModelB(BaseModel): + type: Literal["modelB"] + + required: str + + data: Union[A, B] + + # when constructing ModelA | ModelB, value data doesn't match ModelB exactly - missing `required` + m = construct_type( + value={"type": "modelB", "data": {"type": "a", "data": True}}, + type_=cast(Any, Annotated[Union[ModelA, ModelB], PropertyInfo(discriminator="type")]), + ) + + assert isinstance(m, ModelB) From b053a4a60f48d9d3197d384fe6e3a57723216ac9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 04:21:13 +0000 Subject: [PATCH 4/6] feat(api): added latest OpenAPI specification (#33) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 664f0af..001ecb2 100644 --- a/README.md +++ b/README.md @@ -99,11 +99,11 @@ universal_classification = client.classifications.universal.create( text="I agree not to tell anyone about the document.", chunking_options={ "overlap_ratio": 0.1, - "overlap_tokens": 0, + "overlap_tokens": None, "size": 512, }, ) -print(universal_classification.chunking_options) +print(universal_classification.chunks) ``` ## Handling errors From d9aef7fa1d6f5283bdd3afd1962f52d2ed072499 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 04:25:00 +0000 Subject: [PATCH 5/6] feat(api): added latest OpenAPI specification (#34) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 001ecb2..4a45ef3 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ universal_classification = client.classifications.universal.create( "size": 512, }, ) -print(universal_classification.chunks) +print(universal_classification.chunking_options) ``` ## Handling errors From 475e4394dc3b8d9a7f3e56665cbbeb1fddc894aa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 04:25:17 +0000 Subject: [PATCH 6/6] release: 0.1.4 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 20 ++++++++++++++++++++ pyproject.toml | 2 +- src/isaacus/_version.py | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 4c5a1a0..a43290c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.3" + ".": "0.1.4" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 37cacb1..09aed18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Changelog +## 0.1.4 (2025-03-15) + +Full Changelog: [v0.1.3...v0.1.4](https://github.com/isaacus-dev/isaacus-python/compare/v0.1.3...v0.1.4) + +### Features + +* **api:** added latest OpenAPI specification ([#29](https://github.com/isaacus-dev/isaacus-python/issues/29)) ([411d83f](https://github.com/isaacus-dev/isaacus-python/commit/411d83f2da5913573e8e09c281a5dfb949670bf9)) +* **api:** added latest OpenAPI specification ([#33](https://github.com/isaacus-dev/isaacus-python/issues/33)) ([b053a4a](https://github.com/isaacus-dev/isaacus-python/commit/b053a4a60f48d9d3197d384fe6e3a57723216ac9)) +* **api:** added latest OpenAPI specification ([#34](https://github.com/isaacus-dev/isaacus-python/issues/34)) ([d9aef7f](https://github.com/isaacus-dev/isaacus-python/commit/d9aef7fa1d6f5283bdd3afd1962f52d2ed072499)) + + +### Bug Fixes + +* **types:** handle more discriminated union shapes ([#32](https://github.com/isaacus-dev/isaacus-python/issues/32)) ([0644ad3](https://github.com/isaacus-dev/isaacus-python/commit/0644ad39f602b43ee03e4eb4ec58b05cb5ff28aa)) + + +### Chores + +* **internal:** bump rye to 0.44.0 ([#31](https://github.com/isaacus-dev/isaacus-python/issues/31)) ([371c249](https://github.com/isaacus-dev/isaacus-python/commit/371c2490695cd773b8202c8cd016360535609923)) + ## 0.1.3 (2025-03-15) Full Changelog: [v0.1.2...v0.1.3](https://github.com/isaacus-dev/isaacus-python/compare/v0.1.2...v0.1.3) diff --git a/pyproject.toml b/pyproject.toml index b4d77c6..5e2ba95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "isaacus" -version = "0.1.3" +version = "0.1.4" description = "The official Python library for the isaacus API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/isaacus/_version.py b/src/isaacus/_version.py index 847a056..594099b 100644 --- a/src/isaacus/_version.py +++ b/src/isaacus/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "isaacus" -__version__ = "0.1.3" # x-release-please-version +__version__ = "0.1.4" # x-release-please-version