Skip to content

Commit

Permalink
Add goals, provider tests, doc updates, small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Feb 25, 2024
1 parent f775394 commit 177ad29
Show file tree
Hide file tree
Showing 41 changed files with 678 additions and 262 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,20 @@ Bgent is customized through actions and evaluators. Actions are functions that a

An example of an action is `wait` (the agent should stop and wait for the user to respond) or `continue` (the agent should continue with the next step in the conversation).

An example of a evaluator is `summarization` (the agent should summarize the conversation so far).
An example of a evaluator is `fact` (the agent should summarize the conversation so far).

```typescript
import { wait, summarization } from "bgent";
import { wait, fact } from "bgent";

const runtime = new BgentRuntime({
// ... other options
actions: [wait],
evaluators: [summarization],
evaluators: [fact],
});

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

## Handling User Input
Expand Down
42 changes: 30 additions & 12 deletions docs/docs/classes/BgentRuntime.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Creates an instance of BgentRuntime.
| `opts.actions?` | [`Action`](../interfaces/Action.md)[] | Optional custom actions. |
| `opts.debugMode?` | `boolean` | If true, debug messages will be logged. |
| `opts.evaluators?` | [`Evaluator`](../interfaces/Evaluator.md)[] | Optional custom evaluators. |
| `opts.flavor?` | `string` | Optional lore to inject into the default prompt. |
| `opts.providers?` | [`Provider`](../interfaces/Provider.md)[] | Optional context providers. |
| `opts.recentMessageCount?` | `number` | The number of messages to hold in the recent message cache. |
| `opts.serverUrl?` | `string` | The URL of the worker. |
| `opts.supabase` | `default`\<`any`, ``"public"``, `any`\> | The Supabase client. |
Expand Down Expand Up @@ -69,11 +69,11 @@ Evaluators used to assess and guide the agent's responses.

___

### flavor
### factManager

**flavor**: `string` = `""`
**factManager**: [`MemoryManager`](MemoryManager.md)

A string to customize the agent's behavior or responses.
Manage the fact and recall of facts.

___

Expand All @@ -93,19 +93,19 @@ Store messages that are sent and received by the agent.

___

### serverUrl
### providers

**serverUrl**: `string` = `"http://localhost:7998"`
**providers**: [`Provider`](../interfaces/Provider.md)[] = `[]`

The base URL of the server where the agent's requests are processed.
Context providers used to provide context for message generation.

___

### summarizationManager
### serverUrl

**summarizationManager**: [`MemoryManager`](MemoryManager.md)
**serverUrl**: `string` = `"http://localhost:7998"`

Manage the summarization and recall of facts.
The base URL of the server where the agent's requests are processed.

___

Expand Down Expand Up @@ -152,7 +152,7 @@ ___

### composeState

▸ **composeState**(`message`): `Promise`\<\{ `actionConditions`: `string` ; `actionExamples`: `string` ; `actionNames`: `string` ; `actions`: `string` ; `actors`: `string` ; `actorsData`: [`Actor`](../interfaces/Actor.md)[] ; `agentId`: \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\` ; `agentName`: `undefined` \| `string` ; `evaluatorConditions`: `string` ; `evaluatorExamples`: `string` ; `evaluatorNames`: `string` ; `evaluators`: `string` ; `evaluatorsData`: [`Evaluator`](../interfaces/Evaluator.md)[] ; `flavor`: `string` ; `goals`: `string` ; `goalsData`: [`Goal`](../interfaces/Goal.md)[] ; `lore`: `string` ; `loreData`: [`Memory`](../interfaces/Memory.md)[] ; `recentMessages`: `string` ; `recentMessagesData`: [`Memory`](../interfaces/Memory.md)[] ; `recentSummarizations`: `string` ; `recentSummarizationsData`: [`Memory`](../interfaces/Memory.md)[] ; `relevantSummarizations`: `string` ; `relevantSummarizationsData`: [`Memory`](../interfaces/Memory.md)[] ; `room_id`: \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\` ; `senderName`: `undefined` \| `string` ; `userIds`: \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\`[] }\>
▸ **composeState**(`message`): `Promise`\<\{ `actionConditions`: `string` ; `actionExamples`: `string` ; `actionNames`: `string` ; `actions`: `string` ; `actors`: `string` ; `actorsData`: [`Actor`](../interfaces/Actor.md)[] ; `agentId`: \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\` ; `agentName`: `undefined` \| `string` ; `evaluatorConditions`: `string` ; `evaluatorExamples`: `string` ; `evaluatorNames`: `string` ; `evaluators`: `string` ; `evaluatorsData`: [`Evaluator`](../interfaces/Evaluator.md)[] ; `goals`: `string` ; `goalsData`: [`Goal`](../interfaces/Goal.md)[] ; `lore`: `string` ; `loreData`: [`Memory`](../interfaces/Memory.md)[] ; `providers`: `string` ; `recentFacts`: `string` ; `recentFactsData`: [`Memory`](../interfaces/Memory.md)[] ; `recentMessages`: `string` ; `recentMessagesData`: [`Memory`](../interfaces/Memory.md)[] ; `relevantFacts`: `string` ; `relevantFactsData`: [`Memory`](../interfaces/Memory.md)[] ; `room_id`: \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\` ; `senderName`: `undefined` \| `string` ; `userIds`: \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\`[] }\>

Compose the state of the agent into an object that can be passed or used for response generation.

Expand All @@ -164,7 +164,7 @@ Compose the state of the agent into an object that can be passed or used for res

#### Returns

`Promise`\<\{ `actionConditions`: `string` ; `actionExamples`: `string` ; `actionNames`: `string` ; `actions`: `string` ; `actors`: `string` ; `actorsData`: [`Actor`](../interfaces/Actor.md)[] ; `agentId`: \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\` ; `agentName`: `undefined` \| `string` ; `evaluatorConditions`: `string` ; `evaluatorExamples`: `string` ; `evaluatorNames`: `string` ; `evaluators`: `string` ; `evaluatorsData`: [`Evaluator`](../interfaces/Evaluator.md)[] ; `flavor`: `string` ; `goals`: `string` ; `goalsData`: [`Goal`](../interfaces/Goal.md)[] ; `lore`: `string` ; `loreData`: [`Memory`](../interfaces/Memory.md)[] ; `recentMessages`: `string` ; `recentMessagesData`: [`Memory`](../interfaces/Memory.md)[] ; `recentSummarizations`: `string` ; `recentSummarizationsData`: [`Memory`](../interfaces/Memory.md)[] ; `relevantSummarizations`: `string` ; `relevantSummarizationsData`: [`Memory`](../interfaces/Memory.md)[] ; `room_id`: \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\` ; `senderName`: `undefined` \| `string` ; `userIds`: \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\`[] }\>
`Promise`\<\{ `actionConditions`: `string` ; `actionExamples`: `string` ; `actionNames`: `string` ; `actions`: `string` ; `actors`: `string` ; `actorsData`: [`Actor`](../interfaces/Actor.md)[] ; `agentId`: \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\` ; `agentName`: `undefined` \| `string` ; `evaluatorConditions`: `string` ; `evaluatorExamples`: `string` ; `evaluatorNames`: `string` ; `evaluators`: `string` ; `evaluatorsData`: [`Evaluator`](../interfaces/Evaluator.md)[] ; `goals`: `string` ; `goalsData`: [`Goal`](../interfaces/Goal.md)[] ; `lore`: `string` ; `loreData`: [`Memory`](../interfaces/Memory.md)[] ; `providers`: `string` ; `recentFacts`: `string` ; `recentFactsData`: [`Memory`](../interfaces/Memory.md)[] ; `recentMessages`: `string` ; `recentMessagesData`: [`Memory`](../interfaces/Memory.md)[] ; `relevantFacts`: `string` ; `relevantFactsData`: [`Memory`](../interfaces/Memory.md)[] ; `room_id`: \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\` ; `senderName`: `undefined` \| `string` ; `userIds`: \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\`[] }\>

The state of the agent.

Expand Down Expand Up @@ -283,6 +283,24 @@ Register an action for the agent to perform.

___

### registerContextProvider

**registerContextProvider**(`provider`): `void`

Register a context provider to provide context for message generation.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `provider` | [`Provider`](../interfaces/Provider.md) | The context provider to register. |

#### Returns

`void`

___

### registerEvaluator

**registerEvaluator**(`evaluator`): `void`
Expand Down
25 changes: 25 additions & 0 deletions docs/docs/enums/GoalStatus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
id: "GoalStatus"
title: "Enumeration: GoalStatus"
sidebar_label: "GoalStatus"
sidebar_position: 0
custom_edit_url: null
---

## Enumeration Members

### DONE

**DONE** = ``"DONE"``

___

### FAILED

**FAILED** = ``"FAILED"``

___

### IN\_PROGRESS

**IN\_PROGRESS** = ``"IN_PROGRESS"``
2 changes: 2 additions & 0 deletions docs/docs/enums/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
label: "Enumerations"
position: 2
20 changes: 20 additions & 0 deletions docs/docs/functions/addHeader.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
id: "addHeader"
title: "Function: addHeader"
sidebar_label: "addHeader"
sidebar_position: 0
custom_edit_url: null
---

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

#### Parameters

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

#### Returns

`string`
4 changes: 2 additions & 2 deletions docs/docs/functions/cancelGoal.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_position: 0
custom_edit_url: null
---

**cancelGoal**(`«destructured»`): `Promise`\<`void`\>
**cancelGoal**(`«destructured»`): `Promise`\<`PostgrestSingleResponse`\<``null``\>\>

#### Parameters

Expand All @@ -18,4 +18,4 @@ custom_edit_url: null

#### Returns

`Promise`\<`void`\>
`Promise`\<`PostgrestSingleResponse`\<``null``\>\>
6 changes: 2 additions & 4 deletions docs/docs/functions/createGoal.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_position: 0
custom_edit_url: null
---

**createGoal**(`«destructured»`): `Promise`\<`void`\>
**createGoal**(`«destructured»`): `Promise`\<`PostgrestSingleResponse`\<``null``\>\>

#### Parameters

Expand All @@ -15,9 +15,7 @@ custom_edit_url: null
| `«destructured»` | `Object` |
| › `goal` | [`Goal`](../interfaces/Goal.md) |
| › `runtime` | [`BgentRuntime`](../classes/BgentRuntime.md) |
| › `userId` | `string` |
| › `userIds` | `string`[] |

#### Returns

`Promise`\<`void`\>
`Promise`\<`PostgrestSingleResponse`\<``null``\>\>
4 changes: 2 additions & 2 deletions docs/docs/functions/finishGoal.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_position: 0
custom_edit_url: null
---

**finishGoal**(`«destructured»`): `Promise`\<`void`\>
**finishGoal**(`«destructured»`): `Promise`\<`PostgrestSingleResponse`\<``null``\>\>

#### Parameters

Expand All @@ -18,4 +18,4 @@ custom_edit_url: null

#### Returns

`Promise`\<`void`\>
`Promise`\<`PostgrestSingleResponse`\<``null``\>\>
4 changes: 2 additions & 2 deletions docs/docs/functions/finishGoalObjective.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_position: 0
custom_edit_url: null
---

**finishGoalObjective**(`«destructured»`): `Promise`\<`void`\>
**finishGoalObjective**(`«destructured»`): `Promise`\<`PostgrestSingleResponse`\<``null``\>\>

#### Parameters

Expand All @@ -19,4 +19,4 @@ custom_edit_url: null

#### Returns

`Promise`\<`void`\>
`Promise`\<`PostgrestSingleResponse`\<``null``\>\>
24 changes: 24 additions & 0 deletions docs/docs/functions/getProviders.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
id: "getProviders"
title: "Function: getProviders"
sidebar_label: "getProviders"
sidebar_position: 0
custom_edit_url: null
---

**getProviders**(`runtime`, `message`): `Promise`\<`string`\>

Formats provider outputs into a string which can be injected into the context.

#### Parameters

| Name | Type |
| :------ | :------ |
| `runtime` | [`BgentRuntime`](../classes/BgentRuntime.md) |
| `message` | [`Message`](../interfaces/Message.md) |

#### Returns

`Promise`\<`string`\>

A string that concatenates the outputs of each provider.
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
id: "updateGoals"
title: "Function: updateGoals"
sidebar_label: "updateGoals"
id: "updateGoal"
title: "Function: updateGoal"
sidebar_label: "updateGoal"
sidebar_position: 0
custom_edit_url: null
---

**updateGoals**(`«destructured»`): `Promise`\<`void`\>
**updateGoal**(`«destructured»`): `Promise`\<`PostgrestSingleResponse`\<``null``\>\>

#### Parameters

| Name | Type |
| :------ | :------ |
| `«destructured»` | `Object` |
| › `goals` | [`Goal`](../interfaces/Goal.md)[] |
| › `goal` | [`Goal`](../interfaces/Goal.md) |
| › `runtime` | [`BgentRuntime`](../classes/BgentRuntime.md) |
| › `userIds` | \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\`[] |

#### Returns

`Promise`\<`void`\>
`Promise`\<`PostgrestSingleResponse`\<``null``\>\>
10 changes: 6 additions & 4 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ A flexible, scalable and customizable agent for production apps. Comes with batt

[![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)
![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)
[![stars - bgent](https://img.shields.io/github/stars/jointhealliance/bgent?style=social)](https://github.com/jointhealliance/bgent)
[![forks - bgent](https://img.shields.io/github/forks/jointhealliance/bgent?style=social)](https://github.com/jointhealliance/bgent)
Expand Down Expand Up @@ -143,20 +145,20 @@ Bgent is customized through actions and evaluators. Actions are functions that a

An example of an action is `wait` (the agent should stop and wait for the user to respond) or `continue` (the agent should continue with the next step in the conversation).

An example of a evaluator is `summarization` (the agent should summarize the conversation so far).
An example of a evaluator is `fact` (the agent should summarize the conversation so far).

```typescript
import { wait, summarization } from "bgent";
import { wait, fact } from "bgent";

const runtime = new BgentRuntime({
// ... other options
actions: [wait],
evaluators: [summarization],
evaluators: [fact],
});

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

## Handling User Input
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/interfaces/Goal.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Represents a goal, which is a higher-level aim composed of one or more objective

### id

**id**: \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\`
`Optional` **id**: \`$\{string}-$\{string}-$\{string}-$\{string}-$\{string}\`

___

Expand All @@ -30,7 +30,7 @@ ___

### status

**status**: `string`
**status**: [`GoalStatus`](../enums/GoalStatus.md)

___

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/interfaces/Objective.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ ___

### id

**id**: `string`
`Optional` **id**: `string`
29 changes: 29 additions & 0 deletions docs/docs/interfaces/Provider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
id: "Provider"
title: "Interface: Provider"
sidebar_label: "Provider"
sidebar_position: 0
custom_edit_url: null
---

## Properties

### get

**get**: (`runtime`: [`BgentRuntime`](../classes/BgentRuntime.md), `message`: [`Message`](Message.md), `state?`: [`State`](State.md)) => `Promise`\<`unknown`\>

#### Type declaration

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

##### Parameters

| Name | Type |
| :------ | :------ |
| `runtime` | [`BgentRuntime`](../classes/BgentRuntime.md) |
| `message` | [`Message`](Message.md) |
| `state?` | [`State`](State.md) |

##### Returns

`Promise`\<`unknown`\>
Loading

0 comments on commit 177ad29

Please sign in to comment.