From 20f4265a9370032a6fa0e4275298d55c70c35778 Mon Sep 17 00:00:00 2001 From: moon Date: Wed, 20 Mar 2024 23:09:52 -0700 Subject: [PATCH 1/2] Updat docs, remove logs, add optionals to composeState --- docs/docs/classes/BgentRuntime.md | 3 ++- package.json | 2 +- src/lib/__tests__/goals.test.ts | 2 -- src/lib/__tests__/messages.test.ts | 2 +- src/lib/adapters/sqljs.ts | 2 -- src/lib/adapters/supabase.ts | 1 - src/lib/runtime.ts | 6 +++++- src/test/createRuntime.ts | 2 -- 8 files changed, 9 insertions(+), 11 deletions(-) diff --git a/docs/docs/classes/BgentRuntime.md b/docs/docs/classes/BgentRuntime.md index 0d20922..738c943 100644 --- a/docs/docs/classes/BgentRuntime.md +++ b/docs/docs/classes/BgentRuntime.md @@ -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. @@ -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 diff --git a/package.json b/package.json index e582f98..6a481d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bgent", - "version": "0.1.6", + "version": "0.1.7", "private": false, "description": "bgent. because agent was taken.", "type": "module", diff --git a/src/lib/__tests__/goals.test.ts b/src/lib/__tests__/goals.test.ts index d3e988f..d99150e 100644 --- a/src/lib/__tests__/goals.test.ts +++ b/src/lib/__tests__/goals.test.ts @@ -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(); diff --git a/src/lib/__tests__/messages.test.ts b/src/lib/__tests__/messages.test.ts index 16ef309..5cf2c89 100644 --- a/src/lib/__tests__/messages.test.ts +++ b/src/lib/__tests__/messages.test.ts @@ -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"); diff --git a/src/lib/adapters/sqljs.ts b/src/lib/adapters/sqljs.ts index 270fe84..648010f 100644 --- a/src/lib/adapters/sqljs.ts +++ b/src/lib/adapters/sqljs.ts @@ -367,7 +367,6 @@ export class SqlJsDatabaseAdapter extends DatabaseAdapter { } stmt.free(); - console.log("*** count result:", count); return count; } @@ -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; } diff --git a/src/lib/adapters/supabase.ts b/src/lib/adapters/supabase.ts index 71c7196..01bcbe5 100644 --- a/src/lib/adapters/supabase.ts +++ b/src/lib/adapters/supabase.ts @@ -302,7 +302,6 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { } async createGoal(goal: Goal): Promise { - console.log("inserting goal:", goal); const { error } = await this.supabase.from("goals").insert(goal); if (error) { throw new Error(`Error creating goal: ${error.message}`); diff --git a/src/lib/runtime.ts b/src/lib/runtime.ts index 15d5ccf..486c37c 100644 --- a/src/lib/runtime.ts +++ b/src/lib/runtime.ts @@ -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(); @@ -549,6 +552,7 @@ export class BgentRuntime { recentFactsData, relevantFacts: addHeader("# Relevant Facts", relevantFacts), relevantFactsData, + ...additionalKeys, }; const actionPromises = this.actions.map(async (action: Action) => { diff --git a/src/test/createRuntime.ts b/src/test/createRuntime.ts index dbf8772..c7cf06b 100644 --- a/src/test/createRuntime.ts +++ b/src/test/createRuntime.ts @@ -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") From b9b48c36f8a22f143ec310e4a45814b2286aeb41 Mon Sep 17 00:00:00 2001 From: moon Date: Wed, 20 Mar 2024 23:10:01 -0700 Subject: [PATCH 2/2] remove loves --- src/test/getOrCreateRelationship.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/test/getOrCreateRelationship.ts b/src/test/getOrCreateRelationship.ts index edf9653..b87b5dc 100644 --- a/src/test/getOrCreateRelationship.ts +++ b/src/test/getOrCreateRelationship.ts @@ -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"); }