Skip to content

Commit

Permalink
Significant test pass updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Mar 18, 2024
1 parent f6b7e52 commit c35f907
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 43 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 0 additions & 3 deletions src/lib/__tests__/goals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ describe("Goals", () => {
],
};

console.log("newGoal", newGoal);

await createGoal({
runtime,
goal: newGoal,
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/__tests__/messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -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);
});
});
Expand Down
8 changes: 2 additions & 6 deletions src/lib/__tests__/runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

Expand All @@ -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" },
Expand Down
9 changes: 5 additions & 4 deletions src/lib/actions/__tests__/elaborate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
});
Expand Down Expand Up @@ -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!;
Expand All @@ -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 =
Expand Down
8 changes: 6 additions & 2 deletions src/lib/actions/elaborate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default {
stop: [],
});

console.log("RESPONSE");
console.log("response", response);

runtime.databaseAdapter.log({
body: { message, context, response },
Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/lib/adapters/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
}

Expand Down
8 changes: 1 addition & 7 deletions src/lib/adapters/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
match_count: number;
unique: boolean;
}): Promise<Memory[]> {
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,
Expand All @@ -106,7 +101,6 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter {
query_field_sub_name: string;
query_match_count: number;
}): Promise<SimilaritySearch[]> {
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));
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 0 additions & 7 deletions src/lib/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -135,8 +130,6 @@ export class MemoryManager {
unique: !!unique,
});

console.log("result.embedding.length", result[0]?.embedding?.length);

return result;
}

Expand Down
4 changes: 0 additions & 4 deletions src/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion src/test/createRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -91,7 +95,7 @@ export async function createRuntime({
);
}
break;
}
}

const runtime = new BgentRuntime({
debugMode: false,
Expand Down
2 changes: 1 addition & 1 deletion src/test/populateMemories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/test/runAiTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}

Expand Down

0 comments on commit c35f907

Please sign in to comment.