Skip to content

Commit

Permalink
rerun build script
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronvg committed Dec 3, 2024
1 parent 2039f19 commit 0fe2c37
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 24 deletions.
17 changes: 12 additions & 5 deletions engine/language_client_typescript/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
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 { 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 BamlClientFinishReasonError extends Error {
prompt: string;
raw_output: string;
constructor(prompt: string, raw_output: string, message: string);
toJSON(): string;
static from(error: Error): BamlClientFinishReasonError | undefined;
}
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;
static from(error: Error): BamlValidationError | undefined;
}
export declare function createBamlValidationError(error: Error): BamlValidationError | Error;
export declare function createBamlValidationError(error: Error): BamlValidationError | BamlClientFinishReasonError | Error;
//# sourceMappingURL=index.d.ts.map
2 changes: 1 addition & 1 deletion engine/language_client_typescript/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 55 additions & 12 deletions engine/language_client_typescript/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
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;
exports.createBamlValidationError = exports.BamlValidationError = exports.BamlClientFinishReasonError = 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");
Object.defineProperty(exports, "BamlRuntime", { enumerable: true, get: function () { return native_1.BamlRuntime; } });
Object.defineProperty(exports, "FunctionResult", { enumerable: true, get: function () { return native_1.FunctionResult; } });
Expand All @@ -15,47 +15,90 @@ var stream_1 = require("./stream");
Object.defineProperty(exports, "BamlStream", { enumerable: true, get: function () { return stream_1.BamlStream; } });
var async_context_vars_1 = require("./async_context_vars");
Object.defineProperty(exports, "BamlCtxManager", { enumerable: true, get: function () { return async_context_vars_1.BamlCtxManager; } });
class BamlValidationError extends Error {
class BamlClientFinishReasonError extends Error {
prompt;
raw_output;
constructor(prompt, raw_output, message) {
super(message);
this.name = 'BamlValidationError';
this.name = "BamlClientFinishReasonError";
this.prompt = prompt;
this.raw_output = raw_output;
Object.setPrototypeOf(this, BamlValidationError.prototype);
Object.setPrototypeOf(this, BamlClientFinishReasonError.prototype);
}
toJSON() {
return JSON.stringify({
name: this.name,
message: this.message,
raw_output: this.raw_output,
prompt: this.prompt,
}, null, 2);
}
static from(error) {
if (error.message.includes('BamlValidationError')) {
if (error.message.includes("BamlClientFinishReasonError")) {
try {
const errorData = JSON.parse(error.message);
if (errorData.type === 'BamlValidationError') {
return new BamlValidationError(errorData.prompt || '', errorData.raw_output || '', errorData.message || error.message);
if (errorData.type === "BamlClientFinishReasonError") {
return new BamlClientFinishReasonError(errorData.prompt || "", errorData.raw_output || "", errorData.message || error.message);
}
else {
console.warn('Not a BamlValidationError:', error);
console.warn("Not a BamlClientFinishReasonError:", error);
}
}
catch (parseError) {
// If JSON parsing fails, fall back to the original error
console.warn('Failed to parse BamlValidationError:', parseError);
console.warn("Failed to parse BamlClientFinishReasonError:", parseError);
}
}
// If it's not a BamlValidationError or parsing failed, return the original error
return error;
return undefined;
}
}
exports.BamlClientFinishReasonError = BamlClientFinishReasonError;
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);
}
toJSON() {
return JSON.stringify({
name: this.name,
message: this.message,
raw_output: this.raw_output,
prompt: this.prompt,
}, null, 2);
}
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);
}
}
catch (parseError) {
console.warn("Failed to parse BamlValidationError:", parseError);
}
}
return undefined;
}
}
exports.BamlValidationError = BamlValidationError;
// Helper function to safely create a BamlValidationError
function createBamlValidationError(error) {
return BamlValidationError.from(error);
const bamlValidationError = BamlValidationError.from(error);
if (bamlValidationError) {
return bamlValidationError;
}
const bamlClientFinishReasonError = BamlClientFinishReasonError.from(error);
if (bamlClientFinishReasonError) {
return bamlClientFinishReasonError;
}
// otherwise return the original error
return error;
}
exports.createBamlValidationError = createBamlValidationError;
// No need for a separate throwBamlValidationError function in TypeScript
Loading

0 comments on commit 0fe2c37

Please sign in to comment.