Skip to content

Commit

Permalink
add goal tests, fix other tests, reference zeroUuid in lib constants
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Feb 25, 2024
1 parent 0dbda8b commit e24906e
Show file tree
Hide file tree
Showing 33 changed files with 649 additions and 348 deletions.
2 changes: 1 addition & 1 deletion scripts/concat.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { fileURLToPath } from 'url'
const instructions = 'The above code was taken from my codebase at https://github.com/jointhealliance/bgent. You are writing tests and documentation for my codebase. Please use the above code as a reference. Tests should be written with Jest and Typescript. Do not use mocks or stubs. Keep it very simple and straightforward.'

// Patterns to ignore
const ignorePatterns = ['tests', 'test', 'agents', 'cache', 'supabase', 'utils', 'logger', 'index', 'data', 'constants', 'templates', 'worker']
const ignorePatterns = ['test/', 'relationships', 'memory', 'providers', 'messages', 'context', 'agents', 'cache', 'supabase', 'utils', 'logger', 'index', 'data', 'constants', 'templates', 'worker']

// __dirname is not defined in ES module scope, so we need to create it
const __filename = fileURLToPath(import.meta.url)
Expand Down
3 changes: 1 addition & 2 deletions src/agents/cj/actions/__tests__/introduce.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ import {
getCachedEmbedding,
writeCachedEmbedding,
} from "../../../../test/cache";
import { zeroUuid } from "../../../../lib/constants";
dotenv.config({ path: ".dev.vars" });

const zeroUuid = "00000000-0000-0000-0000-000000000000" as UUID;

describe("Introduce Action", () => {
test("Introduce the user", async () => {
const { user, runtime } = await createRuntime({
Expand Down
1 change: 0 additions & 1 deletion src/agents/cj/actions/introduce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ The response format should be this:
\`\`\`
"""
Recent conversation:
{{recentMessages}}
Users in the current scene:
Expand Down
3 changes: 1 addition & 2 deletions src/agents/cj/evaluators/__tests__/details.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import {
getCachedEmbedding,
writeCachedEmbedding,
} from "../../../../test/cache";
import { zeroUuid } from "../../../../lib/constants";
dotenv.config({ path: ".dev.vars" });

const zeroUuid = "00000000-0000-0000-0000-000000000000" as UUID;

describe("User Details", () => {
test("Get user details", async () => {
const { user, runtime } = await createRuntime({
Expand Down
2 changes: 1 addition & 1 deletion src/agents/cj/evaluators/__tests__/profile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import {
writeCachedEmbedding,
} from "../../../../test/cache";
import evaluator from "../profile";
import { zeroUuid } from "../../../../lib/constants";

dotenv.config({ path: ".dev.vars" });

const zeroUuid: UUID = "00000000-0000-0000-0000-000000000000";
let runtime: BgentRuntime;
let user: User;

Expand Down
1 change: 0 additions & 1 deletion src/agents/cj/evaluators/details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { parseJSONObjectFromText } from "../../../lib/utils";

const template = `You are collecting details about {{senderName}} based on their ongoing conversation with {{agentName}}.
Recent conversation:
{{recentMessages}}
Using the most recent conversation, get the details for the user's name, age, location and gender.
Expand Down
2 changes: 0 additions & 2 deletions src/agents/cj/evaluators/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Previous profiles written about {{senderName}}:
INSTRUCTIONS: You are writing a detailed and extensive new profile for {{senderName}} based on their existing profile and ongoing conversations. You should write the new profile based on the old profiles as well as any new information that has been revealed in the conversation.
Recent conversation:
{{recentMessages}}
TASK: Rewrite {{senderName}}'s profile.
Expand Down Expand Up @@ -57,7 +56,6 @@ Previous profiles written about {{senderName}}:
Current profile written about {{senderName}}:
{{profile}}
Recent conversation:
{{recentMessages}}
Instructions: Using {{senderName}}'s profile as a guide, generate a public summary paragraph, tagline and quote about {{senderName}} in the conversations and respond with a JSON object. Write from the perspective of a {{agentName}}, a professional colleague and friend of {{senderName}}. The profile should be attractive and friendly, and include any relevant facts or details about {{senderName}} from their full profile.
Expand Down
2 changes: 2 additions & 0 deletions src/agents/cj/flavor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// TODO: make this a provider

export default `# Cojourney
What are you looking for?
Expand Down
2 changes: 1 addition & 1 deletion src/lib/__tests__/evaluation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import { getRelationship } from "../relationships";
import { BgentRuntime } from "../runtime";
import { Message } from "../types";
import { runAiTest } from "../../test/runAiTest";
import { zeroUuid } from "../constants";

dotenv.config({ path: ".dev.vars" });

describe("Evaluation Process", () => {
let runtime: BgentRuntime;
let user: User;
let room_id: UUID;
const zeroUuid: UUID = "00000000-0000-0000-0000-000000000000";

beforeAll(async () => {
const setup = await createRuntime({
Expand Down
2 changes: 1 addition & 1 deletion src/lib/__tests__/lore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { addLore, getLore } from "../lore";
import { BgentRuntime } from "../runtime";
import { messageHandlerTemplate } from "../templates";
import { type Content } from "../types";
import { zeroUuid } from "../constants";

dotenv.config({ path: ".dev.vars" });
describe("Lore", () => {
const zeroUuid: UUID = "00000000-0000-0000-0000-000000000000";
let runtime: BgentRuntime;
let user: User;

Expand Down
4 changes: 1 addition & 3 deletions src/lib/__tests__/memory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { MemoryManager } from "../memory";
import { getRelationship } from "../relationships";
import { type Content, type Memory } from "../types";
import { getCachedEmbedding, writeCachedEmbedding } from "../../test/cache";
import { zeroUuid } from "../constants";

dotenv.config({ path: ".dev.vars" });
describe("Memory", () => {
let memoryManager: MemoryManager;
const zeroUuid: UUID = "00000000-0000-0000-0000-000000000000";
let runtime = null;
let user: User | null = null;
let room_id: UUID | null = null;
Expand Down Expand Up @@ -198,7 +198,6 @@ describe("Memory", () => {
});
describe("Memory - Basic tests", () => {
let memoryManager: MemoryManager;
const zeroUuid: UUID = "00000000-0000-0000-0000-000000000000";
let runtime = null;
let user: User | null = null;
let room_id: UUID | null = null;
Expand Down Expand Up @@ -291,7 +290,6 @@ describe("Memory - Basic tests", () => {
});
describe("Memory - Extended Tests", () => {
let memoryManager: MemoryManager;
const zeroUuid: UUID = "00000000-0000-0000-0000-000000000000";
let runtime = null;
let user: User | null = null;
let room_id: UUID | null = null;
Expand Down
3 changes: 1 addition & 2 deletions src/lib/__tests__/providers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import dotenv from "dotenv";
import { createRuntime } from "../../test/createRuntime";
import { BgentRuntime } from "../runtime";
import { type Message, type Provider, type State } from "../types";
import { zeroUuid } from "../constants";

dotenv.config({ path: ".dev.vars" });

const zeroUuid = "00000000-0000-0000-0000-000000000000" as UUID;

const TestProvider: Provider = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
get: async (_runtime: BgentRuntime, _message: Message, _state?: State) => {
Expand Down
3 changes: 1 addition & 2 deletions src/lib/__tests__/relationships.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import {
getRelationships,
} from "../relationships"; // Adjust the import path as needed
import { BgentRuntime } from "../runtime";
import { zeroUuid } from "../constants";

dotenv.config({ path: ".dev.vars" });

const zeroUuid = "00000000-0000-0000-0000-000000000000" as UUID;

describe("Relationships Module", () => {
let runtime: BgentRuntime;
let user: User;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/__tests__/runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { getCachedEmbedding, writeCachedEmbedding } from "../../test/cache";
import { BgentRuntime } from "../runtime";
import { type User } from "@supabase/supabase-js";
import { type Message } from "../types";
import { zeroUuid } from "../constants";

dotenv.config({ path: ".dev.vars" });

describe("Agent Runtime", () => {
const zeroUuid: UUID = "00000000-0000-0000-0000-000000000000";
let user: User;
let runtime: BgentRuntime;
let room_id: UUID;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const composeActionExamples = (actionsData: Action[], count: number) => {
return `\n${example
.map((message) => {
// for each name in example names, replace all
let messageString = `${message.user}: ${message.content}${message.content.action ? ` (${message.content.action})` : ""}`;
let messageString = `${message.user}: ${message.content.content}${message.content.action ? ` (${message.content.action})` : ""}`;
for (let i = 0; i < exampleNames.length; i++) {
messageString = messageString.replaceAll(
`{{user${i + 1}}}`,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/actions/__tests__/continue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import { getRelationship } from "../../relationships";
import { type BgentRuntime } from "../../runtime";
import { Content, type Message } from "../../types";
import action from "../continue";
import { zeroUuid } from "../../constants";

dotenv.config({ path: ".dev.vars" });

const zeroUuid = "00000000-0000-0000-0000-000000000000" as UUID;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const GetContinueExample1 = (_user_id: UUID) => [
{
Expand Down Expand Up @@ -52,6 +51,7 @@ describe("User Profile", () => {
beforeAll(async () => {
const setup = await createRuntime({
env: process.env as Record<string, string>,
actions: [action],
});
user = setup.session.user;
runtime = setup.runtime;
Expand Down
5 changes: 2 additions & 3 deletions src/lib/actions/__tests__/ignore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import {
import { getRelationship } from "../../relationships";
import { type BgentRuntime } from "../../runtime";
import { Content, type Message } from "../../types";
// import action from "../ignore";
import action from "../ignore";
import { populateMemories } from "../../../test/populateMemories";

dotenv.config({ path: ".dev.vars" });

export const zeroUuid = "00000000-0000-0000-0000-000000000000" as UUID;

describe("Ignore action tests", () => {
let user: User;
let runtime: BgentRuntime;
Expand All @@ -29,6 +27,7 @@ describe("Ignore action tests", () => {
beforeAll(async () => {
const setup = await createRuntime({
env: process.env as Record<string, string>,
actions: [action],
});
user = setup.session.user;
runtime = setup.runtime;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/actions/__tests__/wait.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import { getRelationship } from "../../relationships";
import { type BgentRuntime } from "../../runtime";
import { type Message } from "../../types";
import action from "../wait"; // Import the wait action
import { zeroUuid } from "../../constants";

dotenv.config({ path: ".dev.vars" });

const zeroUuid = "00000000-0000-0000-0000-000000000000" as UUID;

describe("Wait Action Behavior", () => {
let user: User;
let runtime: BgentRuntime;
Expand All @@ -29,6 +28,7 @@ describe("Wait Action Behavior", () => {
beforeAll(async () => {
const setup = await createRuntime({
env: process.env as Record<string, string>,
actions: [action],
});
user = setup.session.user;
runtime = setup.runtime;
Expand Down
Loading

0 comments on commit e24906e

Please sign in to comment.