jcrewai
Version:
Multi-agent automation framework written in TypeScript. Patterned after CrewAI.
30 lines (29 loc) • 1.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Agent = void 0;
const BaseAgent_1 = require("./agents/BaseAgent");
const CrewAgentExecutor_1 = require("./agents/CrewAgentExecutor");
const Prompts_1 = require("./utilities/Prompts");
class Agent extends BaseAgent_1.BaseAgent {
constructor(options) {
super(options);
}
createAgentExecutor() {
const prompt = new Prompts_1.Prompts(this, this.i18n).taskExecution();
this.agentExecutor = new CrewAgentExecutor_1.CrewAgentExecutor(this, this.crew, prompt, this.llm);
}
async executeTask(task) {
console.log(`Agent, ${this.name}, executing task '${task.name}'`);
const taskPrompt = task.prompt();
//TESTING ONLY
// (this.llm as BaseLlm).call();
if (this.agentExecutor) {
const result = await this.agentExecutor.invoke({
input: taskPrompt
});
return result['output'];
}
throw new Error('Agent Executor is not set. Unable to execute task.');
}
}
exports.Agent = Agent;