@@ -6,97 +6,201 @@ sidebar_position: 5
6
6
7
7
This guide covers the fundamental concepts and patterns for using Eliza in your applications.
8
8
9
+ ## Prerequisites
10
+
11
+ - Node.js 20+ required
12
+ - PNPM for package management
13
+
14
+ ## Installation
15
+
16
+ ``` bash
17
+ pnpm install eliza
18
+
19
+ # Database adapters
20
+ pnpm install sqlite-vss better-sqlite3 # for SQLite (local development)
21
+ pnpm install @supabase/supabase-js # for Supabase (production)
22
+
23
+ # Optional - for Linux
24
+ pnpm install --include=optional sharp
25
+ ```
26
+
27
+ ## Environment Setup
28
+
29
+ Copy .env.example to .env and configure:
30
+
31
+ ``` bash
32
+ # Required
33
+ OPENAI_API_KEY=" sk-*" # OpenAI API key, starting with sk-
34
+ XAI_MODEL=" gpt-4o-mini" # Model selection (see below)
35
+
36
+ # Model Selection Options
37
+ XAI_MODEL=gpt-4o-mini # OpenAI GPT-4
38
+ XAI_MODEL=meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo # Llama 70B
39
+ XAI_MODEL=meta-llama/Meta-Llama-3.1-405B-Instruct # Llama 405B
40
+ XAI_MODEL=grok-beta # Grok
41
+
42
+ # Optional - Model Configuration
43
+ LOCALAI_URL=" http://localhost:8080"
44
+ LOCALAI_TOKEN=" your-token"
45
+ ANTHROPIC_API_KEY=" your-claude-api-key"
46
+
47
+ # Optional - Database (for production)
48
+ POSTGRES_URL=" postgres://user:pass@host:5432/db" # Add this line
49
+ SUPABASE_URL=" https://your-supabase-url.supabase.co"
50
+ SUPABASE_SERVICE_API_KEY=" your-supabase-service-api-key"
51
+
52
+ # Optional - Platform Integration
53
+ DISCORD_TOKEN=" your-discord-token"
54
+ TELEGRAM_BOT_TOKEN=" your-telegram-token"
55
+ TWITTER_USERNAME=" your-twitter-username"
56
+ TWITTER_PASSWORD=" your-twitter-password"
57
+
58
+ # Optional - Voice Support
59
+ ELEVENLABS_XI_API_KEY=" your-elevenlabs-key"
60
+ ELEVENLABS_MODEL_ID=" eleven_multilingual_v2"
61
+ ELEVENLABS_VOICE_ID=" 21m00Tcm4TlvDq8ikWAM"
62
+ ELEVENLABS_VOICE_STABILITY=0.5
63
+ ELEVENLABS_VOICE_SIMILARITY_BOOST=0.9
64
+ ELEVENLABS_VOICE_STYLE=0.66
65
+ ELEVENLABS_VOICE_USE_SPEAKER_BOOST=false
66
+ ELEVENLABS_OPTIMIZE_STREAMING_LATENCY=4
67
+ ELEVENLABS_OUTPUT_FORMAT=pcm_16000
68
+ ```
69
+
9
70
## Creating an Agent Runtime
10
71
11
- The first step is to initialize an agent runtime with your desired configuration:
72
+ Initialize with SQLite (local development):
73
+
74
+ ``` typescript
75
+ import { createAgentRuntime , Database } from " eliza" ;
76
+ import { initializeDatabase , ModelProvider } from " eliza" ;
77
+
78
+ // Initialize database (SQLite locally, Postgres in production)
79
+ const db = initializeDatabase ();
80
+
81
+ // Get token for model provider (supports character-specific keys)
82
+ const token = getTokenForProvider (ModelProvider .OPENAI , character );
83
+
84
+ // Create runtime with default configuration
85
+ const runtime = await createAgentRuntime (
86
+ character ,
87
+ db ,
88
+ token ,
89
+ " ./elizaConfig.yaml"
90
+ );
12
91
```
13
- import { AgentRuntime, SqliteDatabaseAdapter } from "eliza";
14
- import { Database } from "sqlite3";
15
- const sqliteDatabaseAdapter = new SqliteDatabaseAdapter(new Database(":memory:"));
16
- const runtime = new AgentRuntime({
17
- serverUrl: "https://api.openai.com/v1",
18
- token: process.env.OPENAI_API_KEY,
19
- databaseAdapter: sqliteDatabaseAdapter,
20
- model: "gpt-3.5-turbo" ,
21
- embeddingModel: "text-embedding-3-small"
22
- } );
92
+
93
+ For production with Supabase:
94
+
95
+ ``` typescript
96
+ import { SupabaseDatabaseAdapter } from " eliza " ;
97
+
98
+ const db = new SupabaseDatabaseAdapter (
99
+ process . env . SUPABASE_URL ,
100
+ process . env . SUPABASE_SERVICE_API_KEY
101
+ );
23
102
```
24
103
25
- ## Loading Characters
104
+ ## Working with Characters
105
+
106
+ You can either:
107
+ - Modify the default character in ` src/core/defaultCharacter.ts `
108
+ - Create a custom character file:
26
109
27
- Characters can be loaded from JSON files:
28
110
``` json
29
111
{
30
- "name" : " character_name" ,
31
- "bio" : [],
32
- "lore" : [],
33
- "knowledge" : [],
34
- "style" : {}
112
+ "name" : " character_name" ,
113
+ "settings" : {
114
+ "secrets" : {
115
+ "OPENAI_API_KEY" : " optional-character-specific-key" ,
116
+ "CLAUDE_API_KEY" : " optional-character-specific-key"
117
+ }
118
+ },
119
+ "bio" : [],
120
+ "lore" : [],
121
+ "knowledge" : [],
122
+ "messageExamples" : [],
123
+ "postExamples" : [],
124
+ "topics" : [],
125
+ "style" : {},
126
+ "adjectives" : [],
127
+ "clients" : [" discord" , " telegram" , " twitter" ]
35
128
}
36
129
```
37
130
38
- Load the character:
39
- ```
131
+ Load characters:
132
+
133
+ ``` bash
40
134
node --loader ts-node/esm src/index.ts --characters=" path/to/your/character.json"
41
135
```
42
136
43
- ## Working with Memory
137
+ ## Basic Memory Management
44
138
45
- Process different types of content:
46
- ```
47
- // Process documents
139
+ Process documents and text:
140
+
141
+ ``` typescript
142
+ // Basic document processing
48
143
await runtime .processDocument (" path/to/document.pdf" );
49
144
await runtime .processUrl (" https://example.com" );
50
145
await runtime .processText (" Important information" );
51
146
```
52
147
53
- Use the knowledge management tools:
148
+ Use built-in knowledge tools:
149
+
54
150
``` bash
55
- npx folder2knowledge ./docs
56
- npx knowledge2character my- character.json knowledge.json
151
+ npx folder2knowledge < path/to/folder >
152
+ npx knowledge2character < character-file > < knowledge-file >
57
153
```
58
154
59
155
## Platform Integration
60
156
61
- Set up Discord integration:
62
- ```
63
- import { DiscordConnector } from "eliza";
64
- const discord = new DiscordConnector({
65
- token: process.env.DISCORD_TOKEN,
66
- runtime: runtime
67
- });
68
- await discord.start();
69
- ```
157
+ Before initializing clients, ensure:
158
+ 1 . The desired clients are configured in your character file's ` clients ` array
159
+ 2 . Required environment variables are set for each platform:
160
+ - Discord: DISCORD_TOKEN
161
+ - Telegram: TELEGRAM_BOT_TOKEN
162
+ - Twitter: TWITTER_USERNAME and TWITTER_PASSWORD
70
163
71
- Set up Twitter integration:
72
- ```
73
- import { TwitterConnector } from "eliza";
74
- const twitter = new TwitterConnector({
75
- username: process.env.TWITTER_USERNAME,
76
- password: process.env.TWITTER_PASSWORD,
77
- runtime: runtime
78
- });
79
- await twitter.start();
80
- ```
164
+ For help with setting up your Discord Bot, check out: https://discordjs.guide/preparations/setting-up-a-bot-application.html
81
165
166
+ Initialize all configured clients:
82
167
83
- ## Development Commands
168
+ ``` typescript
169
+ import { initializeClients } from " eliza" ;
84
170
85
- Start the server:
86
- ``` bash
87
- pnpm run dev
171
+ // Initialize all configured clients
172
+ const clients = await initializeClients (character , runtime );
88
173
```
89
174
175
+ ## Development Commands
90
176
91
- Start the interactive shell:
92
177
``` bash
93
- pnpm run shell
178
+ pnpm run dev # Start the server
179
+ pnpm run shell # Start interactive shell
94
180
```
181
+ ## Runtime Components
182
+
183
+ The runtime includes these built-in components:
184
+
185
+ ### Actions
186
+ - Default actions from defaultActions
187
+ - followRoom/unfollowRoom
188
+ - muteRoom/unmuteRoom
189
+ - imageGeneration
190
+ - Custom actions from elizaConfig.yaml
191
+
192
+ ### Providers
193
+ - timeProvider
194
+ - boredomProvider
95
195
196
+ See [ Advanced Features] ( ./advanced ) for adding custom actions and providers.
96
197
## Next Steps
97
198
98
199
- Learn about [ Configuration] ( ./configuration ) options
99
- - Explore [ Advanced Features] ( ./advanced )
200
+ - Explore [ Advanced Features] ( ./advanced ) including:
201
+ - Audio/video processing
202
+ - Advanced memory management
203
+ - Custom actions and evaluators
100
204
- Read about [ Character Files] ( ./characterfile )
101
205
102
206
For API details, see the [ API Reference] ( ../api ) .
0 commit comments