Skip to content

Commit

Permalink
Merge pull request #66 from JoinTheAlliance/compose-state-additional
Browse files Browse the repository at this point in the history
Add additional key options to composeState
  • Loading branch information
lalalune authored Mar 21, 2024
2 parents 05960b3 + b9b48c3 commit 303ea0e
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 16 deletions.
3 changes: 2 additions & 1 deletion docs/docs/classes/BgentRuntime.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,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)[] ; `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` }\>
▸ **composeState**(`message`, `additionalKeys?`): `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` }\>

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

Expand All @@ -188,6 +188,7 @@ Compose the state of the agent into an object that can be passed or used for res
| Name | Type | Description |
| :------ | :------ | :------ |
| `message` | [`Message`](../interfaces/Message.md) | The message to compose the state from. |
| `additionalKeys` | `Object` | - |

#### Returns

Expand Down
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.1.6",
"version": "0.1.7",
"private": false,
"description": "bgent. because agent was taken.",
"type": "module",
Expand Down
2 changes: 0 additions & 2 deletions src/lib/__tests__/goals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ describe("Goals", () => {
onlyInProgress: false,
});

console.log("goals", goals);

const createdGoal = goals.find((goal: Goal) => goal.name === newGoal.name);

expect(createdGoal).toBeDefined();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/__tests__/messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("Messages Library", () => {
runtime,
room_id,
});
console.log("result", result);

expect(result.length).toBeGreaterThan(0);
result.forEach((actor: Actor) => {
expect(actor).toHaveProperty("name");
Expand Down
2 changes: 0 additions & 2 deletions src/lib/adapters/sqljs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ export class SqlJsDatabaseAdapter extends DatabaseAdapter {
}

stmt.free();
console.log("*** count result:", count);
return count;
}

Expand Down Expand Up @@ -545,7 +544,6 @@ export class SqlJsDatabaseAdapter extends DatabaseAdapter {
const relationship = stmt.getAsObject() as unknown as
| Relationship
| undefined;
console.log("relationship", relationship);
stmt.free();
return relationship || null;
}
Expand Down
1 change: 0 additions & 1 deletion src/lib/adapters/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
}

async createGoal(goal: Goal): Promise<void> {
console.log("inserting goal:", goal);
const { error } = await this.supabase.from("goals").insert(goal);
if (error) {
throw new Error(`Error creating goal: ${error.message}`);
Expand Down
6 changes: 5 additions & 1 deletion src/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,10 @@ export class BgentRuntime {
* @param message The message to compose the state from.
* @returns The state of the agent.
*/
async composeState(message: Message) {
async composeState(
message: Message,
additionalKeys: { [key: string]: unknown } = {},
) {
const { userId, room_id } = message;

const recentMessageCount = this.getRecentMessageCount();
Expand Down Expand Up @@ -549,6 +552,7 @@ export class BgentRuntime {
recentFactsData,
relevantFacts: addHeader("# Relevant Facts", relevantFacts),
relevantFactsData,
...additionalKeys,
};

const actionPromises = this.actions.map(async (action: Action) => {
Expand Down
2 changes: 0 additions & 2 deletions src/test/createRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ export async function createRuntime({
password: TEST_PASSWORD!,
});

console.log("response to signup", response);

// Change the name of the user
const { error } = await supabase
.from("accounts")
Expand Down
5 changes: 0 additions & 5 deletions src/test/getOrCreateRelationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,14 @@ export async function getOrCreateRelationship({
}

if (!relationship) {
console.log("Creating relationship", userA, userB);
// Create the relationship
await runtime.databaseAdapter.createRelationship({
userA,
userB,
});

console.log("Fetching relationship", userA, userB);

relationship = await getRelationship({ runtime, userA, userB });

console.log("Fetched relationship", relationship);

if (!relationship) {
throw new Error("Failed to fetch the created relationship");
}
Expand Down

0 comments on commit 303ea0e

Please sign in to comment.