Merge pull request #179 from ereid7/feat-profile-arg

feat: support --profiles arg
This commit is contained in:
Max Robinson 2024-10-06 21:33:38 -05:00 committed by GitHub
commit 7abf30c353
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 39 additions and 5 deletions

View file

@ -62,6 +62,11 @@ Bot profiles are json files (such as `andy.json`) that define:
2. Prompts used to influence the bot's behavior.
3. Examples help the bot perform tasks.
### Specifying Profiles via Command Line
By default, the program will use the profiles specified in `settings.js`. You can specify one or more agent profiles using the `--profiles` argument:
`node main.js --profiles ./profiles/andy.json ./profiles/jill.json`
### Model Specifications

39
main.js
View file

@ -1,9 +1,38 @@
import { AgentProcess } from './src/process/agent-process.js';
import settings from './settings.js';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
let profiles = settings.profiles;
let load_memory = settings.load_memory;
let init_message = settings.init_message;
function parseArguments() {
return yargs(hideBin(process.argv))
.option('profiles', {
type: 'array',
describe: 'List of agent profile paths',
})
.help()
.alias('help', 'h')
.parse();
}
for (let profile of profiles)
new AgentProcess().start(profile, load_memory, init_message);
function getProfiles(args) {
return args.profiles || settings.profiles;
}
function main() {
const args = parseArguments();
const profiles = getProfiles(args);
console.log(profiles);
const { load_memory, init_message } = settings;
for (const profile of profiles) {
const agent = new AgentProcess();
agent.start(profile, load_memory, init_message);
}
}
try {
main();
} catch (error) {
console.error('An error occurred:', error);
process.exit(1);
}