Skip to main content

Agent Executors

为了让智能代理更加强大,我们需要使其迭代,即调用模型多次,直到达到最终答案。这就是 AgentExecutor 的工作。

class AgentExecutor {

// a simplified implementation

run(inputs: object) {

const steps = [];

while (true) {

const step = await this.agent.plan(steps, inputs);

if (step instanceof AgentFinish) {

return step.returnValues;

}

steps.push(step);

}

}

}