-
Notifications
You must be signed in to change notification settings - Fork 80
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
WIP: Add support for int keys in maps #1180
Draft
antoniosarosi
wants to merge
8
commits into
canary
Choose a base branch
from
antonio/int-keys-in-map
base: canary
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
github-merge-queue bot
pushed a commit
that referenced
this pull request
Nov 19, 2024
Issue #1050 Added support for enums and literal strings in map keys: ```baml enum MapKey { A B C } class Fields { // Enum as key e map<MapKey, string> // Single literal as key l1 map<"literal", string> // Union of literals as keys l2 map<"one" | "two" | ("three" | "four"), string> } ``` Literal integers are more complicated since they require maps to support int keys. See #1180. <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Add support for enums and literal strings as map keys in BAML, with updated validation, coercion logic, and tests. > > - **Behavior**: > - Support for enums and literal strings as map keys added in `mod.rs` and `types.rs`. > - Validation logic updated to allow enums and literal strings as map keys. > - Coercion logic updated to handle enums and literal strings as map keys. > - **Tests**: > - Added tests in `map_enums_and_literals.baml` and `map_types.baml` to verify new map key functionality. > - Updated `test_functions.py` and `integ-tests.test.ts` to include cases for enum and literal string map keys. > - **Misc**: > - Updated error messages in `error.rs` to reflect new map key types. > - Minor updates in `async_client.py`, `sync_client.py`, and `client.rb` to support new map key types. > > <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 c7742fd. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WIP, some ideas to implement int keys:
BamlValue::Map
.BamlMapKey
enum everywhere.The FFI code that converts
BamlValue
back to Python or other targets needs the informationabout the type of the key, which is not currently provided by
BamlValue::Map
. But thenBamlValue::Map
is also used for converting JSONs from LLMs into classes or similar operations, basically the runtime is designed around maps supporting string keys only.