Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
add a readme for the doc section representing the documentation site
  • Loading branch information
emmz3230 authored May 19, 2024
1 parent 2250faf commit 1f5afb8
Showing 1 changed file with 108 additions and 6 deletions.
114 changes: 108 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,119 @@
# Website
# Bgent Documentation Site

This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
This the official documentation site of bgent. A flexible, scalable and customizable agent for production apps. which Comes with batteries-including database, deployment and examples using Supabase and Cloudflare.

### Installation
Currently bgent is dependent on Supabase for local development. You can install it with the following command:


npm install bgent

# Select your database adapter

npm install sqlite-vss better-sqlite3 # for sqlite (simple, for local development)
```
npm install @supabase/supabase-js # for supabase (more complicated but can be deployed at scale)
```


### Set up environment variables

You will need a Supbase account, as well as an OpenAI developer account.

Copy and paste the .dev.vars.example to .dev.vars and fill in the environment variables:

SUPABASE_URL="https://your-supabase-url.supabase.co"
SUPABASE_SERVICE_API_KEY="your-supabase-service-api-key"
OPENAI_API_KEY="your-openai-api-key"

### SQLite Local Setup (Easiest)
You can use SQLite for local development. This is the easiest way to get started with bgent.

import { BgentRuntime, SqliteDatabaseAdapter } from "bgent";
import { Database } from "sqlite3";
const sqliteDatabaseAdapter = new SqliteDatabaseAdapter(new Database(":memory:"));

const runtime = new BgentRuntime({
serverUrl: "https://api.openai.com/v1",
token: process.env.OPENAI_API_KEY, // Can be an API key or JWT token for your AI services
databaseAdapter: sqliteDatabaseAdapter,
// ... other options
});

### Supabase Local Setup
First, you will need to install the Supabase CLI. You can install it using the instructions here.

Once you have the CLI installed, you can run the following commands to set up a local Supabase instance:

supabase init
```
$ npm install
supabase start
```

### Local Development
You can now start the bgent project with `npm run dev` and it will connect to the local Supabase instance by default.

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).

### Supabase Cloud Setup
This library uses Supabase as a database. You can set up a free account at supabase.io and create a new project.

* Step 1: On the Subase All Projects Dashboard, select “New Project”.
* Step 2: Select the organization to store the new project in, assign a database name, password and region.
* Step 3: Select “Create New Project”.
* Step 4: Wait for the database to setup. This will take a few minutes as supabase setups various directories.
* Step 5: Select the “SQL Editor” tab from the left navigation menu.
* Step 6: Copy in your own SQL dump file or optionally use the provided file in the bgent 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.
* Step 7: Paste the SQL code into the SQL Editor and hit run in the bottom right.
* Step 8: Select the “Databases” tab from the left navigation menu to verify all of the tables have been added properly.

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.

### Local Model Setup

While bgent 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.

const runtime = new BgentRuntime({
serverUrl: process.env.LOCALAI_URL,
token: process.env.LOCALAI_TOKEN, // Can be an API key or JWT token for your AI service
// ... other options
});


### Development

npm run dev # start the server
```
$ npm start
npm run shell # start the shell in another terminal to talk to the default agent
```
### Usage
import { BgentRuntime, SupabaseDatabaseAdapter, SqliteDatabaseAdapter } from "bgent";
const sqliteDatabaseAdapter = new SqliteDatabaseAdapter(new Database(":memory:"));
```
// You can also use Supabase like this
// const supabaseDatabaseAdapter = new SupabaseDatabaseAdapter(
// process.env.SUPABASE_URL,
// process.env.SUPABASE_SERVICE_API_KEY)
// ;
```
const runtime = new BgentRuntime({
serverUrl: "https://api.openai.com/v1",
token: process.env.OPENAI_API_KEY, // Can be an API key or JWT token for your AI services
databaseAdapter: sqliteDatabaseAdapter,
actions: [
/* your custom actions */
],
evaluators: [
/* your custom evaluators */
],
model: "gpt-3.5-turbo", // whatever model you want to use
embeddingModel: "text-embedding-3-small", // whatever model you want to use
});


This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
### what next?
it is good to interact with the bgent and read more about the documentation on https://www.bgent.org/docs

0 comments on commit 1f5afb8

Please sign in to comment.