Skip to content

Commit fbe5cf8

Browse files
authored
Update basic-usage.md
Updated basic-usage docs
1 parent e53fc97 commit fbe5cf8

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

docs/docs/guides/basic-usage.md

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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+
## Creating an Agent Runtime
10+
11+
The first step is to initialize an agent runtime with your desired configuration:
12+
```
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+
});
23+
```
24+
25+
## Loading Characters
26+
27+
Characters can be loaded from JSON files:
28+
```json
29+
{
30+
"name": "character_name",
31+
"bio": [],
32+
"lore": [],
33+
"knowledge": [],
34+
"style": {}
35+
}
36+
```
37+
38+
Load the character:
39+
```
40+
node --loader ts-node/esm src/index.ts --characters="path/to/your/character.json"
41+
```
42+
43+
## Working with Memory
44+
45+
Process different types of content:
46+
```
47+
// Process documents
48+
await runtime.processDocument("path/to/document.pdf");
49+
await runtime.processUrl("https://example.com");
50+
await runtime.processText("Important information");
51+
```
52+
53+
Use the knowledge management tools:
54+
```bash
55+
npx folder2knowledge ./docs
56+
npx knowledge2character my-character.json knowledge.json
57+
```
58+
59+
## Platform Integration
60+
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+
```
70+
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+
```
81+
82+
83+
## Development Commands
84+
85+
Start the server:
86+
```bash
87+
pnpm run dev
88+
```
89+
90+
91+
Start the interactive shell:
92+
```bash
93+
pnpm run shell
94+
```
95+
96+
## Next Steps
97+
98+
- Learn about [Configuration](./configuration) options
99+
- Explore [Advanced Features](./advanced)
100+
- Read about [Character Files](./characterfile)
101+
102+
For API details, see the [API Reference](../api).

0 commit comments

Comments
 (0)