Skip to content
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

rename #545

Merged
merged 162 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
c6684e6
do legacy pass on grammar
hellovai Apr 4, 2024
ef9ebf0
Working function type with errors
hellovai Apr 4, 2024
b5de746
Some code gen works
hellovai Apr 4, 2024
ce3e55d
adding work items
hellovai Apr 4, 2024
57bef58
Code generation
hellovai Apr 4, 2024
bfbd1a5
Add template string syntax
hellovai Apr 5, 2024
0a93714
feat: expose render_prompt to python
sxlijin Apr 5, 2024
1cb2bd6
strip out dead code
sxlijin Apr 5, 2024
52c5434
improve the pyo3 interface
sxlijin Apr 5, 2024
c190a01
set up maturin build steps
sxlijin Apr 6, 2024
6176b9e
add gh workflow
sxlijin Apr 6, 2024
9b692dd
fix workflow
sxlijin Apr 6, 2024
fb13d02
setup more release stuff
sxlijin Apr 6, 2024
8d33902
add an upload job
sxlijin Apr 6, 2024
2815d83
fix syntax
sxlijin Apr 6, 2024
ffd3432
fix publishing
sxlijin Apr 6, 2024
1448a04
allow oidc
sxlijin Apr 6, 2024
6379603
fix wheel file naming
sxlijin Apr 6, 2024
42e8021
clean up pyo3 version
sxlijin Apr 6, 2024
651de26
try again to fix workflow
sxlijin Apr 6, 2024
328afd0
try again
sxlijin Apr 6, 2024
8a99a65
once more
sxlijin Apr 6, 2024
787a7d3
try again
sxlijin Apr 6, 2024
ce0078a
try again...
sxlijin Apr 6, 2024
301a321
rename package
sxlijin Apr 6, 2024
a1833d7
fix clients/python
sxlijin Apr 6, 2024
fed0b20
Add static analysis function on jinja
hellovai Apr 7, 2024
d9d2c5b
Merge branch 'sam/maturin2' into rename
sxlijin Apr 7, 2024
9c4272d
Working JINJA static analyzer
hellovai Apr 8, 2024
db7615f
Handle all errors for template_strings too
hellovai Apr 8, 2024
dce7b14
fix gh workflow, add render_chat_prompt in python
sxlijin Apr 8, 2024
0c604a9
push up pyi changes
sxlijin Apr 8, 2024
12ecda1
fix pyi file
sxlijin Apr 8, 2024
2cf9982
remove indirection
sxlijin Apr 8, 2024
3ced139
get more stuff working
sxlijin Apr 8, 2024
80494f0
fix compile
sxlijin Apr 8, 2024
fd0c028
expose all types
sxlijin Apr 8, 2024
1144b33
more fixes
sxlijin Apr 8, 2024
b0967d9
Generate code
hellovai Apr 8, 2024
f072084
get the new rust python interface working
sxlijin Apr 8, 2024
b5bb444
remove indirect
sxlijin Apr 8, 2024
8e4d1ef
end2end working1
hellovai Apr 8, 2024
50f2ecf
renaming "default_config"
hellovai Apr 8, 2024
2cbe9af
add derives
hellovai Apr 8, 2024
3cc1f92
Add output_schema
hellovai Apr 8, 2024
e6dfd34
get globals working
sxlijin Apr 8, 2024
4a61285
make chat/completions splitting work
sxlijin Apr 8, 2024
498b5ef
works with playground
hellovai Apr 8, 2024
28a940a
implement chat splitting and dedenting
sxlijin Apr 9, 2024
9dcda5a
Add syntax highlighting
hellovai Apr 9, 2024
a25ac42
Make tests a warning when named incorrected.
hellovai Apr 9, 2024
6a37c5e
vscode preview works now!
sxlijin Apr 9, 2024
d630602
clean up the wasm_bindgen interface
sxlijin Apr 9, 2024
8fb63b6
fixes
hellovai Apr 9, 2024
84efcd1
react to tsx changes
sxlijin Apr 9, 2024
65ee762
change wasm_bindgen interface
sxlijin Apr 9, 2024
89bdc23
Fix TODO
hellovai Apr 9, 2024
5b79e0c
Better equality for Jinja
hellovai Apr 9, 2024
6285cb5
Fix errors for bad variables
hellovai Apr 9, 2024
e7aa4fe
fix a prompt rendering bug
sxlijin Apr 9, 2024
bdbc764
get output_schema working
sxlijin Apr 9, 2024
2e98f49
oops
sxlijin Apr 9, 2024
d1ec47c
output_schema does not work
sxlijin Apr 9, 2024
1b42bc7
ctx.output_schema kinda works now
sxlijin Apr 9, 2024
f66c16e
get ctx.output_schema working properly
sxlijin Apr 10, 2024
3e76f8c
make output schema work better
sxlijin Apr 10, 2024
58342e1
tweak enum format more for aaron
sxlijin Apr 10, 2024
b5820a4
add complex-v2 with AnalyzeProductReview tests
sxlijin Apr 10, 2024
00ec786
support output_schema in python
sxlijin Apr 10, 2024
1e15b0d
make it work
sxlijin Apr 10, 2024
7451d16
a little bit more pyo3
sxlijin Apr 10, 2024
1cbe10a
rip out js files in typescript/common/src
sxlijin Apr 10, 2024
c8d86ce
resolve fallback/round-robin in prompt preview
sxlijin Apr 11, 2024
4002487
expose the list of clients
sxlijin Apr 11, 2024
74e3a5c
fix build
sxlijin Apr 11, 2024
c779698
Merge branch 'canary' into rename
sxlijin Apr 11, 2024
9a75a5a
make implpanel work
sxlijin Apr 11, 2024
be37020
example projects wip
aaronvg Apr 11, 2024
95ce403
Example cards
aaronvg Apr 12, 2024
e3ac64c
test case auto-synthesis
sxlijin Apr 11, 2024
f288719
mvp impl of save and run is now working
sxlijin Apr 11, 2024
4e29bb1
still needs a lot of ui work
sxlijin Apr 12, 2024
cdaf7ef
Fixed typescript integration
hellovai Apr 12, 2024
f33c164
improve styling
aaronvg Apr 12, 2024
c4addb4
fix more sharing link bugs
aaronvg Apr 12, 2024
679b337
improve test case editor
sxlijin Apr 12, 2024
6ef4ca9
multi file editor
aaronvg Apr 12, 2024
c17935d
got token count working, then broke it
sxlijin Apr 13, 2024
54968de
implement token counting, clean up save and run
sxlijin Apr 13, 2024
33aa85e
fix some styles
aaronvg Apr 13, 2024
5381733
Add basic-ass linting
aaronvg Apr 13, 2024
255e5ee
use turbo
aaronvg Apr 13, 2024
b58e2ab
some prompt engineering fixes
aaronvg Apr 13, 2024
724e0f2
more prompt engineering
aaronvg Apr 14, 2024
b526389
more prompting
aaronvg Apr 14, 2024
80cf134
Add more prompts
aaronvg Apr 14, 2024
9027afe
update playground
aaronvg Apr 14, 2024
740e33c
adding linter
hellovai Apr 15, 2024
1cff60e
disable linter
hellovai Apr 15, 2024
cd36912
deactivate ai linter
aaronvg Apr 15, 2024
02e66d7
make class_schema work again
sxlijin Apr 15, 2024
c59600f
gitignore baml-schema-wasm web correctly
sxlijin Apr 15, 2024
084879a
some lezer updates
sxlijin Apr 15, 2024
368a752
Generate TS Code
hellovai Apr 15, 2024
3883132
Editable title
aaronvg Apr 15, 2024
c804c61
some more fixes
aaronvg Apr 15, 2024
bd2c83b
routing changes
aaronvg Apr 15, 2024
b9f29d7
clean up fiddle code
aaronvg Apr 15, 2024
263b059
fix rendering issue with the example project files
aaronvg Apr 15, 2024
1ab222b
Add test result to the project contents
aaronvg Apr 15, 2024
e4b1957
style tweak
aaronvg Apr 15, 2024
4a8e1cd
more grammar fixes for fiddle
sxlijin Apr 15, 2024
9a929bb
add jinja styling
sxlijin Apr 15, 2024
0b6a6e1
improve highlighting
sxlijin Apr 15, 2024
1c9bb8f
reset the url after running tests so user needs to generate a new one
aaronvg Apr 15, 2024
472ac5d
url resets
aaronvg Apr 15, 2024
147864f
fix vscode esbuild
sxlijin Apr 16, 2024
050efc7
new syntax works in TS!
hellovai Apr 16, 2024
7263b5d
rezisable panel change
aaronvg Apr 16, 2024
e39ee09
remove files
hellovai Apr 16, 2024
389e508
add symlinks
hellovai Apr 16, 2024
be02598
patch the status undefined
aaronvg Apr 16, 2024
217b550
Fixed with python again!
hellovai Apr 16, 2024
2c6519d
remove handle
aaronvg Apr 16, 2024
a69c1dc
tweaks
aaronvg Apr 16, 2024
1e01525
mostly finish syntax highlighting
sxlijin Apr 16, 2024
ca4fa85
unsaved changes
aaronvg Apr 16, 2024
b606684
fix bad use of hooks
aaronvg Apr 16, 2024
336ca32
fix linting error when switching files
aaronvg Apr 16, 2024
1058444
fix some highlights and add snippets
aaronvg Apr 16, 2024
d160cf0
add snippets
aaronvg Apr 16, 2024
8b124cf
reset the output logs, and add a newline spacing for now
aaronvg Apr 16, 2024
5b79f6e
Add linter gutter
aaronvg Apr 16, 2024
77b4a97
fix bug
aaronvg Apr 16, 2024
4003f5c
more fix
aaronvg Apr 16, 2024
c096617
merging
hellovai Apr 17, 2024
e2b3f46
add examples
sxlijin Apr 17, 2024
ec02d92
undo merge conflicts
sxlijin Apr 17, 2024
e6dabb2
fix merge conflicts again
sxlijin Apr 17, 2024
02dce46
add examples
sxlijin Apr 17, 2024
9dc1228
fix unable to name new test
aaronvg Apr 17, 2024
7ded33f
more fix
aaronvg Apr 17, 2024
8fd6347
minor comments
hellovai Apr 17, 2024
e6fa555
use tests as files
hellovai Apr 17, 2024
cb4139e
command w should not close the tab
aaronvg Apr 17, 2024
ed94301
Update listeners
hellovai Apr 17, 2024
070e732
add rendering
hellovai Apr 17, 2024
ea33839
update lock file
hellovai Apr 17, 2024
0ff10df
fix compiler errors
hellovai Apr 17, 2024
7e35c61
adding PYI file
hellovai Apr 17, 2024
086396f
ignore ffi errors python
hellovai Apr 17, 2024
b57fe4c
update ini
hellovai Apr 17, 2024
a650e2c
remove trailing comment
hellovai Apr 17, 2024
1575987
fix ini file
hellovai Apr 17, 2024
cd4d107
fix ruff
hellovai Apr 17, 2024
b16d11a
udpate workflow
hellovai Apr 17, 2024
0471d38
udpate workflow
hellovai Apr 17, 2024
64b756d
Make codemirror refresh and relint when files change
aaronvg Apr 17, 2024
c0d63f3
Some cleanup
aaronvg Apr 17, 2024
2140823
fixed tests
hellovai Apr 17, 2024
49c0dc7
Fix resizing performance issues, text overflow bugs, and test error o…
aaronvg Apr 17, 2024
18afcaa
fix stuff
aaronvg Apr 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion engine/baml-fmt/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ pub(crate) fn run(input: &str) -> String {
})).collect::<Vec<_>>(),
"functions": schema
.db
.walk_functions()
.walk_old_functions()
.chain(schema.db.walk_new_functions())
.map(|func| {
json!({
"name": StringSpan::new(func.name(), func.identifier().span()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ pub(crate) fn generate_py(
db.walk_enums().for_each(|e| generate_py_file(&e, &mut fc));
db.walk_classes()
.for_each(|c| generate_py_file(&c, &mut fc));
db.walk_functions()
db.walk_old_functions()
.chain(db.walk_new_functions())
.for_each(|f| generate_py_file(&f, &mut fc));
let mut variants = db.walk_variants().collect::<Vec<_>>();
variants.sort_by(|a, b| {
Expand Down Expand Up @@ -142,20 +143,23 @@ impl WithWritePythonString for ParserDatabase {
fc.complete_file();

fc.start_export_file("./baml_types", "__init__");
self.walk_functions().for_each(|f| {
fc.last_file().add_import(
&format!("..__do_not_import.functions.{}", f.file_name()),
&format!("I{}", f.name()),
);
fc.last_file().add_import(
&format!("..__do_not_import.functions.{}", f.file_name()),
&format!("I{}Stream", f.name()),
);
fc.last_file().add_import(
&format!("..__do_not_import.functions.{}", f.file_name()),
&format!("I{}Output", f.name()),
)
});

self.walk_old_functions()
.chain(self.walk_new_functions())
.for_each(|f| {
fc.last_file().add_import(
&format!("..__do_not_import.functions.{}", f.file_name()),
&format!("I{}", f.name()),
);
fc.last_file().add_import(
&format!("..__do_not_import.functions.{}", f.file_name()),
&format!("I{}Stream", f.name()),
);
fc.last_file().add_import(
&format!("..__do_not_import.functions.{}", f.file_name()),
&format!("I{}Output", f.name()),
)
});
self.walk_enums().for_each(|e| {
fc.last_file().add_import(
&format!("..__do_not_import.types.enums.{}", e.file_name()),
Expand Down Expand Up @@ -191,7 +195,8 @@ impl WithWritePythonString for ParserDatabase {

fc.start_py_file(".", "generated_baml_client");
let mut fxs = self
.walk_functions()
.walk_old_functions()
.chain(self.walk_new_functions())
.map(|f| {
fc.last_file().add_import(
&format!(".functions.{}", f.file_name()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use internal_baml_parser_database::walkers::{ArgWalker, EnumWalker, Walker};
use internal_baml_parser_database::walkers::{ArgWalker, EnumWalker, FunctionWalker, Walker};
use internal_baml_schema_ast::ast::{
FieldType, FunctionArg, FunctionId, Identifier, WithDocumentation, WithName,
};
Expand Down Expand Up @@ -92,15 +92,22 @@ impl JsonHelper for ArgWalker<'_> {
}
}

impl JsonHelper for Walker<'_, FunctionId> {
impl JsonHelper for FunctionWalker<'_> {
fn json(&self, f: &mut File) -> serde_json::Value {
let mut impls = self
.walk_variants()
.map(|v| v.name().to_string())
.collect::<Vec<_>>();
impls.sort();
let impls = if self.is_old_function() {
let mut impls = self
.walk_variants()
.map(|v| v.name().to_string())
.collect::<Vec<_>>();
impls.sort();
impls
} else {
// New function logic
vec!["default".into()]
};

let mut inputs = self.walk_input_args().collect::<Vec<_>>();
inputs.sort_by(|a, b| a.is_optional().cmp(&b.is_optional()));
inputs.sort_by(|a, b| a.name().cmp(&b.name()));

json!({
"name": self.ast_function().name(),
Expand Down Expand Up @@ -130,7 +137,7 @@ fn is_enum<'a>(
return false;
}

impl WithWritePythonString for Walker<'_, FunctionId> {
impl WithWritePythonString for FunctionWalker<'_> {
fn file_name(&self) -> String {
format!("fx_{}", clean_file_name(self.name()))
}
Expand All @@ -152,5 +159,20 @@ impl WithWritePythonString for Walker<'_, FunctionId> {
json,
);
fc.complete_file();

if !self.is_old_function() {
let impl_name = format!("fx_{}_impl_default", clean_file_name(self.name()));

fc.start_py_file("impls", "__init__.py");
fc.last_file()
.add_line(format!("from .{0} import default as unused_{0}", impl_name,));
fc.complete_file();

// May need to do some fancy stuff
fc.start_py_file("impls", impl_name);
// let json = self.json(fc.last_file());
// render_template(super::template::HSTemplate::Variant, fc.last_file(), json);
fc.complete_file();
}
}
}
28 changes: 17 additions & 11 deletions engine/baml-lib/baml-core/src/generate/ir/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ impl IntermediateRepr {
.map(|e| e.node(db))
.collect::<Result<Vec<_>>>()?,
functions: db
.walk_functions()
.walk_old_functions()
.chain(db.walk_new_functions())
.map(|e| e.node(db))
.collect::<Result<Vec<_>>>()?,
clients: db
Expand Down Expand Up @@ -354,7 +355,7 @@ impl WithRepr<EnumValue> for EnumValueWalker<'_> {

attributes.meta = to_ir_attributes(db, self.get_default_attributes());

for r#fn in db.walk_functions() {
for r#fn in db.walk_old_functions() {
for r#impl in r#fn.walk_variants() {
let node_attributes = to_ir_attributes(db, self.get_override(&r#impl));

Expand All @@ -381,7 +382,7 @@ impl WithRepr<Enum> for EnumWalker<'_> {

attributes.meta = to_ir_attributes(db, self.get_default_attributes());

for r#fn in db.walk_functions() {
for r#fn in db.walk_old_functions() {
for r#impl in r#fn.walk_variants() {
let node_attributes =
to_ir_attributes(db, r#impl.find_serializer_attributes(self.name()));
Expand Down Expand Up @@ -420,7 +421,7 @@ impl WithRepr<Field> for FieldWalker<'_> {

attributes.meta = to_ir_attributes(db, self.get_default_attributes());

for r#fn in db.walk_functions() {
for r#fn in db.walk_old_functions() {
for r#impl in r#fn.walk_variants() {
let node_attributes = to_ir_attributes(db, self.get_override(&r#impl));
if !node_attributes.is_empty() {
Expand Down Expand Up @@ -458,7 +459,7 @@ impl WithRepr<Class> for ClassWalker<'_> {

attributes.meta = to_ir_attributes(db, self.get_default_attributes());

for r#fn in db.walk_functions() {
for r#fn in db.walk_old_functions() {
for r#impl in r#fn.walk_variants() {
let node_attributes =
to_ir_attributes(db, r#impl.find_serializer_attributes(self.name()));
Expand Down Expand Up @@ -724,12 +725,17 @@ impl WithRepr<Function> for FunctionWalker<'_> {
}?,
default_impl: self.metadata().default_impl.as_ref().map(|f| f.0.clone()),
impls: {
let mut impls = self
.walk_variants()
.map(|e| e.node(db))
.collect::<Result<Vec<_>>>()?;
impls.sort_by(|a, b| a.elem.name.cmp(&&b.elem.name));
impls
if self.is_old_function() {
let mut impls = self
.walk_variants()
.map(|e| e.node(db))
.collect::<Result<Vec<_>>>()?;
impls.sort_by(|a, b| a.elem.name.cmp(&&b.elem.name));
impls
} else {
// TODO: @hellovai
vec![]
}
},
tests: self
.walk_tests()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::validate::validation_pipeline::context::Context;
use super::common::validate_type_exists;

pub(super) fn validate(ctx: &mut Context<'_>) {
for func in ctx.db.walk_functions() {
for func in ctx.db.walk_old_functions() {
for args in func.walk_input_args().chain(func.walk_output_args()) {
let arg = args.ast_arg();
validate_type_exists(ctx, &arg.1.field_type)
Expand Down Expand Up @@ -45,4 +45,33 @@ pub(super) fn validate(ctx: &mut Context<'_>) {
}
}
}

let clients = ctx
.db
.walk_clients()
.map(|c| c.name().to_string())
.collect::<Vec<_>>();
for func in ctx.db.walk_new_functions() {
for args in func.walk_input_args().chain(func.walk_output_args()) {
let arg = args.ast_arg();
validate_type_exists(ctx, &arg.1.field_type)
}

// Ensure the client is correct.
match func.client() {
Some(_) => {}
None => {
let client = func.metadata().client.as_ref().unwrap();
ctx.push_error(DatamodelError::not_found_error(
"Client",
&client.0,
client.1.clone(),
clients.clone(),
))
}
}

// TODO: @sxlijin do any validation on the prompt.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sxlijin here!

let _prompt = func.jinja_prompt();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
function Foo() -> {
client Bar
prompt #"fa"#
}

function FooBar(arg) -> bar {

}


// error: Error validating function "Foo": No return type specified. Valid function syntax is
// ```
// function Foo(param1: String, param2: String) -> ReturnType {
// client SomeClient
// prompt #"..."#
// }
// ```
// --> functions_v2/invalid.baml:1
// |
// |
// 1 | function Foo() -> {
// 2 | client Bar
// 3 | prompt #"fa"#
// 4 | }
// |
// error: Error validating: No type specified for argument: arg. Expected: `arg: type`
// --> functions_v2/invalid.baml:6
// |
// 5 |
// 6 | function FooBar(arg) -> bar {
// |
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
function Foo1(arg: int) -> float {
client Foo
}

function Foo2(arg: int) -> float {
prompt #"..."#
}

function Foo3(arg: int) -> float {
client bar
prompt "..."
}


function Foo4(arg: int) -> float {
client bar
prompt
}


function Foo5(arg: int) -> float {
client
prompt #"..."#
}


function Foo6(arg: int) -> float {
client
prompt
}

// error: Error validating: Missing `prompt` field in function. Add to the block:
// ```
// prompt #"..."#
// ```
// --> functions_v2/invalid2.baml:1
// |
// |
// 1 | function Foo1(arg: int) -> float {
// |
// error: Error validating: Missing `client` field in function. Add to the block:
// ```
// client GPT4
// ```
// --> functions_v2/invalid2.baml:5
// |
// 4 |
// 5 | function Foo2(arg: int) -> float {
// |
// error: Expected a template_string value, but received string value `"..."`.
// --> functions_v2/invalid2.baml:11
// |
// 10 | client bar
// 11 | prompt "..."
// |
// error: Error validating: Missing `prompt` field in function. Add to the block:
// ```
// prompt #"..."#
// ```
// --> functions_v2/invalid2.baml:9
// |
// 8 |
// 9 | function Foo3(arg: int) -> float {
// |
// error: Error validating: Missing `prompt` field in function. Add to the block:
// ```
// prompt #"..."#
// ```
// --> functions_v2/invalid2.baml:15
// |
// 14 |
// 15 | function Foo4(arg: int) -> float {
// |
// error: Error validating: Missing `client` field in function. Add to the block:
// ```
// client GPT4
// ```
// --> functions_v2/invalid2.baml:21
// |
// 20 |
// 21 | function Foo5(arg: int) -> float {
// |
// error: Error validating: Missing `prompt` and `client` fields in function. Add to the block:
// ```
// client GPT4
// prompt #"..."#
// ```
// --> functions_v2/invalid2.baml:27
// |
// 26 |
// 27 | function Foo6(arg: int) -> float {
// |
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function Foo() -> int {
client Bar
prompt #"fa"#
}

function Bar(a: string, b: int | bool) -> int {
client Bar
prompt #"fa"#
}
Loading
Loading