generator-begcode
Version:
Spring Boot + Angular/React/Vue in one handy generator
23 lines (22 loc) • 1.03 kB
JavaScript
import { OnGoalAchievedFunction, OnGoalFailedFunction } from '../../functions/index.js';
export class AgentConfig {
functions;
timeout;
shouldTerminate;
prompts;
constructor(promptFactory, functions, timeout, shouldTerminate, overrideDefaultFunctions) {
this.functions = functions;
this.timeout = timeout;
const onGoalAchievedFn = new OnGoalAchievedFunction();
const onGoalFailedFn = new OnGoalFailedFunction();
const defaultFunctions = !overrideDefaultFunctions ? [onGoalAchievedFn, onGoalFailedFn] : [];
const existingFunctions = new Map(functions.map(x => [x.name, x]));
functions.push(...defaultFunctions.filter(x => !existingFunctions.has(x.name)));
this.shouldTerminate =
shouldTerminate ??
(functionCalled => {
return [onGoalAchievedFn.name, onGoalFailedFn.name].includes(functionCalled.name);
});
this.prompts = promptFactory(onGoalAchievedFn, onGoalFailedFn);
}
}