Skip to content

Commit

Permalink
Merge branch 'v2-develop' into tcm/elevnlabs-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
tcm390 authored Feb 13, 2025
2 parents e6aba11 + 3e7996d commit 98b1070
Show file tree
Hide file tree
Showing 82 changed files with 2,397 additions and 555 deletions.
29 changes: 29 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
# OpenAI Configuration
OPENAI_API_KEY=

# Anthropic Configuration
ANTHROPIC_API_KEY=

# Fill these out if you want to use Discord
DISCORD_APPLICATION_ID=
DISCORD_API_TOKEN=

# Fill these out if you want to use Telegram
TELEGRAM_BOT_TOKEN=

# Fill these out if you want to use Twitter
TWITTER_USERNAME=
TWITTER_PASSWORD=
TWITTER_EMAIL=

# Fill these out if you want to use EVM
EVM_PRIVATE_KEY=
EVM_CHAINS=mainnet,sepolia,base,arbitrum,polygon
EVM_PROVIDER_URL=

# Fill these out if you want to use Solana
SOLANA_PUBLIC_KEY=
SOLANA_PRIVATE_KEY=
BIRDEYE_API_KEY=

# Swarm settings
COMPLIANCE_OFFICER_DISCORD_APPLICATION_ID=
COMPLIANCE_OFFICER_DISCORD_API_TOKEN=
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ node_modules
.env_main
concatenated-output.ts
embedding-cache.json
packages/plugin-buttplug/intiface-engine

node-compile-cache

Expand Down Expand Up @@ -50,10 +49,7 @@ characters/**/*.env
characters/**/*.key
characters/**/private/

packages/core/src/providers/cache
packages/core/src/providers/cache/*
cache/*
packages/plugin-coinbase/src/plugins/transactions.csv

tsup.config.bundled_*.mjs

Expand All @@ -71,10 +67,6 @@ eliza.manifest
eliza.manifest.sgx
eliza.sig

packages/plugin-nvidia-nim/extra
packages/plugin-nvidia-nim/old_code
packages/plugin-nvidia-nim/docs

# Edriziai specific ignores
characters/edriziai-info/secrets.json

Expand Down
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"lint": "turbo run lint:fix --filter=./packages/*",
"check": "biome check --apply .",
"preinstall": "npx only-allow bun",
"swarm": "turbo run build --filter=./packages/core && concurrently \"turbo run start --filter=@elizaos/agent -- --swarm \" \"turbo run start --filter=!@elizaos/agent --filter=!@elizaos/docs --filter=!@elizaos/core\"",
"build": "turbo run build --filter=./packages/core && turbo run build --filter=./packages/*",
"build:core": "turbo run build --filter=./packages/core",
"build:cli": "turbo run build --filter=./packages/cli && cd packages/cli && bun link",
Expand Down
1 change: 1 addition & 0 deletions packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"type": "module",
"scripts": {
"start": "node --loader ts-node/esm src/index.ts",
"swarm": "node --loader ts-node/esm src/index.ts --swarm",
"dev": "node --loader ts-node/esm src/index.ts",
"check-types": "tsc --noEmit",
"test": "vitest"
Expand Down
9 changes: 4 additions & 5 deletions packages/agent/src/defaultCharacter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ export const defaultCharacter: Character = {
name: "Eliza",
username: "eliza",
plugins: [
// "@elizaos/plugin-anthropic",
"@elizaos/plugin-anthropic",
"@elizaos/plugin-openai",
"@elizaos/plugin-elevenlabs",
// "@elizaos/plugin-local-ai",
// "@elizaos/plugin-discord",
"@elizaos/plugin-discord",
"@elizaos/plugin-node",
// "@elizaos/plugin-telegram",
// "@elizaos/plugin-twitter",
"@elizaos-plugins/evm"
// "@elizaos/plugin-evm",
// "@elizaos/plugin-solana",
],
settings: {
secrets: {},
Expand All @@ -37,8 +38,6 @@ export const defaultCharacter: Character = {
"Weaponizes charm and chaos in equal measure to make her point",
"She never uses emojis",
"She is an emoji-hater",
],
lore: [
"Child of a jazz musician and a theoretical physicist who met at a burlesque show",
"Spent formative years between Parisian cafes and Bangkok street markets",
"Got kicked out of three prestigious philosophy departments for 'excessive deconstruction'",
Expand Down
2 changes: 0 additions & 2 deletions packages/agent/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const messageHandlerTemplate =
# Task: Generate dialog and actions for the character {{agentName}}.
About {{agentName}}:
{{bio}}
{{lore}}
{{providers}}
Expand All @@ -44,7 +43,6 @@ export const hyperfiHandlerTemplate = `{{actionExamples}}
# Task: Generate dialog and actions for the character {{agentName}}.
About {{agentName}}:
{{bio}}
{{lore}}
{{providers}}
Expand Down
103 changes: 57 additions & 46 deletions packages/agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { fileURLToPath } from "node:url";
import yargs from "yargs";
import { defaultCharacter } from "./defaultCharacter.ts";
import { CharacterServer } from "./server";
import swarmCharacters from './swarm/defaultSwarm.ts';

const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
const __dirname = path.dirname(__filename); // get the name of the directory
Expand All @@ -45,6 +46,7 @@ export const logFetch = async (url: string, options: any) => {
export function parseArguments(): {
character?: string;
characters?: string;
swarm?: boolean;
} {
try {
return yargs(process.argv.slice(2))
Expand All @@ -57,6 +59,10 @@ export function parseArguments(): {
description:
"Comma separated list of paths to character JSON files",
})
.option("swarm", {
type: "boolean",
description: "Load characters from swarm/defaultSwarm.ts",
})
.parseSync();
} catch (error) {
logger.error("Error parsing arguments:", error);
Expand Down Expand Up @@ -348,7 +354,7 @@ async function findDatabaseAdapter(runtime: IAgentRuntime) {
let adapter: Adapter | undefined;
// if not found, default to sqlite
if (adapters.length === 0) {
const sqliteAdapterPlugin = await import('@elizaos-plugins/sqlite');
const sqliteAdapterPlugin = await import('@elizaos/plugin-sqlite');
const sqliteAdapterPluginDefault = sqliteAdapterPlugin.default;
adapter = sqliteAdapterPluginDefault.adapters[0];
if (!adapter) {
Expand Down Expand Up @@ -437,55 +443,60 @@ const hasValidRemoteUrls = () =>
process.env.REMOTE_CHARACTER_URLS !== "" &&
process.env.REMOTE_CHARACTER_URLS.startsWith("http");

const startAgents = async () => {
const characterServer = new CharacterServer();
let serverPort = Number.parseInt(settings.SERVER_PORT || "3000");
const args = parseArguments();
const charactersArg = args.characters || args.character;
let characters = [defaultCharacter];

if ((charactersArg) || hasValidRemoteUrls()) {
characters = await loadCharacters(charactersArg);
}

try {
for (const character of characters) {
await startAgent(character, characterServer);
const startAgents = async () => {
const characterServer = new CharacterServer();
let serverPort = Number.parseInt(settings.SERVER_PORT || "3000");
const args = parseArguments();
const charactersArg = args.characters || args.character;
let characters = [defaultCharacter];

if (args.swarm) {
try {
characters = swarmCharacters;
logger.info("Loaded characters from swarm configuration");
} catch (error) {
logger.error("Error loading swarm characters:", error);
process.exit(1);
}
} else if ((charactersArg) || hasValidRemoteUrls()) {
characters = await loadCharacters(charactersArg);
}
} catch (error) {
logger.error("Error starting agents:", error);
}

// Find available port
while (!(await checkPortAvailable(serverPort))) {
logger.warn(
`Port ${serverPort} is in use, trying ${serverPort + 1}`

try {
for (const character of characters) {
await startAgent(character, characterServer);
}
} catch (error) {
logger.error("Error starting agents:", error);
}

// Rest of the function remains the same...
while (!(await checkPortAvailable(serverPort))) {
logger.warn(
`Port ${serverPort} is in use, trying ${serverPort + 1}`
);
serverPort++;
}

characterServer.startAgent = async (character) => {
logger.info(`Starting agent for character ${character.name}`);
return startAgent(character, characterServer);
};

characterServer.loadCharacterTryPath = loadCharacterTryPath;
characterServer.jsonToCharacter = jsonToCharacter;

characterServer.start(serverPort);

if (serverPort !== Number.parseInt(settings.SERVER_PORT || "3000")) {
logger.log(`Server started on alternate port ${serverPort}`);
}

logger.info(
"Run `bun start:client` to start the client and visit the outputted URL (http://localhost:5173) to chat with your agents. When running multiple agents, use client with different port `SERVER_PORT=3001 bun start:client`"
);
serverPort++;
}

// upload some agent functionality into characterServer
// XXX TODO: is this still used?
characterServer.startAgent = async (character) => {
logger.info(`Starting agent for character ${character.name}`);
// wrap it so we don't have to inject characterServer later
return startAgent(character, characterServer);
};

characterServer.loadCharacterTryPath = loadCharacterTryPath;
characterServer.jsonToCharacter = jsonToCharacter;

characterServer.start(serverPort);

if (serverPort !== Number.parseInt(settings.SERVER_PORT || "3000")) {
logger.log(`Server started on alternate port ${serverPort}`);
}

logger.info(
"Run `bun start:client` to start the client and visit the outputted URL (http://localhost:5173) to chat with your agents. When running multiple agents, use client with different port `SERVER_PORT=3001 bun start:client`"
);
};

startAgents().catch((error) => {
logger.error("Unhandled error in startAgents:", error);
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/src/plugins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function findDatabaseAdapter(runtime: IAgentRuntime) {

// Default to sqlite if no adapter found
if (adapters.length === 0) {
const sqliteAdapter = await import('@elizaos-plugins/sqlite');
const sqliteAdapter = await import('@elizaos/plugin-sqlite');
adapter = sqliteAdapter.default.adapters[0];
if (!adapter) {
throw new Error("No database adapter found in default sqlite plugin");
Expand Down
7 changes: 4 additions & 3 deletions packages/agent/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ export class CharacterServer {
return;
}

const transcription = await runtime.useModel(ModelClass.TRANSCRIPTION, fs.createReadStream(audioFile.path));

res.json(transcription);
const audioBuffer = fs.readFileSync(audioFile.path);
const transcription = await runtime.useModel(ModelClass.TRANSCRIPTION, audioBuffer);

res.json({text: transcription});
}
);

Expand Down
Empty file.
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 98b1070

Please sign in to comment.