From 045a6e5eeba4cce88cdcedfdad918ce75d0833ac Mon Sep 17 00:00:00 2001 From: moon Date: Mon, 4 Mar 2024 19:07:59 -0800 Subject: [PATCH] add named exports --- docs/docs/functions/addHeader.md | 4 ++-- docs/docs/index.md | 28 ++++++++++++++++++++++++++-- docs/docs/types/Handler.md | 5 +++-- docs/docs/variables/goal-1.md | 2 +- package.json | 2 +- rollup.config.js | 3 ++- 6 files changed, 35 insertions(+), 9 deletions(-) diff --git a/docs/docs/functions/addHeader.md b/docs/docs/functions/addHeader.md index 1b8de60..0e060e3 100644 --- a/docs/docs/functions/addHeader.md +++ b/docs/docs/functions/addHeader.md @@ -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 diff --git a/docs/docs/index.md b/docs/docs/index.md index 44392aa..e713abd 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -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) @@ -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 ``` @@ -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. diff --git a/docs/docs/types/Handler.md b/docs/docs/types/Handler.md index cf0187b..72a58f6 100644 --- a/docs/docs/types/Handler.md +++ b/docs/docs/types/Handler.md @@ -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 @@ -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 diff --git a/docs/docs/variables/goal-1.md b/docs/docs/variables/goal-1.md index 7ac9c2e..129f8d0 100644 --- a/docs/docs/variables/goal-1.md +++ b/docs/docs/variables/goal-1.md @@ -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`\> | diff --git a/package.json b/package.json index bba87ad..6743b0a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bgent", - "version": "0.0.28", + "version": "0.0.29", "private": false, "description": "bgent. because agent was taken.", "type": "module", diff --git a/rollup.config.js b/rollup.config.js index 655a1a1..4bd1648 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -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: [