-
Notifications
You must be signed in to change notification settings - Fork 60
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
feat: allow optional lists and maps #1251
feat: allow optional lists and maps #1251
Conversation
Resolves BoundaryML#948 - Added support for optional arrays with string[]? syntax\n- Added support for optional maps with map<string, int>? syntax\n- Updated JSON schema generation for optional types\n- Added comprehensive test cases
@revidious is attempting to deploy a commit to the Gloo Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Reviewed everything up to 8a31ab9 in 20 seconds
More details
- Looked at
306
lines of code in3
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. engine/baml-lib/baml-core/src/ir/json_schema.rs:235
- Draft comment:
Therequired
field is being populated with optional fields instead of required ones. It should be populated with fields that are not optional.
if let FieldType::Optional(_) = t {
// Do nothing for optional fields
} else {
required_props.push(name.clone());
}
- Reason this comment was not posted:
Comment was not on a valid diff hunk.
Workflow ID: wflow_hG9ygX9vO60xfENi
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
nice work on all these PRs! This one LGTM, will ping someone else on the team to also take a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@revidious LGTM! I made some changes to your PR, mainly removed the "Maps/Lists are not allowed to be optional"
error, added validation and integ tests for the new feature and then I made some changes to the spelling in the docs you wrote because it looks like you used some kind of automatic spell-checker that messes up the punctuation and capitalization.
Allow optional lists and maps
Resolves #948
Description
This PR adds support for optional lists and maps in BAML, allowing users to declare properties like
string[]?
andmap<string, int>?
. Previously these types were not supported, and the parser would coerce unset parameters into empty lists/maps.Changes
parse_types.rs
):string[]?
syntaxmap<string, int>?
json_schema.rs
)[\"array\", \"null\"]
, or[\"object\",\"null\"]
)datamodel.pest
):Example Usage
Testing
Important
Adds support for optional lists and maps in BAML, updating parser, JSON schema generation, and grammar to handle
string[]?
andmap<string, int>?
syntax.parse_types.rs
usingstring[]?
andmap<string, int>?
syntax.FieldArity
accordingly.json_schema.rs
updated to handle optional arrays and maps, allowingnull
values.datamodel.pest
to allow optional token for arrays and maps.parse_types.rs
to verify correct parsing and schema generation.This description was created by for 8a31ab9. It will automatically update as commits are pushed.