wllvns
08/21/2025, 8:34 PMwllvns
08/21/2025, 9:03 PMVaibhav (BAML π)
08/21/2025, 9:11 PMVaibhav (BAML π)
08/21/2025, 9:11 PMVaibhav (BAML π)
08/21/2025, 9:12 PMseawatts
08/21/2025, 9:13 PMwllvns
08/21/2025, 10:58 PMwllvns
08/21/2025, 10:58 PMwllvns
08/21/2025, 11:24 PMwllvns
08/21/2025, 11:24 PMwllvns
08/21/2025, 11:28 PM{
"errorType": "Runtime.UserCodeSyntaxError",
"errorMessage": "SyntaxError: Named export 'Image' not found. The requested module '@boundaryml/baml' is a CommonJS module, which may not support all module.exports as named exports.\nCommonJS modules can always be imported via the default export, for example using:\n\nimport pkg from '@boundaryml/baml';\nconst { ClientRegistry, Image } = pkg;\n",
"stack": [
"Runtime.UserCodeSyntaxError: SyntaxError: Named export 'Image' not found. The requested module '@boundaryml/baml' is a CommonJS module, which may not support all module.exports as named exports.",
"CommonJS modules can always be imported via the default export, for example using:",
"",
"import pkg from '@boundaryml/baml';",
"const { ClientRegistry, Image } = pkg;",
"",
" at _loadUserApp (file:///var/runtime/index.mjs:1106:17)",
" at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1148:21)",
" at async start (file:///var/runtime/index.mjs:1335:23)",
" at async file:///var/runtime/index.mjs:1342:1"
]
}
my test repo at least gave a more helpful/complete errorwllvns
08/21/2025, 11:42 PMwllvns
08/21/2025, 11:43 PMimport { Resource } from "sst";
import { Handler } from "aws-lambda";
import { Example } from "@baml-test/core/example";
import pkg from '@boundaryml/baml'
import { b } from "../baml_client"
export const handler: Handler = async (_event) => {
const cr = new pkg.ClientRegistry()
// Creates a new client
console.log(Resource.OPENAI_API_KEY.value)
cr.addLlmClient('MyAmazingClient', 'openai', {
model: "gpt-4o-2024-11-20",
temperature: 0.7,
api_key: Resource.OPENAI_API_KEY.value
})
// Sets MyAmazingClient as the primary client
cr.setPrimary('MyAmazingClient')
const resume = await b.ExtractResume("hithere", { clientRegistry: cr })
const image = await b.ExtractImageContent(pkg.Image.fromUrl("..."), { env: {
OPENAI_API_KEY: Resource.OPENAI_API_KEY.value
}})
return {
statusCode: 200,
body: `${Example.hello()}. yes it works.... ${JSON.stringify(image)}`,
};
};wllvns
08/21/2025, 11:43 PMwllvns
08/21/2025, 11:44 PMwllvns
08/21/2025, 11:44 PMimport { bucket } from "./storage";
import { secrets } from "./secrets";
export const api = new sst.aws.ApiGatewayV2("Api");
// for when sstv3 supports lambda layers
// const installPackages = stack.stage === "prod" ? [] : ["@boundaryml/baml"];
// const bamlLayer =
// stack.stage === "prod"
// ? [
// new sst.aws.lambda.LayerVersion(stack, "BAMLLayer", {
// code: lambda.Code.fromAsset("layers/baml-layer"),
// }),
// ]
// : [];
api.route("GET /", {
link: [bucket, secrets.OpenAiApiKey],
runtime: "nodejs20.x",
environment: {
// OPENAI_API_KEY: process.env.OPENAI_API_KEY
},
nodejs: {
install: ["@boundaryml/baml", "@boundaryml/baml-linux-x64-gnu"],
// TBD which loader config we need (this one or the esbuild one)
loader: {
".node": "file",
},
esbuild: {
loader: {
".node": "file",
},
// TODO: add the lambda layer when sstv3 supports it (or upload it manually)
// since this will be in the lambda layer, don't include it in the final bundle
// external: ["@boundaryml/baml"],
},
},
handler: "packages/functions/src/api.handler",
});wllvns
08/21/2025, 11:45 PM