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

merge from main #13

Merged
merged 28 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b3ecd5c
updat dependencies and fix lock
lalalune Nov 1, 2024
83106a2
remove package lock
lalalune Nov 1, 2024
8eed22d
export work cleanup
ponderingdemocritus Nov 1, 2024
bdbaba5
imports
ponderingdemocritus Nov 1, 2024
e85195f
merge
ponderingdemocritus Nov 1, 2024
ff3ef9c
remove logs
lalalune Nov 1, 2024
7e6260f
Merge branch 'main' of https://github.com/ponderingdemocritus/eliza i…
lalalune Nov 1, 2024
0b72cce
lock
ponderingdemocritus Nov 1, 2024
29bcbf8
node
ponderingdemocritus Nov 2, 2024
a624586
lock
ponderingdemocritus Nov 2, 2024
ccc7385
ci
ponderingdemocritus Nov 2, 2024
4d0ada5
commit'
ponderingdemocritus Nov 2, 2024
247615c
npm
ponderingdemocritus Nov 2, 2024
ba69005
lock
ponderingdemocritus Nov 2, 2024
28a4d13
try
ponderingdemocritus Nov 2, 2024
e25ce25
lint
ponderingdemocritus Nov 2, 2024
b9a9c33
Merge pull request #162 from ponderingdemocritus/main
lalalune Nov 2, 2024
0905d97
clean up index
ponderingdemocritus Nov 2, 2024
dce8bae
allow custom actions
ponderingdemocritus Nov 2, 2024
6f88148
Merge pull request #163 from ponderingdemocritus/main
lalalune Nov 2, 2024
5da90dc
add optional agentId
lalalune Nov 2, 2024
04c62f0
add agentId to filtering
lalalune Nov 2, 2024
2629806
Merge branch 'main' of https://github.com/ai16z/eliza into HEAD
lalalune Nov 2, 2024
06edacd
fix eslint, switch image handling to false
lalalune Nov 2, 2024
95a87f0
move stuff
lalalune Nov 2, 2024
e9f9c8b
update package.json
lalalune Nov 2, 2024
1cd035b
peer dep
lalalune Nov 2, 2024
b387fab
downgrade onnx runtime to 1.19.2 until hf transformers is updated
lalalune Nov 2, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
cache: "pnpm"

- name: Install dependencies
run: pnpm i
run: pnpm install --no-frozen-lockfile

- name: Run Prettier
run: pnpm run prettier --check .
Expand Down
109 changes: 64 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Eliza

<img src="./docs/eliza_banner.jpg" alt="Eliza Banner" width="100%" />
<img src="./docs/static/img/eliza_banner.jpg" alt="Eliza Banner" width="100%" />

_As seen powering [@DegenSpartanAI](https://x.com/degenspartanai) and [@MarcAIndreessen](https://x.com/pmairca)_

Expand All @@ -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
4 changes: 2 additions & 2 deletions core/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export default [

// Disable no-undef as TypeScript handles this better
"no-undef": "off",

"@typescript-eslint/no-unsafe-function-type": "off",
// Customize TypeScript rules
"@typescript-eslint/no-explicit-any": "warn", // Changed from error to warn
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
Expand Down
35 changes: 18 additions & 17 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@
"build": "tsc",
"lint": "eslint . --fix",
"start": "node --loader ts-node/esm src/index.ts",
"start:arok": "node --loader ts-node/esm src/index.ts --characters=\"characters/arok.character.json\"",
"start:arok": "node --loader ts-node/esm src/index.ts --characters=\"../characters/arok.character.json\"",
"start:service:ruby": "pm2 start npm --name=\"ruby\" --restart-delay=3000 --max-restarts=10 -- run start:ruby",
"stop:service:ruby": "pm2 stop ruby",
"start:ruby": "node --loader ts-node/esm src/index.ts --characters=\"characters/ruby.character.json\"",
"start:ruby": "node --loader ts-node/esm src/index.ts --characters=\"../characters/ruby.character.json\"",
"start:service:trump": "pm2 start npm --name=\"trump\" --restart-delay=3000 --max-restarts=10 -- run start:trump",
"stop:service:trump": "pm2 stop trump",
"start:service:degen": "pm2 start npm --name=\"degen\" --restart-delay=3000 --max-restarts=10 -- run start:degen",
"stop:service:degen": "pm2 stop degen",
"start:degen": "node --loader ts-node/esm src/index.ts --characters=\"characters/degenspartan.json\"",
"start:degen": "node --loader ts-node/esm src/index.ts --characters=\"../characters/degenspartan.json\"",
"start:service:all": "pm2 start npm --name=\"all\" --restart-delay=3000 --max-restarts=10 -- run start:degen",
"stop:service:all": "pm2 stop all",
"start:all": "node --loader ts-node/esm src/index.ts --characters=\"characters/degenspartan.json\",\"characters/ruby.character.json\"",
"start:trump": "node --loader ts-node/esm src/index.ts --characters=\"characters/trump.character.json\"",
"start:all": "node --loader ts-node/esm src/index.ts --characters=\"../characters/degenspartan.json\",\"../characters/ruby.character.json\"",
"start:trump": "node --loader ts-node/esm src/index.ts --characters=\"../characters/trump.character.json\"",
"start:service:tate": "pm2 start npm --name=\"tate\" --restart-delay=3000 --max-restarts=10 -- run start:tate",
"stop:service:tate": "pm2 stop tate",
"start:tate": "node --loader ts-node/esm src/index.ts --characters=\"characters/tate.character.json\"",
"start:tate": "node --loader ts-node/esm src/index.ts --characters=\"../characters/tate.character.json\"",
"watch": "tsc --watch",
"dev": "tsc && nodemon",
"build:docs": "cd docs && npm run build",
Expand Down Expand Up @@ -69,6 +69,11 @@
"typescript": "5.6.3",
"wrangler": "3.84.0"
},
"pnpm": {
"overrides": {
"onnxruntime-node": "^1.19.2"
}
},
"dependencies": {
"@ai-sdk/anthropic": "^0.0.53",
"@ai-sdk/google": "^0.0.55",
Expand All @@ -93,6 +98,7 @@
"@types/body-parser": "1.19.5",
"@types/cors": "2.8.17",
"@types/express": "5.0.0",
"@types/uuid": "^10.0.0",
"agent-twitter-client": "0.0.13",
"ai": "^3.4.23",
"alawmulaw": "6.0.0",
Expand Down Expand Up @@ -124,8 +130,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 All @@ -135,7 +143,7 @@
"node-wav": "0.0.2",
"nodejs-whisper": "0.1.18",
"nodemon": "3.1.7",
"onnxruntime-node": "1.20.0",
"onnxruntime-node": "^1.19.2",
"openai": "4.69.0",
"pdfjs-dist": "4.7.76",
"pg": "^8.13.1",
Expand All @@ -156,7 +164,6 @@
"together-ai": "^0.7.0",
"unique-names-generator": "4.7.1",
"uuid": "11.0.2",
"uuidv4": "6.2.13",
"wav": "1.0.2",
"wav-encoder": "1.3.0",
"wavefile": "11.0.0",
Expand All @@ -166,17 +173,11 @@
"youtube-dl-exec": "3.0.10"
},
"trustedDependencies": {
"onnxruntime-node": "1.19.0",
"onnxruntime-node": "^1.19.2",
"@discordjs/opus": "github:discordjs/opus",
"sharp": "^0.33.5"
},
"optionalDependencies": {
"sharp": "0.33.5",
"sqlite-vss-darwin-arm64": "0.1.2",
"sqlite-vss-darwin-x64": "0.1.2",
"sqlite-vss-linux-arm64": "^0.1.2",
"sqlite-vss-linux-x64": "0.1.2",
"sqlite-vss-win32-arm64": "^0.1.2",
"sqlite-vss-win32-x64": "^0.1.2"
"peerDependencies": {
"onnxruntime-node": "^1.19.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const claudeHandlerTemplate = `{{attachments}}

# Instructions: Claude, I need your help in assisting the user with their last request. Please provide a helpful, thorough response. I have no arms, so you'll have to write out any implements and take care not to omit or leave TODOs for later. Also, please don't acknowledge the request, just do it.`;

export default {
export const askClaude: Action = {
name: "ASK_CLAUDE",
similes: ["CLAUDE", "CALL_CLAUDE", "ANTHROPIC", "SONNET", "OPUS"],
description:
Expand Down
3 changes: 2 additions & 1 deletion core/src/actions/continue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ Based on the following conversation, should {{agentName}} continue? YES or NO

Should {{agentName}} continue? ` + booleanFooter;

export default {
export const continueAction: Action = {
name: "CONTINUE",
similes: ["ELABORATE", "KEEP_TALKING"],
description:
"ONLY use this action when the message necessitates a follow up. Do not use this action when the conversation is finished or the user does not wish to speak (use IGNORE instead). If the last message action was CONTINUE, and the user has not responded. Use sparingly.",
validate: async (runtime: IAgentRuntime, message: Memory) => {
const recentMessagesData = await runtime.messageManager.getMemories({
roomId: message.roomId,
agentId: runtime.agentId,
count: 10,
unique: false,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Respond with YES if:
Otherwise, respond with NO.
` + booleanFooter;

export default {
export const followRoom: Action = {
name: "FOLLOW_ROOM",
similes: [
"FOLLOW_CHAT",
Expand Down
2 changes: 1 addition & 1 deletion core/src/actions/ignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type Action,
} from "../core/types.ts";

export default {
export const ignore: Action = {
name: "IGNORE",
similes: ["STOP_TALKING", "STOP_CHATTING", "STOP_CONVERSATION"],
validate: async (_runtime: IAgentRuntime, _message: Memory) => {
Expand Down
2 changes: 1 addition & 1 deletion core/src/actions/imageGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "../core/types.ts";
import { generateCaption, generateImage } from "./imageGenerationUtils.ts";

export default {
export const imageGeneration: Action = {
name: "IMAGE_GEN",
similes: ["GENERATE_IMAGE", "CREATE_IMAGE", "MAKE_PICTURE"],
description: "Generate an image based on a prompt",
Expand Down
18 changes: 9 additions & 9 deletions core/src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export * from "./ask_claude.ts";
export * from "./follow_room.ts";
export * from "./askClaude.ts";
export * from "./followRoom.ts";
export * from "./imageGeneration.ts";
export * from "./mute_room.ts";
export * from "./muteRoom.ts";
export * from "./swap.ts";
export * from "./unfollow_room.ts";
export * from "./unmute_room.ts";
export * from "./mute_room.ts";
export * from "./unfollowRoom.ts";
export * from "./unmuteRoom.ts";
export * from "./muteRoom.ts";
export * from "./continue.ts";
export * from "./follow_room.ts";
export * from "./followRoom.ts";
export * from "./ignore.ts";
export * from "./imageGenerationUtils.ts";
export * from "./pumpfun.ts";
export * from "./swap.ts";
export * from "./swapUtils.ts";
export * from "./take_order.ts";
export * from "./takeOrder.ts";
export * from "./none.ts";
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Respond with YES if:
Otherwise, respond with NO.
` + booleanFooter;

export default {
export const muteRoom: Action = {
name: "MUTE_ROOM",
similes: [
"MUTE_CHAT",
Expand Down
2 changes: 1 addition & 1 deletion core/src/actions/none.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type Action,
} from "../core/types.ts";

export default {
export const none: Action = {
name: "NONE",
similes: [
"NO_ACTION",
Expand Down
Loading