|
| 1 | +# Eliza Documentation Site |
| 2 | + |
| 3 | +This the official documentation site of eliza. A flexible, scalable and customizable agent for production apps. which Comes with batteries-including database, deployment and examples using Supabase and Cloudflare. |
| 4 | + |
| 5 | +### Installation |
| 6 | +Currently eliza is dependent on Supabase for local development. You can install it with the following command: |
| 7 | + |
| 8 | + |
| 9 | + npm install eliza |
| 10 | + |
| 11 | +# Select your database adapter |
| 12 | + |
| 13 | + npm install sqlite-vss better-sqlite3 # for sqlite (simple, for local development) |
| 14 | + ``` |
| 15 | + |
| 16 | + npm install @supabase/supabase-js # for supabase (more complicated but can be deployed at scale) |
| 17 | +``` |
| 18 | + |
| 19 | + |
| 20 | +### Set up environment variables |
| 21 | + |
| 22 | +You will need a Supbase account, as well as an OpenAI developer account. |
| 23 | + |
| 24 | +Copy and paste the .dev.vars.example to .dev.vars and fill in the environment variables: |
| 25 | + |
| 26 | + SUPABASE_URL="https://your-supabase-url.supabase.co" |
| 27 | + SUPABASE_SERVICE_API_KEY="your-supabase-service-api-key" |
| 28 | + OPENAI_API_KEY="your-openai-api-key" |
| 29 | + |
| 30 | +### SQLite Local Setup (Easiest) |
| 31 | +You can use SQLite for local development. This is the easiest way to get started with eliza. |
| 32 | + |
| 33 | + import { BgentRuntime, SqliteDatabaseAdapter } from "eliza"; |
| 34 | + import { Database } from "sqlite3"; |
| 35 | + const sqliteDatabaseAdapter = new SqliteDatabaseAdapter(new Database(":memory:")); |
| 36 | + |
| 37 | + const runtime = new BgentRuntime({ |
| 38 | + serverUrl: "https://api.openai.com/v1", |
| 39 | + token: process.env.OPENAI_API_KEY, // Can be an API key or JWT token for your AI services |
| 40 | + databaseAdapter: sqliteDatabaseAdapter, |
| 41 | + // ... other options |
| 42 | + }); |
| 43 | + |
| 44 | +### Supabase Local Setup |
| 45 | +First, you will need to install the Supabase CLI. You can install it using the instructions here. |
| 46 | + |
| 47 | +Once you have the CLI installed, you can run the following commands to set up a local Supabase instance: |
| 48 | + |
| 49 | + supabase init |
| 50 | +``` |
| 51 | +
|
| 52 | +supabase start |
| 53 | +``` |
| 54 | + |
| 55 | +You can now start the eliza project with `npm run dev` and it will connect to the local Supabase instance by default. |
| 56 | + |
| 57 | +NOTE: You will need Docker installed for this to work. If that is an issue for you, use the Supabase Cloud Setup instructions instead below). |
| 58 | + |
| 59 | +### Supabase Cloud Setup |
| 60 | +This library uses Supabase as a database. You can set up a free account at supabase.io and create a new project. |
| 61 | + |
| 62 | +* Step 1: On the Subase All Projects Dashboard, select “New Project”. |
| 63 | +* Step 2: Select the organization to store the new project in, assign a database name, password and region. |
| 64 | +* Step 3: Select “Create New Project”. |
| 65 | +* Step 4: Wait for the database to setup. This will take a few minutes as supabase setups various directories. |
| 66 | +* Step 5: Select the “SQL Editor” tab from the left navigation menu. |
| 67 | +* Step 6: Copy in your own SQL dump file or optionally use the provided file in the eliza directory at: "src/supabase/db.sql". Note: You can use the command "supabase db dump" if you have a pre-exisiting supabase database to generate the SQL dump file. |
| 68 | +* Step 7: Paste the SQL code into the SQL Editor and hit run in the bottom right. |
| 69 | +* Step 8: Select the “Databases” tab from the left navigation menu to verify all of the tables have been added properly. |
| 70 | + |
| 71 | +Once you've set up your Supabase project, you can find your API key by going to the "Settings" tab and then "API". You will need to set the` SUPABASE_URL and SUPABASE_SERVICE_API_KEY` environment variables in your `.dev.vars` file. |
| 72 | + |
| 73 | +### Local Model Setup |
| 74 | + |
| 75 | +While eliza uses ChatGPT 3.5 by default, you can use a local model by setting the serverUrl to a local endpoint. The LocalAI project is a great way to run a local model with a compatible API endpoint. |
| 76 | + |
| 77 | + const runtime = new BgentRuntime({ |
| 78 | + serverUrl: process.env.LOCALAI_URL, |
| 79 | + token: process.env.LOCALAI_TOKEN, // Can be an API key or JWT token for your AI service |
| 80 | + // ... other options |
| 81 | + }); |
| 82 | + |
| 83 | + |
| 84 | +### Development |
| 85 | + |
| 86 | + npm run dev # start the server |
| 87 | +``` |
| 88 | +npm run shell # start the shell in another terminal to talk to the default agent |
| 89 | +``` |
| 90 | +### Usage |
| 91 | + import { BgentRuntime, SupabaseDatabaseAdapter, SqliteDatabaseAdapter } from "eliza"; |
| 92 | + |
| 93 | + const sqliteDatabaseAdapter = new SqliteDatabaseAdapter(new Database(":memory:")); |
| 94 | + |
| 95 | + ``` |
| 96 | + // You can also use Supabase like this |
| 97 | + // const supabaseDatabaseAdapter = new SupabaseDatabaseAdapter( |
| 98 | + // process.env.SUPABASE_URL, |
| 99 | + // process.env.SUPABASE_SERVICE_API_KEY) |
| 100 | + // ; |
| 101 | + |
| 102 | + ``` |
| 103 | + const runtime = new BgentRuntime({ |
| 104 | + serverUrl: "https://api.openai.com/v1", |
| 105 | + token: process.env.OPENAI_API_KEY, // Can be an API key or JWT token for your AI services |
| 106 | + databaseAdapter: sqliteDatabaseAdapter, |
| 107 | + actions: [ |
| 108 | + /* your custom actions */ |
| 109 | + ], |
| 110 | + evaluators: [ |
| 111 | + /* your custom evaluators */ |
| 112 | + ], |
| 113 | + model: "gpt-3.5-turbo", // whatever model you want to use |
| 114 | + embeddingModel: "text-embedding-3-small", // whatever model you want to use |
| 115 | + }); |
| 116 | + |
| 117 | + |
| 118 | +### what next? |
| 119 | +it is good to interact with the eliza and read more about the documentation on https://www.eliza.org/docs |
0 commit comments