Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: When the plugins field in the .character.json file is configured with plugin name. #784

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ function tryLoadFile(filePath: string): string | null {
}
}

function isAllStrings(arr: unknown[]): boolean {
return Array.isArray(arr) && arr.every((item) => typeof item === "string");
}

export async function loadCharacters(
charactersArg: string
): Promise<Character[]> {
Expand Down Expand Up @@ -149,12 +153,12 @@ export async function loadCharacters(
validateCharacterConfig(character);

// Handle plugins
if (character.plugins) {
if (isAllStrings(character.plugins)) {
elizaLogger.info("Plugins are: ", character.plugins);
const importedPlugins = await Promise.all(
character.plugins.map(async (plugin) => {
const importedPlugin = await import(plugin);
return importedPlugin;
return importedPlugin.default;
})
);
character.plugins = importedPlugins;
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/enviroment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ export const CharacterSchema = z.object({
adjectives: z.array(z.string()),
knowledge: z.array(z.string()).optional(),
clients: z.array(z.nativeEnum(Clients)),
plugins: z.array(PluginSchema),
plugins: z.union([
z.array(z.string()),
z.array(PluginSchema),
]),
settings: z
.object({
secrets: z.record(z.string()).optional(),
Expand Down