-
Notifications
You must be signed in to change notification settings - Fork 39
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: Add constraints via Jinja expressions #1006
base: canary
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
bfcb239
to
0e483ac
Compare
0e483ac
to
6e4c75a
Compare
803cec8
to
74fd792
Compare
537e0df
to
2898a39
Compare
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 2898a39 in 3 minutes and 9 seconds
More details
- Looked at
8495
lines of code in121
files - Skipped
1
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/types.rs:87
- Draft comment:
Consider handling errors invalidate_type_constraints
more gracefully instead of panicking. Provide a meaningful error message to the user if a constraint is not well-formed. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable:
The comment seems to be suggesting an improvement that is already implemented. The function usesctx.push_error
to handle errors, which is a standard way to report issues without panicking. The comment does not provide strong evidence of an issue that needs addressing.
I might be missing some context about how errors are handled in the broader system. Perhaps the comment is suggesting a different kind of error handling that is not evident from the code alone.
The code clearly shows that errors are being handled by pushing them to the context, which is a common pattern for non-panicking error handling. Without additional context, the comment seems unnecessary.
The comment should be deleted as it suggests an improvement that is already implemented in the code.
Workflow ID: wflow_yxofyQgVkFL7G1Cc
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
15a5b5c
to
82a19f0
Compare
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! Incremental review on 82a19f0 in 2 minutes and 49 seconds
More details
- Looked at
8722
lines of code in124
files - Skipped
1
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. engine/baml-lib/baml-core/src/ir/ir_helpers/to_baml_arg.rs:343
- Draft comment:
Consider handling the error explicitly instead of usingunwrap_or_else
inevaluate_predicate
to avoid unexpected behavior. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable:
The use ofunwrap_or_else
is a common pattern in Rust for handling errors in a concise way. The current implementation pushes an error message to the scope, which seems to be an appropriate way to handle errors in this context. The comment suggests an alternative approach but does not provide strong evidence that the current approach is incorrect or causes unexpected behavior.
The comment does not provide specific reasons why the current use ofunwrap_or_else
would lead to unexpected behavior. It is more of a suggestion than a necessary change.
While the comment suggests an alternative, it does not demonstrate that the current implementation is problematic. Without evidence of an issue, the comment may not be necessary.
The comment is more of a suggestion than a necessary change, and there is no strong evidence that the current implementation is incorrect. Therefore, the comment should be deleted.
2. engine/baml-lib/baml-core/src/ir/ir_helpers/to_baml_arg.rs:340
- Draft comment:
Consider handling the error explicitly instead of usingunwrap_or_else
to avoid unexpected behavior. - Reason this comment was not posted:
Marked as duplicate.
Workflow ID: wflow_gHUOxKuHoqrWS0ME
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
82a19f0
to
5ada779
Compare
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! Incremental review on 8320347 in 1 minute and 12 seconds
More details
- Looked at
34
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. engine/language_client_codegen/src/ruby/generate_types.rs:175
- Draft comment:
Ensure that the removal ofchecks_type_ref
from theformat!
function is consistent with the intended functionality ofBaml::Checked
. Verify thatBaml::Checked
is designed to only takebase_type_ref
. - Reason this comment was not posted:
Comment did not seem useful.
Workflow ID: wflow_VBsSSWl6hKXQCcmF
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
|
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! Incremental review on edd98f8 in 1 minute and 13 seconds
More details
- Looked at
502
lines of code in20
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. integ-tests/typescript/baml_client/types.ts:265
- Draft comment:
The order of the literals in theChecked
type forspecies
has been changed. Ensure that this change is intentional and does not affect any logic that depends on the order of these literals. - Reason this comment was not posted:
Confidence changes required:50%
The test report indicates that all tests have passed, which is a good sign. However, the code changes should still be reviewed for potential issues.
Workflow ID: wflow_rWGLfcLI7GSFcpTW
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
edd98f8
to
c04aa26
Compare
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! Incremental review on c04aa26 in 2 minutes and 42 seconds
More details
- Looked at
9636
lines of code in127
files - Skipped
1
files when reviewing. - Skipped posting
3
drafted comments based on config settings.
1. engine/baml-lib/baml-core/src/ir/jinja_helpers.rs:13
- Draft comment:
Consider logging or handling the error when regex compilation fails inregex_match
to provide more context for debugging. - Reason this comment was not posted:
Confidence changes required:50%
The functionregex_match
injinja_helpers.rs
returns false if the regex compilation fails. It would be better to log or handle this error to provide more context for debugging.
2. engine/baml-lib/baml-core/src/ir/jinja_helpers.rs:14
- Draft comment:
Consider logging or handling the error fromRegex::new
instead of returningfalse
, to avoid silently ignoring regex compilation errors. - Reason this comment was not posted:
Confidence changes required:50%
The functionregex_match
injinja_helpers.rs
does not handle errors fromRegex::new
properly. It returnsfalse
on error, which might hide issues. It should log or handle the error appropriately.
3. engine/baml-lib/baml-core/src/ir/jinja_helpers.rs:15
- Draft comment:
Consider logging or handling the regex compilation error instead of silently returning false. - Reason this comment was not posted:
Confidence changes required:50%
The functionregex_match
injinja_helpers.rs
returns false if the regex compilation fails. It might be more informative to log or handle this error differently.
Workflow ID: wflow_fCgKpMEyC64QxDxr
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
c04aa26
to
508703e
Compare
508703e
to
fa53e49
Compare
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! Incremental review on 508703e in 1 minute and 17 seconds
More details
- Looked at
62
lines of code in4
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. engine/language_client_codegen/src/python/generate_types.rs:172
- Draft comment:
The use ofsorted()
here may not be necessary and could alter the intended order of checks. Consider removing it if order matters. - Reason this comment was not posted:
Confidence changes required:50%
The use ofsorted()
in thetype_name_for_checks
function is unnecessary since the order of checks might be intentional and should be preserved.
2. engine/language_client_codegen/src/typescript/generate_types.rs:128
- Draft comment:
The use ofsorted()
here may not be necessary and could alter the intended order of checks. Consider removing it if order matters. - Reason this comment was not posted:
Confidence changes required:50%
The use ofsorted()
in thetype_name_for_checks
function is unnecessary since the order of checks might be intentional and should be preserved.
Workflow ID: wflow_g2nkzvVNfT2STDtw
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
❌ Changes requested. Incremental review on fa53e49 in 2 minutes and 55 seconds
More details
- Looked at
9578
lines of code in126
files - Skipped
1
files when reviewing. - Skipped posting
3
drafted comments based on config settings.
1. engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:185
- Draft comment:
Consider usingResult::Err
with a custom error type instead ofanyhow::bail!
for better performance, asanyhow::bail!
captures a backtrace which can be expensive. - Reason this comment was not posted:
Confidence changes required:50%
The use ofanyhow::bail!
andanyhow::anyhow!
for error handling is not ideal for performance. These macros can be expensive because they capture a backtrace. It's better to useResult::Err
with a custom error type when performance is a concern.
2. engine/baml-lib/baml-core/src/ir/jinja_helpers.rs:15
- Draft comment:
Consider returning an error instead of false when regex compilation fails to avoid silently ignoring issues. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable:
The comment is suggesting a change in error handling strategy, which is a valid code quality improvement. Returning an error instead of false would make the function's behavior more explicit and prevent silent failures. This is a clear and actionable suggestion.
The current implementation might be intentionally designed to return false on error to simplify usage. Without more context on how this function is used, it's hard to say if changing the error handling is appropriate.
Even if the current design is intentional, the suggestion to handle errors explicitly is a common best practice and could improve code robustness.
The comment is a valid suggestion for improving error handling in theregex_match
function. It should be kept as it proposes a clear and actionable code quality improvement.
3. engine/baml-lib/baml-core/src/ir/jinja_helpers.rs:33
- Draft comment:
Remove theeprintln!
statement or replace it with a proper logging mechanism. - Reason this comment was not posted:
Marked as duplicate.
Workflow ID: wflow_thp3vrb5WlJ3JqFn
Want Ellipsis to fix these issues? Tag @ellipsis-dev
in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
} | ||
|
||
// TODO: (Greg) better error handling. | ||
// TODO: (Greg) Upstream, typecheck the expression. |
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.
Remove the eprintln!
statement or replace it with proper logging.
Important
This PR adds support for constraints using Jinja expressions, updates models and validation logic, and enhances testing to ensure constraint functionality across the codebase.
baml-core
.evaluate_predicate
ininternal_baml_jinja
for constraint evaluation.FieldType
to supportConstrained
type with constraints.Constraint
andConstraintLevel
inbaml-types
.NodeAttributes
to include constraints.validation_pipeline
.test_constraints.rs
.itertools
dependency inCargo.lock
.shell.nix
to include necessary tools for development.This description was created by for fa53e49. It will automatically update as commits are pushed.