Skip to content

Commit 7a1fd02

Browse files
authored
Merge pull request #1045 from ai16z/develop
chore: release develop into main
2 parents 23a0c30 + aa51205 commit 7a1fd02

31 files changed

+1622
-354
lines changed

.env.example

+10
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ WALLET_SECRET_SALT= # ONLY DEFINE IF YOU WANT TO USE TEE Plugin, otherwise it wi
225225
# Galadriel Configuration
226226
GALADRIEL_API_KEY=gal-* # Get from https://dashboard.galadriel.com/
227227

228+
# Venice Configuration
229+
VENICE_API_KEY= # generate from venice settings
230+
SMALL_VENICE_MODEL= # Default: llama-3.3-70b
231+
MEDIUM_VENICE_MODEL= # Default: llama-3.3-70b
232+
LARGE_VENICE_MODEL= # Default: llama-3.1-405b
233+
228234
# fal.ai Configuration
229235
FAL_API_KEY=
230236
FAL_AI_LORA_PATH=
@@ -264,3 +270,7 @@ AWS_SECRET_ACCESS_KEY=
264270
AWS_REGION=
265271
AWS_S3_BUCKET=
266272
AWS_S3_UPLOAD_PATH=
273+
274+
275+
# Deepgram
276+
DEEPGRAM_API_KEY=

.github/workflows/integrationTests.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
push:
44
branches:
55
- "*"
6-
pull_request:
6+
pull_request_target:
77
branches:
88
- "*"
99
jobs:

agent/src/index.ts

+40-17
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ export function getTokenForProvider(
286286
character.settings?.secrets?.HYPERBOLIC_API_KEY ||
287287
settings.HYPERBOLIC_API_KEY
288288
);
289+
case ModelProviderName.VENICE:
290+
return (
291+
character.settings?.secrets?.VENICE_API_KEY ||
292+
settings.VENICE_API_KEY
293+
);
289294
}
290295
}
291296

@@ -318,42 +323,53 @@ function initializeDatabase(dataDir: string) {
318323
}
319324
}
320325

326+
// also adds plugins from character file into the runtime
321327
export async function initializeClients(
322328
character: Character,
323329
runtime: IAgentRuntime
324330
) {
325-
const clients = [];
326-
const clientTypes =
331+
// each client can only register once
332+
// and if we want two we can explicitly support it
333+
const clients: Record<string, any> = {};
334+
const clientTypes:string[] =
327335
character.clients?.map((str) => str.toLowerCase()) || [];
336+
elizaLogger.log('initializeClients', clientTypes, 'for', character.name)
328337

329338
if (clientTypes.includes("auto")) {
330339
const autoClient = await AutoClientInterface.start(runtime);
331-
if (autoClient) clients.push(autoClient);
340+
if (autoClient) clients.auto = autoClient;
332341
}
333342

334343
if (clientTypes.includes("discord")) {
335-
clients.push(await DiscordClientInterface.start(runtime));
344+
const discordClient = await DiscordClientInterface.start(runtime);
345+
if (discordClient) clients.discord = discordClient;
336346
}
337347

338348
if (clientTypes.includes("telegram")) {
339349
const telegramClient = await TelegramClientInterface.start(runtime);
340-
if (telegramClient) clients.push(telegramClient);
350+
if (telegramClient) clients.telegram = telegramClient;
341351
}
342352

343353
if (clientTypes.includes("twitter")) {
344354
TwitterClientInterface.enableSearch = !isFalsish(getSecret(character, "TWITTER_SEARCH_ENABLE"));
345-
const twitterClients = await TwitterClientInterface.start(runtime);
346-
clients.push(twitterClients);
355+
const twitterClient = await TwitterClientInterface.start(runtime);
356+
if (twitterClient) clients.twitter = twitterClient;
347357
}
348358

349359
if (clientTypes.includes("farcaster")) {
350-
const farcasterClients = new FarcasterAgentClient(runtime);
351-
farcasterClients.start();
352-
clients.push(farcasterClients);
360+
// why is this one different :(
361+
const farcasterClient = new FarcasterAgentClient(runtime);
362+
if (farcasterClient) {
363+
farcasterClient.start();
364+
clients.farcaster = farcasterClient;
365+
}
353366
}
354367

368+
elizaLogger.log('client keys', Object.keys(clients));
369+
355370
if (character.plugins?.length > 0) {
356371
for (const plugin of character.plugins) {
372+
// if plugin has clients, add those..
357373
if (plugin.clients) {
358374
for (const client of plugin.clients) {
359375
clients.push(await client.start(runtime));
@@ -382,7 +398,7 @@ function isFalsish(input: any): boolean {
382398
}
383399

384400
function getSecret(character: Character, secret: string) {
385-
return character.settings.secrets?.[secret] || process.env[secret];
401+
return character.settings?.secrets?.[secret] || process.env[secret];
386402
}
387403

388404
let nodePlugin: any | undefined;
@@ -392,7 +408,7 @@ export async function createAgent(
392408
db: IDatabaseAdapter,
393409
cache: ICacheManager,
394410
token: string
395-
) {
411+
):AgentRuntime {
396412
elizaLogger.success(
397413
elizaLogger.successesTitle,
398414
"Creating runtime for character",
@@ -425,6 +441,7 @@ export async function createAgent(
425441
modelProvider: character.modelProvider,
426442
evaluators: [],
427443
character,
444+
// character.plugins are handled when clients are added
428445
plugins: [
429446
bootstrapPlugin,
430447
getSecret(character, "CONFLUX_CORE_PRIVATE_KEY")
@@ -495,7 +512,7 @@ function initializeDbCache(character: Character, db: IDatabaseCacheAdapter) {
495512
return cache;
496513
}
497514

498-
async function startAgent(character: Character, directClient) {
515+
async function startAgent(character: Character, directClient):AgentRuntime {
499516
let db: IDatabaseAdapter & IDatabaseCacheAdapter;
500517
try {
501518
character.id ??= stringToUuid(character.name);
@@ -514,15 +531,21 @@ async function startAgent(character: Character, directClient) {
514531
await db.init();
515532

516533
const cache = initializeDbCache(character, db);
517-
const runtime = await createAgent(character, db, cache, token);
534+
const runtime:AgentRuntime = await createAgent(character, db, cache, token);
518535

536+
// start services/plugins/process knowledge
519537
await runtime.initialize();
520538

521-
const clients = await initializeClients(character, runtime);
539+
// start assigned clients
540+
runtime.clients = await initializeClients(character, runtime);
522541

542+
// add to container
523543
directClient.registerAgent(runtime);
524544

525-
return clients;
545+
// report to console
546+
elizaLogger.debug(`Started ${character.name} as ${runtime.agentId}`)
547+
548+
return runtime;
526549
} catch (error) {
527550
elizaLogger.error(
528551
`Error starting agent for character ${character.name}:`,
@@ -566,8 +589,8 @@ const startAgents = async () => {
566589
});
567590
}
568591

569-
elizaLogger.log("Chat started. Type 'exit' to quit.");
570592
if (!args["non-interactive"]) {
593+
elizaLogger.log("Chat started. Type 'exit' to quit.");
571594
chat();
572595
}
573596
};

docs/docs/core/characterfile.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ A `characterfile` implements the [Character](/api/type-aliases/character) type a
2222
```json
2323
{
2424
"name": "trump",
25-
"clients": ["DISCORD", "DIRECT"],
25+
"clients": ["discord", "direct"],
2626
"settings": {
2727
"voice": { "model": "en_US-male-medium" }
2828
},
@@ -92,11 +92,11 @@ The character's display name for identification and in conversations.
9292

9393
#### `modelProvider` (required)
9494

95-
Specifies the AI model provider. Supported options from [ModelProviderName](/api/enumerations/modelprovidername) include `ANTHROPIC`, `LLAMALOCAL`, `OPENAI`, and others.
95+
Specifies the AI model provider. Supported options from [ModelProviderName](/api/enumerations/modelprovidername) include `anthropic`, `llama_local`, `openai`, and others.
9696

9797
#### `clients` (required)
9898

99-
Array of supported client types from [Clients](/api/enumerations/clients) e.g., `DISCORD`, `DIRECT`, `TWITTER`, `TELEGRAM`.
99+
Array of supported client types from [Clients](/api/enumerations/clients) e.g., `discord`, `direct`, `twitter`, `telegram`, `farcaster`.
100100

101101
#### `bio`
102102

@@ -261,8 +261,8 @@ Your response should not contain any questions. Brief, concise statements only.
261261
```json
262262
{
263263
"name": "TechAI",
264-
"modelProvider": "ANTHROPIC",
265-
"clients": ["DISCORD", "DIRECT"],
264+
"modelProvider": "anthropic",
265+
"clients": ["discord", "direct"],
266266
"bio": "AI researcher and educator focused on practical applications",
267267
"lore": [
268268
"Pioneer in open-source AI development",

lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"version": "0.1.5-alpha.5",
3-
"packages": ["packages/*", "docs", "agent", "client"],
3+
"packages": ["packages/*", "docs", "agent", "client", "!packages/_examples"],
44
"npmClient": "pnpm"
55
}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@
5454
"dependencies": {
5555
"@0glabs/0g-ts-sdk": "0.2.1",
5656
"@coinbase/coinbase-sdk": "0.10.0",
57+
"@deepgram/sdk": "^3.9.0",
58+
"@vitest/eslint-plugin": "1.0.1",
5759
"amqplib": "0.10.5",
5860
"csv-parse": "5.6.0",
59-
"@vitest/eslint-plugin": "1.0.1",
6061
"ollama-ai-provider": "0.16.1",
6162
"optional": "0.1.4",
6263
"pnpm": "9.14.4",

packages/_examples/plugin/.npmignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
3+
!dist/**
4+
!package.json
5+
!readme.md
6+
!tsup.config.ts

packages/_examples/plugin/README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Sample Plugin for Eliza
2+
3+
The Sample Plugin for Eliza extends the functionality of the Eliza platform by providing additional actions, providers, evaluators, and more. This plugin is designed to be easily extendable and customizable to fit various use cases.
4+
5+
## Description
6+
The Sample Plugin offers a set of features that can be integrated into the Eliza platform to enhance its capabilities. Below is a high-level overview of the different components available in this plugin.
7+
8+
## Actions
9+
- **createResourceAction**: This action enables the creation and management of generic resources. It can be customized to handle different types of resources and integrate with various data sources.
10+
11+
## Providers
12+
- **sampleProvider**: This provider offers a mechanism to supply data or services to the plugin. It can be extended to include additional providers as needed.
13+
14+
## Evaluators
15+
- **sampleEvaluator**: This evaluator provides a way to assess or analyze data within the plugin. It can be extended to include additional evaluators as needed.
16+
17+
## Services
18+
- **[ServiceName]**: Description of the service and its functionality. This can be extended to include additional services as needed.
19+
20+
## Clients
21+
- **[ClientName]**: Description of the client and its functionality. This can be extended to include additional clients as needed.
22+
23+
## How to Extend
24+
To extend the Sample Plugin, you can add new actions, providers, evaluators, services, and clients by following the structure provided in the plugin. Each component can be customized to fit your specific requirements.
25+
26+
1. **Actions**: Add new actions by defining them in the `actions` array.
27+
2. **Providers**: Add new providers by defining them in the `providers` array.
28+
3. **Evaluators**: Add new evaluators by defining them in the `evaluators` array.
29+
4. **Services**: Add new services by defining them in the `services` array.
30+
5. **Clients**: Add new clients by defining them in the `clients` array.
31+
32+
For more detailed information on how to extend the plugin, refer to the documentation provided in the Eliza platform.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import eslintGlobalConfig from "../../eslint.config.mjs";
2+
3+
export default [...eslintGlobalConfig];
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@ai16z/plugin-sample",
3+
"version": "0.1.5-alpha.5",
4+
"main": "dist/index.js",
5+
"type": "module",
6+
"types": "dist/index.d.ts",
7+
"dependencies": {
8+
"@ai16z/eliza": "workspace:*"
9+
},
10+
"devDependencies": {
11+
"tsup": "8.3.5",
12+
"@types/node": "^20.0.0"
13+
},
14+
"scripts": {
15+
"build": "tsup --format esm --dts",
16+
"dev": "tsup --format esm --dts --watch",
17+
"lint": "eslint . --fix"
18+
}
19+
}

0 commit comments

Comments
 (0)