https://www.boundaryml.com logo
the ones i implement always have weird
# suggestions
a
a
Function signature is just
dict -> TypeBuilder
? Takes in a JSON object, outputs TypeBuilder object? Or you need additional APIs?
a
yup JSON schema obj to TypeBuilder would be perfect! for reference he's a common pattern ive used in many places (which uses a json schema to typebuilder converter, but also a hack to convert primitives into a valid dynamic output shape)
Copy code
ts
const tb = new TypeBuilder();
// schema being a valid JSON schema
if (schema.type === 'object') {
    for (const [key, property] of Object.entries(schema.properties)) {
      tb.SomeDynamicType.addProperty(key, convertJsonSchemaToBaml(tb, property as any));
    }
} else {
    tb.SomeDynamicType.addProperty('data', convertJsonSchemaToBaml(tb, schema, true));
}

const resp = await b.MyDynamicFunction(
    // ...
    { tb }
);

let data;

if (schema.type === 'object') {
  data = resp;
} else {
  data = resp.data;
}