@autobe/agent
Version:
AI backend server code generator
56 lines • 3.58 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.orchestrateTestCorrectCasting = void 0;
const uuid_1 = require("uuid");
const executeCachedBatch_1 = require("../../../utils/executeCachedBatch");
const validateEmptyCode_1 = require("../../../utils/validateEmptyCode");
const orchestrateCommonCorrectCasting_1 = require("../../common/orchestrateCommonCorrectCasting");
const orchestrateTestCorrectCasting = (ctx, props) => __awaiter(void 0, void 0, void 0, function* () {
const result = yield (0, executeCachedBatch_1.executeCachedBatch)(ctx, props.procedures.map((procedure) => () => __awaiter(void 0, void 0, void 0, function* () {
try {
const event = yield (0, orchestrateCommonCorrectCasting_1.orchestrateCommonCorrectCasting)(ctx, {
source: "testCorrect",
compile: (content) => props.programmer.compile(Object.assign(Object.assign({}, procedure), { function: Object.assign(Object.assign({}, procedure.function), { content }) })),
correct: (next) => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b, _c;
return ({
type: "testCorrect",
kind: "casting",
id: (0, uuid_1.v7)(),
created_at: new Date().toISOString(),
function: Object.assign(Object.assign({}, procedure.function), { content: yield props.programmer.replaceImportStatements(Object.assign(Object.assign({}, procedure), { function: Object.assign(Object.assign({}, procedure.function), { content: (_a = next.final) !== null && _a !== void 0 ? _a : next.draft }) })) }),
result: next.failure,
tokenUsage: next.tokenUsage,
metric: next.metric,
step: (_c = (_b = ctx.state().analyze) === null || _b === void 0 ? void 0 : _b.step) !== null && _c !== void 0 ? _c : 0,
});
}),
script: (event) => event.function.content,
validateEmptyCode: (next) => (0, validateEmptyCode_1.validateEmptyCode)({
name: procedure.function.name,
path: next.path,
asynchronous: props.programmer.asynchronous,
draft: next.draft,
revise: next.revise,
}),
location: procedure.function.location,
}, procedure.function.content);
return Object.assign(Object.assign({}, procedure), { function: event.function });
}
catch (_a) {
return procedure;
}
})));
return result.filter((r) => r !== null);
});
exports.orchestrateTestCorrectCasting = orchestrateTestCorrectCasting;
//# sourceMappingURL=orchestrateTestCorrectCasting.js.map