@boundaryml/baml
Advanced tools
Comparing version 0.58.0 to 0.59.0
export { BamlRuntime, FunctionResult, FunctionResultStream, BamlImage as Image, ClientBuilder, BamlAudio as Audio, invoke_runtime_cli, ClientRegistry, BamlLogEvent, } from './native'; | ||
export { BamlStream } from './stream'; | ||
export { BamlCtxManager } from './async_context_vars'; | ||
export declare class BamlValidationError extends Error { | ||
prompt: string; | ||
raw_output: string; | ||
constructor(prompt: string, raw_output: string, message: string); | ||
static from(error: Error): BamlValidationError | Error; | ||
toJSON(): string; | ||
} | ||
export declare function createBamlValidationError(error: Error): BamlValidationError | Error; | ||
//# sourceMappingURL=index.d.ts.map |
46
index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BamlCtxManager = exports.BamlStream = exports.BamlLogEvent = exports.ClientRegistry = exports.invoke_runtime_cli = exports.Audio = exports.ClientBuilder = exports.Image = exports.FunctionResultStream = exports.FunctionResult = exports.BamlRuntime = void 0; | ||
exports.createBamlValidationError = exports.BamlValidationError = exports.BamlCtxManager = exports.BamlStream = exports.BamlLogEvent = exports.ClientRegistry = exports.invoke_runtime_cli = exports.Audio = exports.ClientBuilder = exports.Image = exports.FunctionResultStream = exports.FunctionResult = exports.BamlRuntime = void 0; | ||
var native_1 = require("./native"); | ||
@@ -18,1 +18,45 @@ Object.defineProperty(exports, "BamlRuntime", { enumerable: true, get: function () { return native_1.BamlRuntime; } }); | ||
Object.defineProperty(exports, "BamlCtxManager", { enumerable: true, get: function () { return async_context_vars_1.BamlCtxManager; } }); | ||
class BamlValidationError extends Error { | ||
prompt; | ||
raw_output; | ||
constructor(prompt, raw_output, message) { | ||
super(message); | ||
this.name = 'BamlValidationError'; | ||
this.prompt = prompt; | ||
this.raw_output = raw_output; | ||
Object.setPrototypeOf(this, BamlValidationError.prototype); | ||
} | ||
static from(error) { | ||
if (error.message.includes('BamlValidationError')) { | ||
try { | ||
const errorData = JSON.parse(error.message); | ||
if (errorData.type === 'BamlValidationError') { | ||
return new BamlValidationError(errorData.prompt || '', errorData.raw_output || '', errorData.message || error.message); | ||
} | ||
else { | ||
console.warn('Not a BamlValidationError:', error); | ||
} | ||
} | ||
catch (parseError) { | ||
// If JSON parsing fails, fall back to the original error | ||
console.warn('Failed to parse BamlValidationError:', parseError); | ||
} | ||
} | ||
// If it's not a BamlValidationError or parsing failed, return the original error | ||
return error; | ||
} | ||
toJSON() { | ||
return JSON.stringify({ | ||
message: this.message, | ||
raw_output: this.raw_output, | ||
prompt: this.prompt, | ||
}, null, 2); | ||
} | ||
} | ||
exports.BamlValidationError = BamlValidationError; | ||
// Helper function to safely create a BamlValidationError | ||
function createBamlValidationError(error) { | ||
return BamlValidationError.from(error); | ||
} | ||
exports.createBamlValidationError = createBamlValidationError; | ||
// No need for a separate throwBamlValidationError function in TypeScript |
{ | ||
"name": "@boundaryml/baml", | ||
"version": "0.58.0", | ||
"version": "0.59.0", | ||
"description": "BAML typescript bindings (package.json)", | ||
@@ -83,9 +83,9 @@ "repository": { | ||
"optionalDependencies": { | ||
"@boundaryml/baml-darwin-arm64": "0.58.0", | ||
"@boundaryml/baml-win32-arm64-msvc": "0.58.0", | ||
"@boundaryml/baml-linux-arm64-gnu": "0.58.0", | ||
"@boundaryml/baml-darwin-x64": "0.58.0", | ||
"@boundaryml/baml-win32-x64-msvc": "0.58.0", | ||
"@boundaryml/baml-linux-x64-gnu": "0.58.0" | ||
"@boundaryml/baml-darwin-arm64": "0.59.0", | ||
"@boundaryml/baml-win32-arm64-msvc": "0.59.0", | ||
"@boundaryml/baml-linux-arm64-gnu": "0.59.0", | ||
"@boundaryml/baml-darwin-x64": "0.59.0", | ||
"@boundaryml/baml-win32-x64-msvc": "0.59.0", | ||
"@boundaryml/baml-linux-x64-gnu": "0.59.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34600
938