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

feat: agent index code #2541

Closed
wants to merge 1 commit into from
Closed
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
26 changes: 16 additions & 10 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ import { hyperliquidPlugin } from "@elizaos/plugin-hyperliquid";
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
import { dexScreenerPlugin } from "@elizaos/plugin-dexscreener";
import { pythDataPlugin } from "@elizaos/plugin-pyth-data";
import { openaiPlugin } from '@elizaos/plugin-openai';
import { openaiPlugin } from "@elizaos/plugin-openai";

import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
import Database from "better-sqlite3";
Expand Down Expand Up @@ -208,7 +208,9 @@ export async function loadCharacterFromOnchain(): Promise<Character[]> {

// .id isn't really valid
const characterId = character.id || character.name;
const characterPrefix = `CHARACTER.${characterId.toUpperCase().replace(/ /g, "_")}.`;
const characterPrefix = `CHARACTER.${characterId
.toUpperCase()
.replace(/ /g, "_")}.`;

const characterSettings = Object.entries(process.env)
.filter(([key]) => key.startsWith(characterPrefix))
Expand Down Expand Up @@ -280,7 +282,9 @@ async function jsonToCharacter(

// .id isn't really valid
const characterId = character.id || character.name;
const characterPrefix = `CHARACTER.${characterId.toUpperCase().replace(/ /g, "_")}.`;
const characterPrefix = `CHARACTER.${characterId
.toUpperCase()
.replace(/ /g, "_")}.`;
const characterSettings = Object.entries(process.env)
.filter(([key]) => key.startsWith(characterPrefix))
.reduce((settings, [key, value]) => {
Expand Down Expand Up @@ -390,8 +394,9 @@ export async function loadCharacters(
if (characterPaths?.length > 0) {
for (const characterPath of characterPaths) {
try {
const character: Character =
await loadCharacterTryPath(characterPath);
const character: Character = await loadCharacterTryPath(
characterPath
);
loadedCharacters.push(character);
} catch (e) {
process.exit(1);
Expand Down Expand Up @@ -554,9 +559,10 @@ export function getTokenForProvider(
settings.VENICE_API_KEY
);
case ModelProviderName.ATOMA:
return (
character.settings?.secrets?.ATOMASDK_BEARER_AUTH ||
settings.ATOMASDK_BEARER_AUTH
return (
character.settings?.secrets?.ATOMASDK_BEARER_AUTH ||
settings.ATOMASDK_BEARER_AUTH
);
case ModelProviderName.NVIDIA:
return (
character.settings?.secrets?.NVIDIA_API_KEY ||
Expand Down Expand Up @@ -1049,7 +1055,8 @@ export async function createAgent(
getSecret(character, "PYTH_MAINNET_PROGRAM_KEY")
? pythDataPlugin
: null,
getSecret(character, "OPENAI_API_KEY") && getSecret(character, "ENABLE_OPEN_AI_COMMUNITY_PLUGIN")
getSecret(character, "OPENAI_API_KEY") &&
getSecret(character, "ENABLE_OPEN_AI_COMMUNITY_PLUGIN")
? openaiPlugin
: null,
].filter(Boolean),
Expand Down Expand Up @@ -1295,4 +1302,3 @@ if (
console.error("unhandledRejection", err);
});
}

Loading