Skip to content

Commit

Permalink
Merge branch 'develop' into feat/autonome
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsayo authored Jan 10, 2025
2 parents ccfd33b + b249393 commit 5fada5c
Show file tree
Hide file tree
Showing 45 changed files with 3,318 additions and 4,250 deletions.
7 changes: 6 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,12 @@ TOGETHER_API_KEY= # Together API Key
#### Crypto Plugin Configurations ####
######################################

# COIN DATA SOURCES
# CoinMarketCap / CMC
COINMARKETCAP_API_KEY=

# CoinGecko
COINGECKO_API_KEY=
COINGECKO_PRO_API_KEY=

# EVM
EVM_PRIVATE_KEY=
Expand Down Expand Up @@ -438,6 +441,8 @@ GIPHY_API_KEY=
# OpenWeather
OPEN_WEATHER_API_KEY= # OpenWeather API key



# EchoChambers Configuration
ECHOCHAMBERS_API_URL=http://127.0.0.1:3333
ECHOCHAMBERS_API_KEY=testingkey0011
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pnpm-lockfile-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Pnpm Lockfile Check

on:
pull_request:
branches: ["*"]
branches: [main]

jobs:
check-lockfile:
Expand Down Expand Up @@ -38,4 +38,4 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
body: '❌ The pnpm-lockfile is out of date. Please run `pnpm install --no-frozen-lockfile` and commit the updated pnpm-lock.yaml file.'
})
})
4 changes: 3 additions & 1 deletion agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@elizaos/plugin-0g": "workspace:*",
"@elizaos/plugin-abstract": "workspace:*",
"@elizaos/plugin-aptos": "workspace:*",
"@elizaos/plugin-coingecko": "workspace:*",
"@elizaos/plugin-coinmarketcap": "workspace:*",
"@elizaos/plugin-coingecko": "workspace:*",
"@elizaos/plugin-binance": "workspace:*",
Expand Down Expand Up @@ -74,6 +75,7 @@
"@elizaos/plugin-3d-generation": "workspace:*",
"@elizaos/plugin-fuel": "workspace:*",
"@elizaos/plugin-avalanche": "workspace:*",
"@elizaos/plugin-video-generation": "workspace:*",
"@elizaos/plugin-web-search": "workspace:*",
"@elizaos/plugin-letzai": "workspace:*",
"@elizaos/plugin-thirdweb": "workspace:*",
Expand All @@ -95,4 +97,4 @@
"ts-node": "10.9.2",
"tsup": "8.3.5"
}
}
}
60 changes: 43 additions & 17 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,19 @@ import { nearPlugin } from "@elizaos/plugin-near";
import { nftGenerationPlugin } from "@elizaos/plugin-nft-generation";
import { createNodePlugin } from "@elizaos/plugin-node";
import { obsidianPlugin } from "@elizaos/plugin-obsidian";
import { sgxPlugin } from "@elizaos/plugin-sgx";
import { solanaPlugin } from "@elizaos/plugin-solana";
import { solanaAgentkitPlguin } from "@elizaos/plugin-solana-agentkit";
import { autonomePlugin } from "@elizaos/plugin-autonome";
import { storyPlugin } from "@elizaos/plugin-story";
import { suiPlugin } from "@elizaos/plugin-sui";
import { sgxPlugin } from "@elizaos/plugin-sgx";
import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
import { teeLogPlugin } from "@elizaos/plugin-tee-log";
import { teeMarlinPlugin } from "@elizaos/plugin-tee-marlin";
import { tonPlugin } from "@elizaos/plugin-ton";
import { webSearchPlugin } from "@elizaos/plugin-web-search";

import { coingeckoPlugin } from "@elizaos/plugin-coingecko";
import { giphyPlugin } from "@elizaos/plugin-giphy";
import { letzAIPlugin } from "@elizaos/plugin-letzai";
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
Expand Down Expand Up @@ -142,10 +143,6 @@ 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 @@ -231,16 +228,9 @@ export async function loadCharacters(
}

// Handle 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.default;
})
);
character.plugins = importedPlugins;
}
character.plugins = await handlePluginImporting(
character.plugins
);

loadedCharacters.push(character);
elizaLogger.info(
Expand All @@ -263,6 +253,36 @@ export async function loadCharacters(
return loadedCharacters;
}

async function handlePluginImporting(plugins: string[]) {
if (plugins.length > 0) {
elizaLogger.info("Plugins are: ", plugins);
const importedPlugins = await Promise.all(
plugins.map(async (plugin) => {
try {
const importedPlugin = await import(plugin);
const functionName =
plugin
.replace("@elizaos/plugin-", "")
.replace(/-./g, (x) => x[1].toUpperCase()) +
"Plugin"; // Assumes plugin function is camelCased with Plugin suffix
return (
importedPlugin.default || importedPlugin[functionName]
);
} catch (importError) {
elizaLogger.error(
`Failed to import plugin: ${plugin}`,
importError
);
return []; // Return null for failed imports
}
})
);
return importedPlugins;
} else {
return [];
}
}

export function getTokenForProvider(
provider: ModelProviderName,
character: Character
Expand Down Expand Up @@ -680,7 +700,10 @@ export async function createAgent(
? webhookPlugin
: null,
goatPlugin,
getSecret(character, "COINGECKO_API_KEY") ? coingeckoPlugin : null,
getSecret(character, "COINGECKO_API_KEY") ||
getSecret(character, "COINGECKO_PRO_API_KEY")
? coingeckoPlugin
: null,
getSecret(character, "EVM_PROVIDER_URL") ? goatPlugin : null,
getSecret(character, "ABSTRACT_PRIVATE_KEY")
? abstractPlugin
Expand Down Expand Up @@ -919,7 +942,10 @@ const startAgents = async () => {
}

// upload some agent functionality into directClient
directClient.startAgent = async (character: Character) => {
directClient.startAgent = async (character) => {
// Handle plugins
character.plugins = await handlePluginImporting(character.plugins);

// wrap it so we don't have to inject directClient later
return startAgent(character, directClient);
};
Expand Down
3 changes: 3 additions & 0 deletions packages/client-twitter/src/plugins/SttTtsSpacesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ interface PluginConfig {
* - On speaker mute -> flush STT -> GPT -> TTS -> push to Janus
*/
export class SttTtsPlugin implements Plugin {
name = "SttTtsPlugin";
description = "Speech-to-text (OpenAI) + conversation + TTS (ElevenLabs)";

private space?: Space;
private janus?: JanusClient;

Expand Down
Loading

0 comments on commit 5fada5c

Please sign in to comment.