From 3f34e550d6b2f6c2f9f05e4597d57725b84e080b Mon Sep 17 00:00:00 2001 From: aaronvg Date: Wed, 26 Jun 2024 12:06:09 -0700 Subject: [PATCH] tb fix (#721) - **Fix typebuilder for random enums** - **0.44.0** --- engine/Cargo.lock | 28 ++++----- engine/Cargo.toml | 2 +- .../typescript/templates/type_builder.js.j2 | 4 +- engine/language_client_python/pyproject.toml | 2 +- engine/language_client_ruby/baml.gemspec | 2 +- .../language_client_typescript/package.json | 2 +- .../type_builder.d.ts | 9 ++- .../type_builder.d.ts.map | 2 +- .../type_builder.js | 4 +- .../typescript_src/type_builder.ts | 9 +-- .../typescript/baml_client/type_builder.ts | 4 +- .../typescript/tests/integ-tests.test.ts | 57 ++++++++++++++----- tools/versions/engine.cfg | 2 +- tools/versions/python.cfg | 2 +- tools/versions/ruby.cfg | 2 +- tools/versions/typescript.cfg | 2 +- tools/versions/vscode.cfg | 2 +- typescript/vscode-ext/packages/package.json | 2 +- 18 files changed, 84 insertions(+), 53 deletions(-) diff --git a/engine/Cargo.lock b/engine/Cargo.lock index 78dbd94b6..00270f8b0 100644 --- a/engine/Cargo.lock +++ b/engine/Cargo.lock @@ -352,7 +352,7 @@ dependencies = [ [[package]] name = "baml" -version = "0.43.0" +version = "0.44.0" dependencies = [ "anyhow", "baml-lib", @@ -393,7 +393,7 @@ dependencies = [ [[package]] name = "baml-fmt" -version = "0.43.0" +version = "0.44.0" dependencies = [ "anyhow", "baml-lib", @@ -415,7 +415,7 @@ dependencies = [ [[package]] name = "baml-lib" -version = "0.43.0" +version = "0.44.0" dependencies = [ "base64 0.13.1", "dissimilar", @@ -453,7 +453,7 @@ dependencies = [ [[package]] name = "baml-runtime" -version = "0.43.0" +version = "0.44.0" dependencies = [ "anyhow", "async-std", @@ -515,7 +515,7 @@ dependencies = [ [[package]] name = "baml-schema-build" -version = "0.43.0" +version = "0.44.0" dependencies = [ "anyhow", "baml-runtime", @@ -547,7 +547,7 @@ dependencies = [ [[package]] name = "baml-types" -version = "0.43.0" +version = "0.44.0" dependencies = [ "indexmap 2.2.6", "minijinja", @@ -1803,7 +1803,7 @@ dependencies = [ [[package]] name = "internal-baml-codegen" -version = "0.43.0" +version = "0.44.0" dependencies = [ "anyhow", "askama", @@ -1823,7 +1823,7 @@ dependencies = [ [[package]] name = "internal-baml-core" -version = "0.43.0" +version = "0.44.0" dependencies = [ "anyhow", "baml-types", @@ -1857,7 +1857,7 @@ dependencies = [ [[package]] name = "internal-baml-diagnostics" -version = "0.43.0" +version = "0.44.0" dependencies = [ "anyhow", "colored", @@ -1870,7 +1870,7 @@ dependencies = [ [[package]] name = "internal-baml-jinja" -version = "0.43.0" +version = "0.44.0" dependencies = [ "anyhow", "askama", @@ -1887,7 +1887,7 @@ dependencies = [ [[package]] name = "internal-baml-parser-database" -version = "0.43.0" +version = "0.44.0" dependencies = [ "baml-types", "colored", @@ -1909,7 +1909,7 @@ dependencies = [ [[package]] name = "internal-baml-prompt-parser" -version = "0.43.0" +version = "0.44.0" dependencies = [ "internal-baml-diagnostics", "internal-baml-schema-ast", @@ -1921,7 +1921,7 @@ dependencies = [ [[package]] name = "internal-baml-schema-ast" -version = "0.43.0" +version = "0.44.0" dependencies = [ "baml-types", "either", @@ -1988,7 +1988,7 @@ checksum = "9dbbfed4e59ba9750e15ba154fdfd9329cee16ff3df539c2666b70f58cc32105" [[package]] name = "jsonish" -version = "0.43.0" +version = "0.44.0" dependencies = [ "anyhow", "assert-json-diff", diff --git a/engine/Cargo.toml b/engine/Cargo.toml index 8c3e4efa1..cfb50ff56 100644 --- a/engine/Cargo.toml +++ b/engine/Cargo.toml @@ -57,7 +57,7 @@ internal-baml-core = { path = "baml-lib/baml-core" } internal-baml-jinja = { path = "baml-lib/jinja" } [workspace.package] -version = "0.43.0" +version = "0.44.0" authors = ["Boundary "] description = "BAML Toolchain" diff --git a/engine/language-client-codegen/src/typescript/templates/type_builder.js.j2 b/engine/language-client-codegen/src/typescript/templates/type_builder.js.j2 index 9e3e243bf..703d0173c 100644 --- a/engine/language-client-codegen/src/typescript/templates/type_builder.js.j2 +++ b/engine/language-client-codegen/src/typescript/templates/type_builder.js.j2 @@ -58,10 +58,10 @@ export default class TypeBuilder { } addClass(name: Name): ClassBuilder { - this.tb.addClass(name); + return this.tb.addClass(name); } addEnum(name: Name): EnumBuilder { - this.tb.addEnum(name); + return this.tb.addEnum(name); } } diff --git a/engine/language_client_python/pyproject.toml b/engine/language_client_python/pyproject.toml index 9ef4045e1..3745c23b6 100644 --- a/engine/language_client_python/pyproject.toml +++ b/engine/language_client_python/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "baml-py" -version = "0.43.0" +version = "0.44.0" description = "BAML python bindings (pyproject.toml)" readme = "README.md" authors = [["Boundary", "contact@boundaryml.com"]] diff --git a/engine/language_client_ruby/baml.gemspec b/engine/language_client_ruby/baml.gemspec index e567d3130..9a63cf916 100644 --- a/engine/language_client_ruby/baml.gemspec +++ b/engine/language_client_ruby/baml.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |spec| spec.name = "baml" - spec.version = "0.43.0" + spec.version = "0.44.0" spec.authors = ["BoundaryML"] spec.email = ["contact@boundaryml.com"] diff --git a/engine/language_client_typescript/package.json b/engine/language_client_typescript/package.json index b48fb19f6..2b64a94db 100644 --- a/engine/language_client_typescript/package.json +++ b/engine/language_client_typescript/package.json @@ -1,6 +1,6 @@ { "name": "@boundaryml/baml", - "version": "0.43.0", + "version": "0.44.0", "description": "BAML typescript bindings (package.json)", "repository": { "type": "git", diff --git a/engine/language_client_typescript/type_builder.d.ts b/engine/language_client_typescript/type_builder.d.ts index 30e8f48f7..9a9c70b81 100644 --- a/engine/language_client_typescript/type_builder.d.ts +++ b/engine/language_client_typescript/type_builder.d.ts @@ -5,10 +5,13 @@ type CheckNever = [T] extends type ExcludeFrom = T extends U ? never : T; type RestrictNot = IsLiteral extends true ? CheckNever, Name, Value> : Value; export declare class TypeBuilder { - protected classes: Set; - protected enums: Set; private tb; - constructor(classes: Set, enums: Set); + protected classes: Set; + protected enums: Set; + constructor({ classes, enums }: { + classes: Set; + enums: Set; + }); _tb(): _TypeBuilder; string(): FieldType; int(): FieldType; diff --git a/engine/language_client_typescript/type_builder.d.ts.map b/engine/language_client_typescript/type_builder.d.ts.map index 4fa27ea50..c26a52d3a 100644 --- a/engine/language_client_typescript/type_builder.d.ts.map +++ b/engine/language_client_typescript/type_builder.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"type_builder.d.ts","sourceRoot":"","sources":["typescript_src/type_builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,oBAAoB,IAAI,qBAAqB,EAC7C,gBAAgB,EAChB,SAAS,EACT,WAAW,IAAI,YAAY,EAC5B,MAAM,UAAU,CAAA;AAEjB,KAAK,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,SAAS,CAAC,GAAG,KAAK,GAAG,IAAI,CAAA;AAClE,KAAK,MAAM,CAAC,CAAC,SAAS,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,aAAa,CAAA;AAC7E,KAAK,UAAU,CAAC,CAAC,EAAE,QAAQ,SAAS,MAAM,EAAE,KAAK,SAAS,MAAM,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GACnF,gCAAgC,KAAK,iCAAiC,MAAM,CAAC,QAAQ,CAAC,IAAI,GAC1F,CAAC,CAAA;AACL,KAAK,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;AAChD,KAAK,WAAW,CAAC,IAAI,SAAS,MAAM,EAAE,KAAK,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,IAAI,GACrG,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,GAC9C,KAAK,CAAA;AAET,qBAAa,WAAW;IAIpB,SAAS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AAM,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM;IAMvE,OAAO,CAAC,MAAM;IALhB,OAAO,CAAC,IAAI,CAAc;gBAGxB,EAAE,EAAE,YAAY,EAChB,IAAI,EAAE,QAAQ,EACN,MAAM,GAAE,GAAG,CAAC,CAAC,GAAG,MAAM,CAAa;IAK7C,IAAI,IAAI,SAAS;IAIjB,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,gBAAgB;IAOtD,UAAU,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAI/C,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,gBAAgB;CAOhF"} \ No newline at end of file diff --git a/engine/language_client_typescript/type_builder.js b/engine/language_client_typescript/type_builder.js index 3bd5d6ffa..bde0e4e18 100644 --- a/engine/language_client_typescript/type_builder.js +++ b/engine/language_client_typescript/type_builder.js @@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.EnumBuilder = exports.ClassBuilder = exports.TypeBuilder = void 0; const native_1 = require("./native"); class TypeBuilder { + tb; classes; enums; - tb; - constructor(classes, enums) { + constructor({ classes, enums }) { this.classes = classes; this.enums = enums; this.tb = new native_1.TypeBuilder(); diff --git a/engine/language_client_typescript/typescript_src/type_builder.ts b/engine/language_client_typescript/typescript_src/type_builder.ts index a285898d7..471eada0e 100644 --- a/engine/language_client_typescript/typescript_src/type_builder.ts +++ b/engine/language_client_typescript/typescript_src/type_builder.ts @@ -19,11 +19,12 @@ type RestrictNot = export class TypeBuilder { private tb: _TypeBuilder + protected classes: Set + protected enums: Set - constructor( - protected classes: Set, - protected enums: Set, - ) { + constructor({ classes, enums }: { classes: Set; enums: Set }) { + this.classes = classes + this.enums = enums this.tb = new _TypeBuilder() } diff --git a/integ-tests/typescript/baml_client/type_builder.ts b/integ-tests/typescript/baml_client/type_builder.ts index 36ed1d713..5eaa1449b 100644 --- a/integ-tests/typescript/baml_client/type_builder.ts +++ b/integ-tests/typescript/baml_client/type_builder.ts @@ -121,10 +121,10 @@ export default class TypeBuilder { } addClass(name: Name): ClassBuilder { - this.tb.addClass(name); + return this.tb.addClass(name); } addEnum(name: Name): EnumBuilder { - this.tb.addEnum(name); + return this.tb.addEnum(name); } } \ No newline at end of file diff --git a/integ-tests/typescript/tests/integ-tests.test.ts b/integ-tests/typescript/tests/integ-tests.test.ts index e511fb71a..39014ebfd 100644 --- a/integ-tests/typescript/tests/integ-tests.test.ts +++ b/integ-tests/typescript/tests/integ-tests.test.ts @@ -1,6 +1,6 @@ import assert from 'assert' import { image_b64, audio_b64 } from './base64_test_data' -import { Image} from '@boundaryml/baml' +import { Image } from '@boundaryml/baml' import { Audio } from '@boundaryml/baml' import { b, @@ -15,7 +15,6 @@ import { import TypeBuilder from '../baml_client/type_builder' import { RecursivePartialNull } from '../baml_client/client' - describe('Integ tests', () => { it('should work for all inputs', async () => { let res = await b.TestFnNamedArgsSingleBool(true) @@ -118,19 +117,19 @@ describe('Integ tests', () => { }) it('should work with image from base 64', async () => { - let res = await b.TestImageInput( - Image.fromBase64('image/png', image_b64), - ) + let res = await b.TestImageInput(Image.fromBase64('image/png', image_b64)) expect(res.toLowerCase()).toContain('green') }) it('should work with audio base 64', async () => { - let res = await b.AudioInput(Audio.fromBase64('audio/mp3',audio_b64)) + let res = await b.AudioInput(Audio.fromBase64('audio/mp3', audio_b64)) expect(res.toLowerCase()).toContain('yes') }) it('should work with audio from url', async () => { - let res = await b.AudioInput(Audio.fromUrl("https://actions.google.com/sounds/v1/emergency/beeper_emergency_call.ogg")) + let res = await b.AudioInput( + Audio.fromUrl('https://actions.google.com/sounds/v1/emergency/beeper_emergency_call.ogg'), + ) expect(res.toLowerCase()).toContain('no') }) @@ -237,7 +236,7 @@ describe('Integ tests', () => { })('hi', 10) }) - it('should work with dynamic types', async () => { + it('should work with dynamic types single', async () => { let tb = new TypeBuilder() tb.Person.addProperty('last_name', tb.string().optional()) tb.Person.addProperty('height', tb.float().optional()).description('Height in meters') @@ -255,28 +254,56 @@ describe('Integ tests', () => { console.log(res) }) + it('should work with dynamic types enum', async () => { + let tb = new TypeBuilder() + const fieldEnum = tb.addEnum('Animal') + const animals = ['giraffe', 'elephant', 'lion'] + for (const animal of animals) { + fieldEnum.addValue(animal.toUpperCase()) + } + tb.Person.addProperty('animalLiked', fieldEnum.type()) + const res = await b.ExtractPeople( + "My name is Harrison. My hair is black and I'm 6 feet tall. I'm pretty good around the hoop. I like giraffes.", + { tb }, + ) + expect(res.length).toBeGreaterThan(0) + expect(res[0]['animalLiked']).toEqual('GIRAFFE') + }) + + it('should work with dynamic types class', async () => { + let tb = new TypeBuilder() + const animalClass = tb.addClass('Animal') + animalClass.addProperty('animal', tb.string()).description('The animal mentioned, in singular form.') + tb.Person.addProperty('animalLiked', animalClass.type()) + const res = await b.ExtractPeople( + "My name is Harrison. My hair is black and I'm 6 feet tall. I'm pretty good around the hoop. I like giraffes.", + { tb }, + ) + expect(res.length).toBeGreaterThan(0) + const animalLiked = res[0]['animalLiked'] + expect(animalLiked['animal']).toContain('giraffe') + }) it('should work with dynamic inputs class', async () => { let tb = new TypeBuilder() tb.DynInputOutput.addProperty('new-key', tb.string().optional()) - const res = await b.DynamicInputOutput({ 'new-key': 'hi', testKey: "myTest" }, { tb }) - expect(res["new-key"]).toEqual('hi') - expect(res["testKey"]).toEqual('myTest') + const res = await b.DynamicInputOutput({ 'new-key': 'hi', testKey: 'myTest' }, { tb }) + expect(res['new-key']).toEqual('hi') + expect(res['testKey']).toEqual('myTest') }) it('should work with dynamic inputs list', async () => { let tb = new TypeBuilder() tb.DynInputOutput.addProperty('new-key', tb.string().optional()) - const res = await b.DynamicListInputOutput([{ 'new-key': 'hi', testKey: "myTest" }], { tb }) - expect(res[0]["new-key"]).toEqual('hi') - expect(res[0]["testKey"]).toEqual('myTest') + const res = await b.DynamicListInputOutput([{ 'new-key': 'hi', testKey: 'myTest' }], { tb }) + expect(res[0]['new-key']).toEqual('hi') + expect(res[0]['testKey']).toEqual('myTest') }) // test with extra list, boolean in the input as well. - it('should work with nested classes', async () => { let stream = b.stream.FnOutputClassNested('hi!') let msgs: RecursivePartialNull = [] diff --git a/tools/versions/engine.cfg b/tools/versions/engine.cfg index f9091bfb4..4d4025af4 100644 --- a/tools/versions/engine.cfg +++ b/tools/versions/engine.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.43.0 +current_version = 0.44.0 commit = False tag = False parse = ^(?P\d+)\.(?P\d+).(?P\d+)$ diff --git a/tools/versions/python.cfg b/tools/versions/python.cfg index 44ba48811..7820815ff 100644 --- a/tools/versions/python.cfg +++ b/tools/versions/python.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.43.0 +current_version = 0.44.0 commit = False tag = False parse = ^(?P\d+)\.(?P\d+).(?P\d+)$ diff --git a/tools/versions/ruby.cfg b/tools/versions/ruby.cfg index 6ed489f7e..4d5608d7f 100644 --- a/tools/versions/ruby.cfg +++ b/tools/versions/ruby.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.43.0 +current_version = 0.44.0 commit = False tag = False parse = ^(?P\d+)\.(?P\d+).(?P\d+)$ diff --git a/tools/versions/typescript.cfg b/tools/versions/typescript.cfg index 56211888c..2424a0e73 100644 --- a/tools/versions/typescript.cfg +++ b/tools/versions/typescript.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.43.0 +current_version = 0.44.0 commit = False tag = False parse = ^(?P\d+)\.(?P\d+).(?P\d+)$ diff --git a/tools/versions/vscode.cfg b/tools/versions/vscode.cfg index 48767a804..487fd32ba 100644 --- a/tools/versions/vscode.cfg +++ b/tools/versions/vscode.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.43.0 +current_version = 0.44.0 commit = False tag = False parse = ^(?P\d+)\.(?P\d+).(?P\d+)$ diff --git a/typescript/vscode-ext/packages/package.json b/typescript/vscode-ext/packages/package.json index 74b74ab57..762cd83eb 100644 --- a/typescript/vscode-ext/packages/package.json +++ b/typescript/vscode-ext/packages/package.json @@ -2,7 +2,7 @@ "name": "baml-extension", "displayName": "Baml", "description": "BAML is a DSL for AI applications.", - "version": "0.43.0", + "version": "0.44.0", "publisher": "Boundary", "repository": "https://github.com/BoundaryML/baml", "homepage": "https://www.boundaryml.com",