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

clean up index #163

Merged
merged 2 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
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
107 changes: 63 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,35 @@ _As seen powering [@DegenSpartanAI](https://x.com/degenspartanai) and [@MarcAInd

# Getting Started

## Install Node.js
**Prerequisites (MUST):**

https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
- [Node.js 22+](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
- [pnpm](https://pnpm.io/installation)

## Using pnpm

We use pnpm to manage our dependencies. It is faster and more efficient than npm, and it supports workspaces.
https://pnpm.io/installation

## Edit the .env file
### Edit the .env file

- Copy .env.example to .env and fill in the appropriate values
- Edit the TWITTER environment variables to add your bot's username and password

## Edit the character file
### Edit the character file

- Check out the file `src/core/defaultCharacter.ts` - you can modify this
- You can also load characters with the `node --loader ts-node/esm src/index.ts --characters="path/to/your/character.json"` and run multiple bots at the same time.
- You can also load characters with the `pnpm start --characters="path/to/your/character.json"` and run multiple bots at the same time.

After setting up the .env file and character file, you can start the bot with the following command:

```
pnpm i
pnpm start
```

# Customising Eliza

### Adding custom actions

To avoid git clashes in the core directory, we recommend adding custom actions to a `custom_actions` directory and then adding them to the `elizaConfig.yaml` file. See the `elizaConfig.example.yaml` file for an example.

## Running with different models

### Run with Llama

Expand All @@ -48,10 +59,6 @@ You can run Grok models by setting the `XAI_MODEL` environment variable to `grok

You can run OpenAI models by setting the `XAI_MODEL` environment variable to `gpt-4o-mini` or `gpt-4o`

# Requires Node 20+

If you are getting strange issues when starting up, make sure you're using Node 20+. Some APIs are not compatible with previous versions. You can check your node version with `node -v`. If you need to install a new version of node, we recommend using [nvm](https://github.com/nvm-sh/nvm).

## Additional Requirements

You may need to install Sharp. If you see an error when starting up, try installing it with the following command:
Expand All @@ -66,20 +73,55 @@ You will need to add environment variables to your .env file to connect to vario

```
# Required environment variables
# Start Discord
DISCORD_APPLICATION_ID=
DISCORD_API_TOKEN= # Bot token
OPENAI_API_KEY=sk-* # OpenAI API key, starting with sk-
ELEVENLABS_XI_API_KEY= # API key from elevenlabs

# Start Twitter
# ELEVENLABS SETTINGS
ELEVENLABS_MODEL_ID=eleven_multilingual_v2
ELEVENLABS_VOICE_ID=21m00Tcm4TlvDq8ikWAM
ELEVENLABS_VOICE_STABILITY=0.5
ELEVENLABS_VOICE_SIMILARITY_BOOST=0.9
ELEVENLABS_VOICE_STYLE=0.66
ELEVENLABS_VOICE_USE_SPEAKER_BOOST=false
ELEVENLABS_OPTIMIZE_STREAMING_LATENCY=4
ELEVENLABS_OUTPUT_FORMAT=pcm_16000

TWITTER_DRY_RUN=false
TWITTER_USERNAME= # Account username
TWITTER_PASSWORD= # Account password
TWITTER_EMAIL= # Account email
TWITTER_COOKIES= # Account cookies

X_SERVER_URL=
XAI_API_KEY=
XAI_MODEL=


# For asking Claude stuff
ANTHROPIC_API_KEY=

WALLET_SECRET_KEY=EXAMPLE_WALLET_SECRET_KEY
WALLET_PUBLIC_KEY=EXAMPLE_WALLET_PUBLIC_KEY

BIRDEYE_API_KEY=

SOL_ADDRESS=So11111111111111111111111111111111111111112
SLIPPAGE=1
RPC_URL=https://api.mainnet-beta.solana.com
HELIUS_API_KEY=


## Telegram
TELEGRAM_BOT_TOKEN=

TOGETHER_API_KEY=
```

# Local Setup
# Local Inference Setup

## CUDA Setup
### CUDA Setup

If you have an NVIDIA GPU, you can install CUDA to speed up local inference dramatically.

Expand All @@ -90,37 +132,14 @@ npx --no node-llama-cpp source download --gpu cuda

Make sure that you've installed the CUDA Toolkit, including cuDNN and cuBLAS.

## Running locally
### Running locally

Add XAI_MODEL and set it to one of the above options from [Run with
Llama](#run-with-llama) - you can leave X_SERVER_URL and XAI_API_KEY blank, it
downloads the model from huggingface and queries it locally

# Cloud Setup (with OpenAI)

In addition to the environment variables above, you will need to add the following:

```
# OpenAI handles the bulk of the work with chat, TTS, image recognition, etc.
OPENAI_API_KEY=sk-* # OpenAI API key, starting with sk-

# The agent can also ask Claude for help if you have an API key
ANTHROPIC_API_KEY=

# For Elevenlabs voice generation on Discord voice
ELEVENLABS_XI_API_KEY= # API key from elevenlabs

# ELEVENLABS SETTINGS
ELEVENLABS_MODEL_ID=eleven_multilingual_v2
ELEVENLABS_VOICE_ID=21m00Tcm4TlvDq8ikWAM
ELEVENLABS_VOICE_STABILITY=0.5
ELEVENLABS_VOICE_SIMILARITY_BOOST=0.9
ELEVENLABS_VOICE_STYLE=0.66
ELEVENLABS_VOICE_USE_SPEAKER_BOOST=false
ELEVENLABS_OPTIMIZE_STREAMING_LATENCY=4
ELEVENLABS_OUTPUT_FORMAT=pcm_16000
```
# Clients

# Discord Bot
## Discord Bot

For help with setting up your Discord Bot, check out here: https://discordjs.guide/preparations/setting-up-a-bot-application.html
2 changes: 2 additions & 0 deletions core/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
dist
elizaConfig.yaml
custom_actions/
11 changes: 11 additions & 0 deletions core/elizaConfig.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Load custom actions from the actions directory

# Close this into a elizaConfig.yaml file that is ignored by git

# Paths are relative to the core/src directory

actions:
- name: askClaude
path: ./actions/askClaude.ts
- name: epicAction
path: ./custom_actions/epicAction.ts
2 changes: 2 additions & 0 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@
"html-escaper": "3.0.3",
"html-to-text": "9.0.5",
"import-meta-resolve": "4.1.0",
"install": "^0.13.0",
"jieba-wasm": "2.2.0",
"js-sha1": "0.7.0",
"js-yaml": "^4.1.0",
"json5": "2.2.3",
"kuromoji": "0.1.2",
"libsodium-wrappers": "0.7.15",
Expand Down
45 changes: 45 additions & 0 deletions core/src/cli/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import fs from "fs";
import yaml from "js-yaml";
import path from "path";
import { fileURLToPath } from "url";
import { Action } from "../core/types";

const ROOT_DIR = path.resolve(fileURLToPath(import.meta.url), "../../../src");

interface ActionConfig {
name: string;
path: string;
}

export function loadActionConfigs(configPath: string): ActionConfig[] {
if (!fs.existsSync(configPath)) {
console.error(`Config file not found at path: ${configPath}`);
return [];
}

const configFile = fs.readFileSync(configPath, "utf8");
const parsedConfig = yaml.load(configFile) as { actions: ActionConfig[] };
return parsedConfig?.actions || [];
}

export async function loadCustomActions(
actionConfigs: ActionConfig[]
): Promise<Action[]> {
const actions = [];

for (const config of actionConfigs) {
const resolvedPath = path.resolve(ROOT_DIR, config.path);
console.log(`Importing action from: ${resolvedPath}`); // Debugging log

try {
const actionModule = await import(resolvedPath);
actions.push(actionModule[config.name]);
} catch (error) {
console.error(
`Failed to import action from ${resolvedPath}:`,
error
);
}
}
return actions;
}
Loading