Skip to content

Commit 2d17b37

Browse files
committed
Merge branch 'updated-documentation' of https://github.com/atvonsc/eliza into main2
2 parents 3c697ea + ba312e6 commit 2d17b37

File tree

3 files changed

+558
-9
lines changed

3 files changed

+558
-9
lines changed

docs/docs/guides/basic-usage.md

+206
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
sidebar_position: 5
3+
---
4+
5+
# Basic Usage
6+
7+
This guide covers the fundamental concepts and patterns for using Eliza in your applications.
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+
70+
## Creating an Agent Runtime
71+
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+
);
91+
```
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+
);
102+
```
103+
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:
109+
110+
```json
111+
{
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"]
128+
}
129+
```
130+
131+
Load characters:
132+
133+
```bash
134+
node --loader ts-node/esm src/index.ts --characters="path/to/your/character.json"
135+
```
136+
137+
## Basic Memory Management
138+
139+
Process documents and text:
140+
141+
```typescript
142+
// Basic document processing
143+
await runtime.processDocument("path/to/document.pdf");
144+
await runtime.processUrl("https://example.com");
145+
await runtime.processText("Important information");
146+
```
147+
148+
Use built-in knowledge tools:
149+
150+
```bash
151+
npx folder2knowledge <path/to/folder>
152+
npx knowledge2character <character-file> <knowledge-file>
153+
```
154+
155+
## Platform Integration
156+
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
163+
164+
For help with setting up your Discord Bot, check out: https://discordjs.guide/preparations/setting-up-a-bot-application.html
165+
166+
Initialize all configured clients:
167+
168+
```typescript
169+
import { initializeClients } from "eliza";
170+
171+
// Initialize all configured clients
172+
const clients = await initializeClients(character, runtime);
173+
```
174+
175+
## Development Commands
176+
177+
```bash
178+
pnpm run dev # Start the server
179+
pnpm run shell # Start interactive shell
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
195+
196+
See [Advanced Features](./advanced) for adding custom actions and providers.
197+
## Next Steps
198+
199+
- Learn about [Configuration](./configuration) options
200+
- Explore [Advanced Features](./advanced) including:
201+
- Audio/video processing
202+
- Advanced memory management
203+
- Custom actions and evaluators
204+
- Read about [Character Files](./characterfile)
205+
206+
For API details, see the [API Reference](../api).

0 commit comments

Comments
 (0)