openai-swarmjs
Version:
Agentic framework inspired from OpenAI's swarm framework for TS, JS
28 lines (27 loc) • 801 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseAgent = void 0;
class BaseAgent {
constructor(goal, functions, agent) {
this.goal = goal;
this.functions = functions;
this.agent = agent;
}
getAgent() {
return this.agent;
}
// Make utility methods static so they can be used before super()
static sanitizeFunctionName(name) {
return name.replace(/[^a-zA-Z0-9_-]/g, '_');
}
static buildFunctionDescriptions(functions) {
return functions
.map(f => ({
name: this.sanitizeFunctionName(f.name),
description: f.description
}))
.map(f => `${f.name}: ${f.description}`)
.join('\n');
}
}
exports.BaseAgent = BaseAgent;
;