Skip to content

Commit 34d9164

Browse files
authored
Merge pull request #28 from ai16z/main
merge from main
2 parents 8148a22 + 04de0f4 commit 34d9164

File tree

6 files changed

+140
-180
lines changed

6 files changed

+140
-180
lines changed

.env.example

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ X_SERVER_URL=
2929
XAI_API_KEY=
3030
XAI_MODEL=
3131

32+
#POST INTERVAL RANDOM MIN-MAX MINUTES
33+
POST_INTERVAL_MIN= #90 #Default
34+
POST_INTERVAL_MAX= #180 #Default
35+
36+
3237
#USE IMAGE GEN
3338
IMAGE_GEN= #TRUE
3439

README.md

+55-167
Original file line numberDiff line numberDiff line change
@@ -1,212 +1,100 @@
1-
# Eliza
1+
# Eliza 🤖
22

3-
<img src="./docs/static/img/eliza_banner.jpg" alt="Eliza Banner" width="100%" />
3+
<div align="center">
4+
<img src="./docs/static/img/eliza_banner.jpg" alt="Eliza Banner" width="100%" />
5+
</div>
46

5-
### [For Chinese Version: 中文说明](./README_CN.md)
7+
<div align="center">
8+
9+
📖 [Documentation](https://ai16z.github.io/eliza/) | 🎯 [Examples](https://github.com/thejoven/awesome-eliza)
10+
11+
</div>
612

7-
### [For Japanese Version: 日本語の説明](./README_JA.md)
13+
## ✨ Features
814

9-
### [For Korean Version: 한국어 설명](./README_KOR.md)
10-
11-
### [For French Version: Instructions en français](./README_FR.md)
12-
13-
### [For Portuguese Version: Instruções em português](./README_PTBR.md)
14-
15-
## Features
16-
17-
- 🛠 Full-featured Discord, Twitter and Telegram connectors
15+
- 🛠️ Full-featured Discord, Twitter and Telegram connectors
16+
- 🔗 Support for every model (Llama, Grok, OpenAI, Anthropic, etc.)
1817
- 👥 Multi-agent and room support
1918
- 📚 Easily ingest and interact with your documents
2019
- 💾 Retrievable memory and document store
21-
- 🚀 Highly extensible - create your own actions and clients to extend capabilities
22-
- ☁️ Supports many models, including local Llama, OpenAI, Anthropic, Groq, and more
20+
- 🚀 Highly extensible - create your own actions and clients
21+
- ☁️ Supports many models (local Llama, OpenAI, Anthropic, Groq, etc.)
2322
- 📦 Just works!
2423

25-
## What can I use it for?
24+
## 🎯 Use Cases
2625

2726
- 🤖 Chatbots
2827
- 🕵️ Autonomous Agents
29-
- 📈 Business process handling
30-
- 🎮 Video game NPCs
31-
32-
# Getting Started
33-
34-
**Prerequisites (MUST):**
35-
36-
- [Python 2.7+](https://www.python.org/downloads/)
37-
- [Node.js 23.1+](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
38-
- [pnpm](https://pnpm.io/installation)
39-
40-
### Edit the .env file
41-
42-
- Copy .env.example to .env and fill in the appropriate values
43-
- Edit the TWITTER environment variables to add your bot's username and password
44-
45-
### Edit the character file
46-
47-
- Check out the file `src/core/defaultCharacter.ts` - you can modify this
48-
- You can also load characters with the `pnpm start --characters="path/to/your/character.json"` and run multiple bots at the same time.
49-
50-
After setting up the .env file and character file, you can start the bot with the following command:
51-
52-
```
53-
pnpm i
54-
pnpm start
55-
```
56-
57-
# Customising Eliza
58-
59-
### Adding custom actions
60-
61-
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.
62-
63-
## Running with different models
64-
65-
### Run with Llama
28+
- 📈 Business Process Handling
29+
- 🎮 Video Game NPCs
30+
- 🧠 Trading
6631

67-
You can run Llama 70B or 405B models by setting the `XAI_MODEL` environment variable to `meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo` or `meta-llama/Meta-Llama-3.1-405B-Instruct`
32+
## 🌍 Translations
6833

69-
### Run with Grok
34+
<details>
35+
<summary>Available Languages</summary>
7036

71-
You can run Grok models by setting the `XAI_MODEL` environment variable to `grok-beta`
37+
- [中文说明](./README_CN.md)
38+
- [日本語の説明](./README_JA.md)
39+
- [한국어 설명](./README_KOR.md)
40+
- [Instructions en français](./README_FR.md)
41+
- [Instruções em português](./README_PTBR.md)
7242

73-
### Run with OpenAI
43+
</details>
7444

75-
You can run OpenAI models by setting the `XAI_MODEL` environment variable to `gpt-4o-mini` or `gpt-4o`
45+
## 🚀 Quick Start
7646

77-
## Additional Requirements
47+
### Prerequisites
7848

79-
You may need to install Sharp. If you see an error when starting up, try installing it with the following command:
80-
81-
```
82-
pnpm install --include=optional sharp
83-
```
84-
85-
# Environment Setup
86-
87-
You will need to add environment variables to your .env file to connect to various platforms:
88-
89-
```
90-
# Required environment variables
91-
DISCORD_APPLICATION_ID=
92-
DISCORD_API_TOKEN= # Bot token
93-
OPENAI_API_KEY=sk-* # OpenAI API key, starting with sk-
94-
ELEVENLABS_XI_API_KEY= # API key from elevenlabs
95-
GOOGLE_GENERATIVE_AI_API_KEY= # Gemini API key
96-
97-
# ELEVENLABS SETTINGS
98-
ELEVENLABS_MODEL_ID=eleven_multilingual_v2
99-
ELEVENLABS_VOICE_ID=21m00Tcm4TlvDq8ikWAM
100-
ELEVENLABS_VOICE_STABILITY=0.5
101-
ELEVENLABS_VOICE_SIMILARITY_BOOST=0.9
102-
ELEVENLABS_VOICE_STYLE=0.66
103-
ELEVENLABS_VOICE_USE_SPEAKER_BOOST=false
104-
ELEVENLABS_OPTIMIZE_STREAMING_LATENCY=4
105-
ELEVENLABS_OUTPUT_FORMAT=pcm_16000
106-
107-
TWITTER_DRY_RUN=false
108-
TWITTER_USERNAME= # Account username
109-
TWITTER_PASSWORD= # Account password
110-
TWITTER_EMAIL= # Account email
111-
TWITTER_COOKIES= # Account cookies
112-
113-
X_SERVER_URL=
114-
XAI_API_KEY=
115-
XAI_MODEL=
116-
117-
118-
# For asking Claude stuff
119-
ANTHROPIC_API_KEY=
120-
121-
WALLET_PRIVATE_KEY=EXAMPLE_WALLET_PRIVATE_KEY
122-
WALLET_PUBLIC_KEY=EXAMPLE_WALLET_PUBLIC_KEY
123-
124-
BIRDEYE_API_KEY=
125-
126-
SOL_ADDRESS=So11111111111111111111111111111111111111112
127-
SLIPPAGE=1
128-
RPC_URL=https://api.mainnet-beta.solana.com
129-
HELIUS_API_KEY=
130-
131-
132-
## Telegram
133-
TELEGRAM_BOT_TOKEN=
134-
135-
TOGETHER_API_KEY=
136-
```
49+
- [Python 2.7+](https://www.python.org/downloads/)
50+
- [Node.js 22+](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
51+
- [pnpm](https://pnpm.io/installation)
13752

138-
# Local Inference Setup
53+
> **Note for Windows Users:** WSL is required
13954
140-
### CUDA Setup
55+
### Edit the .env file
14156

142-
If you have an NVIDIA GPU, you can install CUDA to speed up local inference dramatically.
57+
Copy .env.example to .env and fill in the appropriate values
14358

14459
```
145-
pnpm install
146-
npx --no node-llama-cpp source download --gpu cuda
60+
cp .env.example .env
14761
```
14862

149-
Make sure that you've installed the CUDA Toolkit, including cuDNN and cuBLAS.
150-
151-
### Running locally
152-
153-
Add XAI_MODEL and set it to one of the above options from [Run with
154-
Llama](#run-with-llama) - you can leave X_SERVER_URL and XAI_API_KEY blank, it
155-
downloads the model from huggingface and queries it locally
156-
157-
# Clients
158-
159-
## Discord Bot
63+
### Edit the character file
16064

161-
For help with setting up your Discord Bot, check out here: https://discordjs.guide/preparations/setting-up-a-bot-application.html
65+
1. Open `src/core/defaultCharacter.ts` to modify the default character
16266

163-
# Development
67+
2. To load custom characters:
68+
- Use `pnpm start --characters="path/to/your/character.json"`
69+
- Multiple character files can be loaded simultaneously
16470

165-
## Testing
71+
### Start Eliza
16672

167-
To run the test suite, you must got into each package:
73+
After setting up the .env file and character file, you can start the bot with the following command:
16874

16975
```bash
170-
pnpm test # Run tests once
171-
pnpm test:watch # Run tests in watch mode
172-
```
173-
174-
For database-specific tests:
76+
pnpm i
77+
pnpm build
78+
pnpm start
17579

176-
```bash
177-
pnpm test:sqlite # Run tests with SQLite
178-
pnpm test:sqljs # Run tests with SQL.js
80+
# The project iterates fast, sometimes you need to clean the project if you are coming back to the project
81+
pnpm clean
17982
```
18083

181-
Tests are written using Jest and can be found in `src/**/*.test.ts` files. The test environment is configured to:
182-
183-
- Load environment variables from `.env.test`
184-
- Use a 2-minute timeout for long-running tests
185-
- Support ESM modules
186-
- Run tests in sequence (--runInBand)
84+
#### Additional Requirements
18785

188-
To create new tests, add a `.test.ts` file adjacent to the code you're testing.
189-
190-
## Docker
191-
192-
For development purposes, you can run the docker container with the following command:
86+
You may need to install Sharp. If you see an error when starting up, try installing it with the following command:
19387

19488
```
195-
pnpm docker
89+
pnpm install --include=optional sharp
19690
```
19791

198-
This will drop you into a shell inside the docker container where you can continue to configure the instance
199-
200-
and then you can start it with `pnpm start`
201-
202-
203-
## Community & contact
204-
205-
* [GitHub Issues](https://github.com/ai16z/eliza/issues). Best for: bugs you encounter using Eliza, and feature proposals.
206-
* [Discord](https://discord.gg/ai16z). Best for: sharing your applications and hanging out with the community.
92+
### Community & contact
20793

94+
- [GitHub Issues](https://github.com/ai16z/eliza/issues). Best for: bugs you encounter using Eliza, and feature proposals.
95+
- [Discord](https://discord.gg/ai16z). Best for: sharing your applications and hanging out with the community.
20896

209-
**Contributors**
97+
## Contributors
21098

21199
<a href="https://github.com/ai16z/eliza/graphs/contributors">
212100
<img src="https://contrib.rocks/image?repo=ai16z/eliza" />

packages/client-twitter/src/base.ts

+48
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,24 @@ export class ClientBase extends EventEmitter {
274274
console.log("Twitter user ID:", userId);
275275
this.twitterUserId = userId;
276276

277+
// Initialize Twitter profile
278+
const profile = await this.initializeProfile();
279+
if (profile) {
280+
console.log("Twitter profile initialized:", profile);
281+
282+
// Store profile info for use in responses
283+
this.runtime.character = {
284+
...this.runtime.character,
285+
twitterProfile: {
286+
username: profile.username,
287+
screenName: profile.screenName,
288+
bio: profile.bio,
289+
nicknames: profile.nicknames
290+
}
291+
};
292+
}
293+
294+
277295
await this.populateTimeline();
278296

279297
this.onReady();
@@ -603,4 +621,34 @@ export class ClientBase extends EventEmitter {
603621
});
604622
}
605623
}
624+
625+
async initializeProfile() {
626+
const username = this.runtime.getSetting("TWITTER_USERNAME");
627+
if (!username) {
628+
console.error("Twitter username not configured");
629+
return;
630+
}
631+
632+
try {
633+
const profile = await this.requestQueue.add(async () => {
634+
const profile = await this.twitterClient.getProfile(username);
635+
return {
636+
username,
637+
screenName: profile.name || this.runtime.character.name,
638+
bio: profile.biography || typeof this.runtime.character.bio === 'string' ? this.runtime.character.bio as string : this.runtime.character.bio.length > 0 ? this.runtime.character.bio[0] : "",
639+
nicknames: this.runtime.character.twitterProfile?.nicknames || []
640+
};
641+
});
642+
643+
return profile;
644+
} catch (error) {
645+
console.error("Error fetching Twitter profile:", error);
646+
return {
647+
username: this.runtime.character.name,
648+
screenName: username,
649+
bio: typeof this.runtime.character.bio === 'string' ? this.runtime.character.bio as string : this.runtime.character.bio.length > 0 ? this.runtime.character.bio[0] : "",
650+
nicknames: this.runtime.character.twitterProfile?.nicknames || []
651+
};
652+
}
653+
}
606654
}

packages/client-twitter/src/post.ts

+21-8
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,32 @@ Write a single sentence post that is {{adjective}} about {{topic}} (without ment
2828
Your response should not contain any questions. Brief, concise statements only. No emojis. Use \\n\\n (double spaces) between statements.`;
2929

3030
export class TwitterPostClient extends ClientBase {
31-
onReady() {
31+
32+
33+
onReady(postImmediately: boolean = true) {
3234
const generateNewTweetLoop = () => {
33-
this.generateNewTweet();
35+
const minMinutes = parseInt(this.runtime.getSetting("POST_INTERVAL_MIN")) || 90;
36+
const maxMinutes = parseInt(this.runtime.getSetting("POST_INTERVAL_MAX")) || 180;
37+
const randomMinutes = Math.floor(Math.random() * (maxMinutes - minMinutes + 1)) + minMinutes;
38+
const delay = randomMinutes * 60 * 1000;
39+
3440
setTimeout(
35-
generateNewTweetLoop,
36-
(Math.floor(Math.random() * (180 - 90 + 1)) + 90) * 60 * 1000
37-
); // Random interval: min 90min/max 180min (1.5-3h), Results in min 8/max 16 posts per day
41+
() => {
42+
this.generateNewTweet();
43+
generateNewTweetLoop(); // Set up next iteration
44+
},
45+
delay
46+
);
47+
48+
console.log(`Next tweet scheduled in ${randomMinutes} minutes`);
3849
};
39-
// setTimeout(() => {
50+
51+
if (postImmediately) {
52+
this.generateNewTweet();
53+
}
4054
generateNewTweetLoop();
41-
// }, 5 * 60 * 1000); // Wait 5 minutes before starting the loop
4255
}
43-
56+
4457
constructor(runtime: IAgentRuntime) {
4558
// Initialize the client and pass an optional callback to be called when the client is ready
4659
super({

0 commit comments

Comments
 (0)