Skip to content

Commit

Permalink
Merge pull request #1045 from ai16z/develop
Browse files Browse the repository at this point in the history
chore: release develop into main
  • Loading branch information
odilitime authored Dec 13, 2024
2 parents 23a0c30 + aa51205 commit 7a1fd02
Show file tree
Hide file tree
Showing 31 changed files with 1,622 additions and 354 deletions.
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ WALLET_SECRET_SALT= # ONLY DEFINE IF YOU WANT TO USE TEE Plugin, otherwise it wi
# Galadriel Configuration
GALADRIEL_API_KEY=gal-* # Get from https://dashboard.galadriel.com/

# Venice Configuration
VENICE_API_KEY= # generate from venice settings
SMALL_VENICE_MODEL= # Default: llama-3.3-70b
MEDIUM_VENICE_MODEL= # Default: llama-3.3-70b
LARGE_VENICE_MODEL= # Default: llama-3.1-405b

# fal.ai Configuration
FAL_API_KEY=
FAL_AI_LORA_PATH=
Expand Down Expand Up @@ -264,3 +270,7 @@ AWS_SECRET_ACCESS_KEY=
AWS_REGION=
AWS_S3_BUCKET=
AWS_S3_UPLOAD_PATH=


# Deepgram
DEEPGRAM_API_KEY=
2 changes: 1 addition & 1 deletion .github/workflows/integrationTests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
branches:
- "*"
pull_request:
pull_request_target:
branches:
- "*"
jobs:
Expand Down
57 changes: 40 additions & 17 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ export function getTokenForProvider(
character.settings?.secrets?.HYPERBOLIC_API_KEY ||
settings.HYPERBOLIC_API_KEY
);
case ModelProviderName.VENICE:
return (
character.settings?.secrets?.VENICE_API_KEY ||
settings.VENICE_API_KEY
);
}
}

Expand Down Expand Up @@ -318,42 +323,53 @@ function initializeDatabase(dataDir: string) {
}
}

// also adds plugins from character file into the runtime
export async function initializeClients(
character: Character,
runtime: IAgentRuntime
) {
const clients = [];
const clientTypes =
// each client can only register once
// and if we want two we can explicitly support it
const clients: Record<string, any> = {};
const clientTypes:string[] =
character.clients?.map((str) => str.toLowerCase()) || [];
elizaLogger.log('initializeClients', clientTypes, 'for', character.name)

if (clientTypes.includes("auto")) {
const autoClient = await AutoClientInterface.start(runtime);
if (autoClient) clients.push(autoClient);
if (autoClient) clients.auto = autoClient;
}

if (clientTypes.includes("discord")) {
clients.push(await DiscordClientInterface.start(runtime));
const discordClient = await DiscordClientInterface.start(runtime);
if (discordClient) clients.discord = discordClient;
}

if (clientTypes.includes("telegram")) {
const telegramClient = await TelegramClientInterface.start(runtime);
if (telegramClient) clients.push(telegramClient);
if (telegramClient) clients.telegram = telegramClient;
}

if (clientTypes.includes("twitter")) {
TwitterClientInterface.enableSearch = !isFalsish(getSecret(character, "TWITTER_SEARCH_ENABLE"));
const twitterClients = await TwitterClientInterface.start(runtime);
clients.push(twitterClients);
const twitterClient = await TwitterClientInterface.start(runtime);
if (twitterClient) clients.twitter = twitterClient;
}

if (clientTypes.includes("farcaster")) {
const farcasterClients = new FarcasterAgentClient(runtime);
farcasterClients.start();
clients.push(farcasterClients);
// why is this one different :(
const farcasterClient = new FarcasterAgentClient(runtime);
if (farcasterClient) {
farcasterClient.start();
clients.farcaster = farcasterClient;
}
}

elizaLogger.log('client keys', Object.keys(clients));

if (character.plugins?.length > 0) {
for (const plugin of character.plugins) {
// if plugin has clients, add those..
if (plugin.clients) {
for (const client of plugin.clients) {
clients.push(await client.start(runtime));
Expand Down Expand Up @@ -382,7 +398,7 @@ function isFalsish(input: any): boolean {
}

function getSecret(character: Character, secret: string) {
return character.settings.secrets?.[secret] || process.env[secret];
return character.settings?.secrets?.[secret] || process.env[secret];
}

let nodePlugin: any | undefined;
Expand All @@ -392,7 +408,7 @@ export async function createAgent(
db: IDatabaseAdapter,
cache: ICacheManager,
token: string
) {
):AgentRuntime {
elizaLogger.success(
elizaLogger.successesTitle,
"Creating runtime for character",
Expand Down Expand Up @@ -425,6 +441,7 @@ export async function createAgent(
modelProvider: character.modelProvider,
evaluators: [],
character,
// character.plugins are handled when clients are added
plugins: [
bootstrapPlugin,
getSecret(character, "CONFLUX_CORE_PRIVATE_KEY")
Expand Down Expand Up @@ -495,7 +512,7 @@ function initializeDbCache(character: Character, db: IDatabaseCacheAdapter) {
return cache;
}

async function startAgent(character: Character, directClient) {
async function startAgent(character: Character, directClient):AgentRuntime {
let db: IDatabaseAdapter & IDatabaseCacheAdapter;
try {
character.id ??= stringToUuid(character.name);
Expand All @@ -514,15 +531,21 @@ async function startAgent(character: Character, directClient) {
await db.init();

const cache = initializeDbCache(character, db);
const runtime = await createAgent(character, db, cache, token);
const runtime:AgentRuntime = await createAgent(character, db, cache, token);

// start services/plugins/process knowledge
await runtime.initialize();

const clients = await initializeClients(character, runtime);
// start assigned clients
runtime.clients = await initializeClients(character, runtime);

// add to container
directClient.registerAgent(runtime);

return clients;
// report to console
elizaLogger.debug(`Started ${character.name} as ${runtime.agentId}`)

return runtime;
} catch (error) {
elizaLogger.error(
`Error starting agent for character ${character.name}:`,
Expand Down Expand Up @@ -566,8 +589,8 @@ const startAgents = async () => {
});
}

elizaLogger.log("Chat started. Type 'exit' to quit.");
if (!args["non-interactive"]) {
elizaLogger.log("Chat started. Type 'exit' to quit.");
chat();
}
};
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/core/characterfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ A `characterfile` implements the [Character](/api/type-aliases/character) type a
```json
{
"name": "trump",
"clients": ["DISCORD", "DIRECT"],
"clients": ["discord", "direct"],
"settings": {
"voice": { "model": "en_US-male-medium" }
},
Expand Down Expand Up @@ -92,11 +92,11 @@ The character's display name for identification and in conversations.

#### `modelProvider` (required)

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

#### `clients` (required)

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

#### `bio`

Expand Down Expand Up @@ -261,8 +261,8 @@ Your response should not contain any questions. Brief, concise statements only.
```json
{
"name": "TechAI",
"modelProvider": "ANTHROPIC",
"clients": ["DISCORD", "DIRECT"],
"modelProvider": "anthropic",
"clients": ["discord", "direct"],
"bio": "AI researcher and educator focused on practical applications",
"lore": [
"Pioneer in open-source AI development",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.1.5-alpha.5",
"packages": ["packages/*", "docs", "agent", "client"],
"packages": ["packages/*", "docs", "agent", "client", "!packages/_examples"],
"npmClient": "pnpm"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@
"dependencies": {
"@0glabs/0g-ts-sdk": "0.2.1",
"@coinbase/coinbase-sdk": "0.10.0",
"@deepgram/sdk": "^3.9.0",
"@vitest/eslint-plugin": "1.0.1",
"amqplib": "0.10.5",
"csv-parse": "5.6.0",
"@vitest/eslint-plugin": "1.0.1",
"ollama-ai-provider": "0.16.1",
"optional": "0.1.4",
"pnpm": "9.14.4",
Expand Down
6 changes: 6 additions & 0 deletions packages/_examples/plugin/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*

!dist/**
!package.json
!readme.md
!tsup.config.ts
32 changes: 32 additions & 0 deletions packages/_examples/plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Sample Plugin for Eliza

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.

## Description
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.

## Actions
- **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.

## Providers
- **sampleProvider**: This provider offers a mechanism to supply data or services to the plugin. It can be extended to include additional providers as needed.

## Evaluators
- **sampleEvaluator**: This evaluator provides a way to assess or analyze data within the plugin. It can be extended to include additional evaluators as needed.

## Services
- **[ServiceName]**: Description of the service and its functionality. This can be extended to include additional services as needed.

## Clients
- **[ClientName]**: Description of the client and its functionality. This can be extended to include additional clients as needed.

## How to Extend
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.

1. **Actions**: Add new actions by defining them in the `actions` array.
2. **Providers**: Add new providers by defining them in the `providers` array.
3. **Evaluators**: Add new evaluators by defining them in the `evaluators` array.
4. **Services**: Add new services by defining them in the `services` array.
5. **Clients**: Add new clients by defining them in the `clients` array.

For more detailed information on how to extend the plugin, refer to the documentation provided in the Eliza platform.
3 changes: 3 additions & 0 deletions packages/_examples/plugin/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslintGlobalConfig from "../../eslint.config.mjs";

export default [...eslintGlobalConfig];
19 changes: 19 additions & 0 deletions packages/_examples/plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@ai16z/plugin-sample",
"version": "0.1.5-alpha.5",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"dependencies": {
"@ai16z/eliza": "workspace:*"
},
"devDependencies": {
"tsup": "8.3.5",
"@types/node": "^20.0.0"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"lint": "eslint . --fix"
}
}
Loading

0 comments on commit 7a1fd02

Please sign in to comment.