jcrewai
Version:
Multi-agent automation framework written in TypeScript. Patterned after CrewAI.
38 lines (37 loc) • 1.42 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseAgent = void 0;
const Llm_1 = require("../Llm");
const stringUtils_1 = require("../utilities/stringUtils");
class BaseAgent {
constructor(options) {
this.verbose = false;
this.config = options.config;
this.role = options.role ?? this.config?.role;
this.goal = options.goal ?? this.config?.goal;
this.backstory = options.backstory ?? this.config?.backstory;
this.llm = options.llm ?? this.config?.llm ?? process.env.MODEL;
this.verbose = options.verbose ?? false;
// this.i18n = options.i18n;
if (typeof this.llm === 'string') {
this.llm = new Llm_1.Llm({ model: this.llm });
}
}
interpolateInputs(inputs) {
if (!this.originalRole) {
this.originalRole = this.role ?? '';
}
if (!this.originalGoal) {
this.originalGoal = this.goal ?? '';
}
if (!this.originalBackstory) {
this.originalBackstory = this.backstory ?? '';
}
if (inputs) {
this.role = (0, stringUtils_1.interpolate)(this.originalRole, inputs);
this.goal = (0, stringUtils_1.interpolate)(this.originalGoal, inputs);
this.backstory = (0, stringUtils_1.interpolate)(this.originalBackstory, inputs);
}
}
}
exports.BaseAgent = BaseAgent;