Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump version 0.72.1 #1335

Draft
wants to merge 2 commits into
base: canary
Choose a base branch
from
Draft

Bump version 0.72.1 #1335

wants to merge 2 commits into from

Conversation

imalsogreg
Copy link
Contributor

@imalsogreg imalsogreg commented Jan 15, 2025

For patch release only. Do not merge.

Copy link

vercel bot commented Jan 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
baml ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 8:49pm

Fixes an issue with streaming for classes containing literal types.
During streaming there may not be enough tokens to satisfy a field's
literal value. In that case, the field should be `null`, and this should
be acceptable for the partial type.

The old generated `partial_types.py` does not allow the field to be null
however, so pydantic validation fails to create a
`partial_types.ClassForNullLiteral`:
```
class ClassForNullLiteral(BaseModel):
    a: Literal["hi"] = None
```

The new generated `partial_types.py` after this PR allows literal fields
to be null:
```
class ClassForNullLiteral(BaseModel):
    a: Optional[Literal["hi"]] = None
```

PR adds one parser test and one integ test.
<!-- ELLIPSIS_HIDDEN -->

----

> [!IMPORTANT]
> This PR allows literal fields in generated Python code to be nullable,
updating code generation and adding tests to ensure correct handling of
null literals.
>
>   - **Behavior**:
> - Allows literal fields to be nullable in `partial_types.py` by
changing `a: Literal["hi"] = None` to `a: Optional[Literal["hi"]] =
None`.
> - Updates `BamlSyncClient` and `BamlAsyncClient` to handle nullable
literals in `sync_client.ts` and `async_client.ts`.
>   - **Code Generation**:
>     - Modifies `generate_types.rs` to wrap literals with `Optional[]`.
>     - Updates `mod.rs` to reflect changes in literal handling.
>   - **Testing**:
> - Adds `test_partial_class_with_null_literal` in `test_literals.rs`.
>     - Introduces `literal-or-null.baml` for integration testing.
>     - Adds `test_null_literal_class_hello` in `test_functions.py`.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup>
for 910ab4b. It will automatically
update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->

bump changelog

Bump generated code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant