-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix codegen for Python booleans & Add literals integ tests (#1099)
Fixes #1094 & #1095 <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Fixes Python boolean code generation and adds integration tests for literals, updating handling in `generate_types.rs` and adding tests for various literal scenarios. > > - **Behavior**: > - Added `to_python_literal()` in `generate_types.rs` for Python boolean literals. > - Updated `FieldType::Literal` handling in `generate_types.rs` and `mod.rs` to use `to_python_literal()`. > - **Tests**: > - Added integration tests for literals in `integ-tests/baml_src/test-files/functions/input/named-args/single/` and `integ-tests/baml_src/test-files/functions/output/`. > - Tests cover literal booleans, integers, strings, and unions. > - **Misc**: > - Updated `async_client.py`, `sync_client.py`, and `inlinedbaml.py` for new literal handling. > - Added models `LiteralClassHello`, `LiteralClassOne`, `LiteralClassTwo` in `types.py` and `partial_types.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 5c13e9b. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
- Loading branch information
1 parent
11efa5e
commit 6359762
Showing
33 changed files
with
3,177 additions
and
167 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
11 changes: 11 additions & 0 deletions
11
...tests/baml_src/test-files/functions/input/named-args/single/named-class-literal-prop.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,11 @@ | ||
class LiteralClassHello { | ||
prop "hello" | ||
} | ||
|
||
function FnLiteralClassInputOutput(input: LiteralClassHello) -> LiteralClassHello { | ||
client GPT4 | ||
prompt #" | ||
Return the same object you were given. | ||
{{ ctx.output_format }} | ||
"# | ||
} |
15 changes: 15 additions & 0 deletions
15
...baml_src/test-files/functions/input/named-args/single/named-class-literal-union-prop.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,15 @@ | ||
class LiteralClassOne { | ||
prop "one" | ||
} | ||
|
||
class LiteralClassTwo { | ||
prop "two" | ||
} | ||
|
||
function FnLiteralUnionClassInputOutput(input: LiteralClassOne | LiteralClassTwo) -> LiteralClassOne | LiteralClassTwo { | ||
client GPT4 | ||
prompt #" | ||
Return the same object you were given. | ||
{{ ctx.output_format }} | ||
"# | ||
} |
13 changes: 13 additions & 0 deletions
13
integ-tests/baml_src/test-files/functions/input/named-args/single/named-literal-bool.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,13 @@ | ||
function TestNamedArgsLiteralBool(myBool: true) -> string { | ||
client GPT35 | ||
prompt #" | ||
Return this value back to me: {{myBool}} | ||
"# | ||
} | ||
|
||
test TestFnNamedArgsLiteralBool { | ||
functions [TestNamedArgsLiteralBool] | ||
args { | ||
myBool true | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
integ-tests/baml_src/test-files/functions/input/named-args/single/named-literal-int.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,13 @@ | ||
function TestNamedArgsLiteralInt(myInt: 1) -> string { | ||
client GPT35 | ||
prompt #" | ||
Return this value back to me: {{myInt}} | ||
"# | ||
} | ||
|
||
test TestFnNamedArgsLiteralInt { | ||
functions [TestNamedArgsLiteralInt] | ||
args { | ||
myInt 1 | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
integ-tests/baml_src/test-files/functions/input/named-args/single/named-literal-string.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,13 @@ | ||
function TestNamedArgsLiteralString(myString: "My String") -> string { | ||
client GPT35 | ||
prompt #" | ||
Return this value back to me: {{myString}} | ||
"# | ||
} | ||
|
||
test TestFnNamedArgsLiteralString { | ||
functions [TestNamedArgsLiteralString] | ||
args { | ||
myString "My String" | ||
} | ||
} |
Oops, something went wrong.