node-agency
Version:
A node package for building AI agents
53 lines • 2.31 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logger = void 0;
const colors_1 = __importDefault(require("colors"));
const Logger = (params) => {
const { type, payload } = params;
switch (type) {
case "agent":
try {
const { role, systemMessage, newPrompt } = JSON.parse(payload);
console.log(colors_1.default.yellow(`CALLING AGENT`), colors_1.default.blue(`${role}`), `with`, colors_1.default.blue(`'${systemMessage}'`), `\nWith Input:`, colors_1.default.blue(`'${newPrompt}'\n`));
}
catch (e) {
console.error(colors_1.default.yellow("CALLING AGENT"), colors_1.default.blue(payload) + "\n\n");
}
break;
case "results":
try {
const { role, agentResults } = JSON.parse(payload);
console.log(colors_1.default.yellow(`\nAgent`), colors_1.default.blue(`'${role}'`), `Results:\n`, colors_1.default.blue(`${agentResults}\n\n`));
}
catch (e) {
console.error(colors_1.default.yellow("Agent Results"), colors_1.default.blue(payload) + "\n\n");
}
break;
case "function":
try {
const { name, params } = JSON.parse(payload);
console.log(colors_1.default.yellow("CALLING FUNCTION:"), colors_1.default.blue(`'${name}'`), "with params:", JSON.parse(params), "\n\n");
}
catch (e) {
console.error(colors_1.default.yellow("CALLING FUNCTION"), colors_1.default.blue(payload) + "\n\n");
}
break;
case "info":
console.log(colors_1.default.blue("INFO: "), payload);
break;
case "error":
console.error(colors_1.default.red("ERROR: "), payload);
break;
case "warn":
console.warn(colors_1.default.yellow("WARN: "), payload);
break;
default:
console.log(colors_1.default.blue("DEBUG: "), payload);
break;
}
};
exports.Logger = Logger;
//# sourceMappingURL=logger.js.map