diff --git a/package.json b/package.json index 8ccf8f5..bfcce52 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "shell": "node --no-warnings scripts/shell.mjs --dev", "concat": "node ./scripts/concat.mjs", "shell:cloud": "node --no-warnings scripts/shell.mjs", - "test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --runInBand", + "test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest -f --runInBand", "test:coverage": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --coverage", "reset-profile": "rimraf ~/.cjrc", "deploy": "wrangler deploy", diff --git a/src/lib/__tests__/goals.test.ts b/src/lib/__tests__/goals.test.ts index c6c1e78..c4c9d40 100644 --- a/src/lib/__tests__/goals.test.ts +++ b/src/lib/__tests__/goals.test.ts @@ -42,8 +42,6 @@ describe("Goals", () => { ], }; - console.log("newGoal", newGoal); - await createGoal({ runtime, goal: newGoal, @@ -90,7 +88,6 @@ describe("Goals", () => { room_id: zeroUuid, onlyInProgress: false, }); - console.log("goals", goals); const existingGoal = goals.find( (goal: Goal) => goal.name === newGoal.name, ) as Goal; diff --git a/src/lib/__tests__/messages.test.ts b/src/lib/__tests__/messages.test.ts index 566df7a..c2dfde5 100644 --- a/src/lib/__tests__/messages.test.ts +++ b/src/lib/__tests__/messages.test.ts @@ -7,6 +7,9 @@ import { type Actor, type Content, type Memory } from "../types"; import { formatFacts } from "../evaluators/fact"; import { createRelationship, getRelationship } from "../relationships"; import { zeroUuid } from "../constants"; +import dotenv from "dotenv"; + +dotenv.config({ path: ".dev.vars" }); describe("Messages Library", () => { let runtime: BgentRuntime, user: User, actors: Actor[]; @@ -57,11 +60,8 @@ describe("Messages Library", () => { }); test("formatActors should format actors into a readable string", () => { - console.log("*** actors", actors); const formattedActors = formatActors({ actors }); - console.log("*** formattedActors", formattedActors); actors.forEach((actor) => { - console.log("*** actor.name", actor.name); expect(formattedActors).toContain(actor.name); }); }); diff --git a/src/lib/__tests__/runtime.test.ts b/src/lib/__tests__/runtime.test.ts index 86dd1bb..e040415 100644 --- a/src/lib/__tests__/runtime.test.ts +++ b/src/lib/__tests__/runtime.test.ts @@ -76,10 +76,8 @@ describe("Agent Runtime", () => { userB: zeroUuid, }); } - - console.log("data", data); - - room_id = data?.room_id as UUID; + // TODO: This seems to be defaulting to zeroUuid, but we should be able to get the room_id from the relationship + room_id = (data?.room_id as UUID) || zeroUuid; await clearMemories(); // Clear memories before each test }); @@ -105,8 +103,6 @@ describe("Agent Runtime", () => { console.error("Error creating memories", error); } - console.log("room_id", room_id); - const message: Message = { userId: user.id as UUID, content: { content: "test message" }, diff --git a/src/lib/actions/__tests__/elaborate.test.ts b/src/lib/actions/__tests__/elaborate.test.ts index f2d806c..ae1c6ba 100644 --- a/src/lib/actions/__tests__/elaborate.test.ts +++ b/src/lib/actions/__tests__/elaborate.test.ts @@ -45,7 +45,7 @@ const GetContinueExample1 = (_user_id: UUID) => [ describe("User Profile", () => { let user: User; let runtime: BgentRuntime; - let room_id: UUID; + let room_id: UUID = zeroUuid; afterAll(async () => { await cleanup(); @@ -69,7 +69,8 @@ describe("User Profile", () => { throw new Error("Relationship not found"); } - room_id = data?.room_id; + // TODO: This is a temporary fix for the room_id not being set in the relationship + room_id = data?.room_id || zeroUuid; await cleanup(); }); @@ -124,7 +125,7 @@ describe("User Profile", () => { "Hmm, let think for a second, I was going to tell you about something...", action: "ELABORATE", }, - room_id: room_id as UUID, + room_id, }; const handler = action.handler!; @@ -148,7 +149,7 @@ describe("User Profile", () => { "Write a short story in three parts, using the ELABORATE action for each part.", action: "WAIT", }, - room_id: room_id as UUID, + room_id, }; const initialMessageCount = diff --git a/src/lib/actions/elaborate.ts b/src/lib/actions/elaborate.ts index d8211a5..67b8c13 100644 --- a/src/lib/actions/elaborate.ts +++ b/src/lib/actions/elaborate.ts @@ -66,7 +66,7 @@ export default { stop: [], }); - console.log("RESPONSE"); + console.log("response", response); runtime.databaseAdapter.log({ body: { message, context, response }, @@ -90,7 +90,11 @@ export default { if (runtime.debugMode) { logger.error("No response content"); } - return; + // TODO: Verify that this is the correct response handling + return { + content: "No response.", + action: "IGNORE", + }; } // prevent repetition diff --git a/src/lib/adapters/sqlite.ts b/src/lib/adapters/sqlite.ts index c8dc009..3f7a069 100644 --- a/src/lib/adapters/sqlite.ts +++ b/src/lib/adapters/sqlite.ts @@ -152,9 +152,6 @@ export class SqliteDatabaseAdapter extends DatabaseAdapter { sql += ` LIMIT ${params.count}`; } - console.log("sql"); - console.log(sql); - return this.db.prepare(sql).all() as Memory[]; } diff --git a/src/lib/adapters/supabase.ts b/src/lib/adapters/supabase.ts index 0a9dbc0..425dd52 100644 --- a/src/lib/adapters/supabase.ts +++ b/src/lib/adapters/supabase.ts @@ -79,11 +79,6 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { match_count: number; unique: boolean; }): Promise { - console.log( - "searching memories", - params.tableName, - params.embedding.length, - ); const result = await this.supabase.rpc("search_memories", { query_table_name: params.tableName, query_room_id: params.room_id, @@ -106,7 +101,6 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { query_field_sub_name: string; query_match_count: number; }): Promise { - console.log("get_memory_by_content", opts); const result = await this.supabase.rpc("get_embedding_list", opts); if (result.error) { throw new Error(JSON.stringify(result.error)); @@ -285,7 +279,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { only_in_progress: params.onlyInProgress, row_count: params.count, }; - console.log("opts", opts) + const { data: goals, error } = await this.supabase.rpc("get_goals", opts); if (error) { diff --git a/src/lib/memory.ts b/src/lib/memory.ts index d86e65d..ee8320e 100644 --- a/src/lib/memory.ts +++ b/src/lib/memory.ts @@ -121,11 +121,6 @@ export class MemoryManager { unique, } = opts; - console.log("embedding length to search is", embedding.length); - - console.log("opts are", opts); - console.log(opts); - const result = await this.runtime.databaseAdapter.searchMemories({ tableName: this.tableName, room_id, @@ -135,8 +130,6 @@ export class MemoryManager { unique: !!unique, }); - console.log("result.embedding.length", result[0]?.embedding?.length); - return result; } diff --git a/src/lib/runtime.ts b/src/lib/runtime.ts index 059b9d9..e59b9bb 100644 --- a/src/lib/runtime.ts +++ b/src/lib/runtime.ts @@ -329,8 +329,6 @@ export class BgentRuntime { const data: OpenAIEmbeddingResponse = await response.json(); - console.log("*** EMBEDDING LENGTH IS", data?.data?.[0].embedding.length); - return data?.data?.[0].embedding; } catch (e) { console.error(e); @@ -449,8 +447,6 @@ export class BgentRuntime { async composeState(message: Message) { const { userId, room_id } = message; - console.log("message", message); - const recentMessageCount = this.getRecentMessageCount(); const recentFactsCount = Math.ceil(this.getRecentMessageCount() / 2); const relevantFactsCount = Math.ceil(this.getRecentMessageCount() / 2); diff --git a/src/test/createRuntime.ts b/src/test/createRuntime.ts index 5f0f2d1..b167199 100644 --- a/src/test/createRuntime.ts +++ b/src/test/createRuntime.ts @@ -52,6 +52,10 @@ export async function createRuntime({ case "supabase": default: { + console.log( + "env?.SUPABASE_SERVICE_API_KEY", + env?.SUPABASE_SERVICE_API_KEY, + ); const supabase = createClient( env?.SUPABASE_URL ?? SUPABASE_URL, env?.SUPABASE_SERVICE_API_KEY ?? SUPABASE_ANON_KEY, @@ -91,7 +95,7 @@ export async function createRuntime({ ); } break; - } + } const runtime = new BgentRuntime({ debugMode: false, diff --git a/src/test/populateMemories.ts b/src/test/populateMemories.ts index 54c6b8b..e367b34 100644 --- a/src/test/populateMemories.ts +++ b/src/test/populateMemories.ts @@ -21,7 +21,7 @@ export async function populateMemories( content: c.content.content, action: c.content.action as string, }, - room_id: room_id as UUID, + room_id, embedding: existingEmbedding, }); await runtime.messageManager.createMemory(bakedMemory); diff --git a/src/test/runAiTest.ts b/src/test/runAiTest.ts index 3c1991b..a84d386 100644 --- a/src/test/runAiTest.ts +++ b/src/test/runAiTest.ts @@ -8,7 +8,7 @@ export async function runAiTest( let successful = 0; for (let i = 0; i < runs; i++) { - console.log("Running test", testName, " (iteration", i + ")"); + // console.log("Running test", testName, " (iteration", i + ")"); if (await testFunc()) successful++; }