Skip to content

Commit

Permalink
add named exports
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Mar 5, 2024
1 parent 6eca7d0 commit 045a6e5
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/docs/functions/addHeader.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ sidebar_position: 0
custom_edit_url: null
---

**addHeader**(`header`, `context`): `string`
**addHeader**(`header`, `body`): `string`

#### Parameters

| Name | Type |
| :------ | :------ |
| `header` | `string` |
| `context` | `string` |
| `body` | `string` |

#### Returns

Expand Down
28 changes: 26 additions & 2 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A flexible, scalable and customizable agent for production apps. Comes with batt
![cj](https://github.com/jointhealliance/bgent/assets/18633264/7513b5a6-2352-45f3-8b87-7ee0e2171a30)

[![npm version](https://badge.fury.io/js/bgent.svg)](https://badge.fury.io/js/bgent)
![build passing](https://github.com/JoinTheAlliance/bgent/actions/workflows/deploy_worker.yaml/badge.svg)
![build passing](https://github.com/JoinTheAlliance/bgent/actions/workflows/build.yaml/badge.svg)
![tests passing](https://github.com/JoinTheAlliance/bgent/actions/workflows/test.yaml/badge.svg)
![lint passing](https://github.com/JoinTheAlliance/bgent/actions/workflows/lint.yaml/badge.svg)
[![License](https://img.shields.io/badge/License-MIT-blue)](https://github.com/jointhealliance/bgent/blob/main/LICENSE)
Expand Down Expand Up @@ -74,6 +74,10 @@ First, you will need to install the Supabase CLI. You can install it using the i

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

```bash
supabase init
```

```bash
supabase start
```
Expand Down Expand Up @@ -156,11 +160,31 @@ const runtime = new BgentRuntime({
evaluators: [fact],
});

// You can also register actions and evaluators after the runtime has been created
// OR you can register actions and evaluators after the runtime has been created
bgentRuntime.registerAction(wait);
bgentRuntime.registerEvaluator(fact);
```

## Custom Data Sources
If you want to add custom data into the context that is sent to the LLM, you can create a `Provider` and add it to the runtime.

```typescript
import { type BgentRuntime, type Message, type Provider, type State } from "bgent";

const time: Provider = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
get: async (_runtime: BgentRuntime, _message: Message, _state?: State) => {
const currentTime = new Date().toLocaleTimeString("en-US");
return "The current time is: " + currentTime;
},
};

const runtime = new BgentRuntime({
// ... other options
providers: [time],
});
```

## Handling User Input

The BgentRuntime instance has a `handleMessage` method that can be used to handle user input. The method returns a promise that resolves to the agent's response.
Expand Down
5 changes: 3 additions & 2 deletions docs/docs/types/Handler.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ sidebar_position: 0
custom_edit_url: null
---

Ƭ **Handler**: (`runtime`: [`BgentRuntime`](../classes/BgentRuntime.md), `message`: [`Message`](../interfaces/Message.md), `state?`: [`State`](../interfaces/State.md)) => `Promise`\<`unknown`\>
Ƭ **Handler**: (`runtime`: [`BgentRuntime`](../classes/BgentRuntime.md), `message`: [`Message`](../interfaces/Message.md), `state?`: [`State`](../interfaces/State.md), `options?`: \{ `[key: string]`: `unknown`; }) => `Promise`\<`unknown`\>

Represents the type of a handler function, which takes a runtime instance, a message, and an optional state, and returns a promise resolving to any type.

#### Type declaration

▸ (`runtime`, `message`, `state?`): `Promise`\<`unknown`\>
▸ (`runtime`, `message`, `state?`, `options?`): `Promise`\<`unknown`\>

##### Parameters

Expand All @@ -21,6 +21,7 @@ Represents the type of a handler function, which takes a runtime instance, a mes
| `runtime` | [`BgentRuntime`](../classes/BgentRuntime.md) |
| `message` | [`Message`](../interfaces/Message.md) |
| `state?` | [`State`](../interfaces/State.md) |
| `options?` | `Object` |

##### Returns

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/variables/goal-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ custom_edit_url: null
| `condition` | `string` |
| `description` | `string` |
| `examples` | \{ `context`: `string` ; `messages`: \{ `content`: \{ `content`: `string` = "I've just finished chapter 20 of 'War and Peace'!" } ; `user`: `string` = "\{\{user1}}" }[] ; `outcome`: `string` }[] |
| `handler` | (`runtime`: [`BgentRuntime`](../classes/BgentRuntime.md), `message`: [`Message`](../interfaces/Message.md)) => `Promise`\<[`Goal`](../interfaces/Goal.md)[]\> |
| `handler` | (`runtime`: [`BgentRuntime`](../classes/BgentRuntime.md), `message`: [`Message`](../interfaces/Message.md), `state`: `undefined` \| [`State`](../interfaces/State.md), `options`: \{ `[key: string]`: `unknown`; }) => `Promise`\<[`Goal`](../interfaces/Goal.md)[]\> |
| `name` | `string` |
| `validate` | (`runtime`: [`BgentRuntime`](../classes/BgentRuntime.md), `message`: [`Message`](../interfaces/Message.md)) => `Promise`\<`boolean`\> |
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bgent",
"version": "0.0.28",
"version": "0.0.29",
"private": false,
"description": "bgent. because agent was taken.",
"type": "module",
Expand Down
3 changes: 2 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ export default defineConfig([
file: pkg.main,
format: "cjs",
sourcemap: true,
exports: "auto",
exports: "named",
},
{
file: pkg.module,
format: "es",
sourcemap: true,
exports: "named",
},
],
plugins: [
Expand Down

0 comments on commit 045a6e5

Please sign in to comment.