-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I got something that *compiles* and parses literals into the AST. Lots of `todo!()`s left. <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Implement literal types in the codebase, including coercion, validation, and code generation updates for Python, Ruby, and TypeScript. > > - **Behavior**: > - Implement literal types in `FieldType` and `LiteralValue` enums. > - Add coercion logic for literals in `coerce_literal.rs`. > - Update `to_baml_arg.rs` to handle literal values. > - Modify `json_schema.rs` to support literal types in JSON schema. > - Update `repr.rs` to include literal types in representation. > - **Validation**: > - Add validation for literal types in `types.rs`. > - Introduce tests for literals in `test_literals.rs`. > - **Code Generation**: > - Update Python, Ruby, and TypeScript code generation to support literals. > - Modify OpenAPI generation to include literal types. > - **Misc**: > - Add new test files for validation of literal types. > - Update existing test files to include literal type scenarios. > > <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 a14b308. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN --> --------- Co-authored-by: Greg Hale <imalsogreg@gmail.com> Co-authored-by: Vaibhav Gupta <vbv@boundaryml.com>
- Loading branch information
1 parent
d0cdf90
commit 9e7431f
Showing
62 changed files
with
859 additions
and
274 deletions.
There are no files selected for viewing
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
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
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
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
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
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
9 changes: 9 additions & 0 deletions
9
engine/baml-lib/baml/tests/validation_files/class/literal_types.baml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class TestLiterals { | ||
a "SingleLiteral" | ||
b "Field" | "With" | "Multiple" | "Literals" | ||
c "Field" | "With" | "Some" @description("Description") | ||
d 2 | 3 | ||
e "Optional"? | ||
f 2 | "SomeString" | ||
g "boolean" | true | false | ||
} |
17 changes: 17 additions & 0 deletions
17
engine/baml-lib/baml/tests/validation_files/class/misspeled_boolean_literals.baml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class TestLiterals { | ||
a "SingleLiteral" | ||
b "boolean" | True | False | ||
} | ||
|
||
// error: Type `True` does not exist. Did you mean one of these: `true`, `string`, `int`, `bool`, `false`, `float`, `TestLiterals`? | ||
// --> class/misspeled_boolean_literals.baml:3 | ||
// | | ||
// 2 | a "SingleLiteral" | ||
// 3 | b "boolean" | True | False | ||
// | | ||
// error: Type `False` does not exist. Did you mean one of these: `false`, `float`, `true`, `int`, `bool`, `string`, `TestLiterals`? | ||
// --> class/misspeled_boolean_literals.baml:3 | ||
// | | ||
// 2 | a "SingleLiteral" | ||
// 3 | b "boolean" | True | False | ||
// | |
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
Oops, something went wrong.