Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.3"
".": "0.1.4"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -96,7 +99,7 @@ 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,
},
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
7 changes: 5 additions & 2 deletions src/isaacus/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/isaacus/_version.py
Original file line number Diff line number Diff line change
@@ -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
22 changes: 12 additions & 10 deletions src/isaacus/resources/classifications/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.

Expand Down Expand Up @@ -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.

Expand All @@ -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.

Expand Down
13 changes: 8 additions & 5 deletions src/isaacus/types/classifications/universal_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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"]
Expand Down
32 changes: 32 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)