Skip to content

Commit

Permalink
fix some actions and messages tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Feb 14, 2024
1 parent 4d069c1 commit 95f44e3
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/lib/__tests__/messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Messages Library", () => {
expect(result.length).toBeGreaterThan(0);
result.forEach((actor) => {
expect(actor).toHaveProperty("name");
expect(actor).toHaveProperty("description");
expect(actor).toHaveProperty("details");
expect(actor).toHaveProperty("id");
});
});
Expand All @@ -41,9 +41,9 @@ describe("Messages Library", () => {
const formattedActors = formatMessageActors({ actors });
actors.forEach((actor) => {
expect(formattedActors).toContain(actor.name);
expect(formattedActors).toContain(actor.details);
});
});


test("getRandomMessageExamples should return a specified number of random message examples", () => {
const examples = getRandomMessageExamples(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createRuntime } from "../../../test/createRuntime";
import { GetTellMeAboutYourselfConversation1 } from "../../../test/data";
import { getRelationship } from "../../relationships";
import { type BgentRuntime } from "../../runtime";
import { type Message } from "../../types";
import { Content, type Message } from "../../types";
import action from "../continue";

dotenv.config();
Expand Down Expand Up @@ -92,7 +92,8 @@ describe("User Profile", () => {

await populateMemories([GetTellMeAboutYourselfConversation1]);

const result = (await handler(runtime, message)) as string[];
expect(result.length).toBeGreaterThan(1);
const result = (await handler(runtime, message)) as Content;

expect(result.content.length).toBeGreaterThan(1);
}, 60000);
});
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ describe("User Profile", () => {
const handler = action.handler!;

const result = (await handler(runtime, message)) as string[];
return result;
expect(result).toBe(true);
}, 60000);
});
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ describe("Wait Action Behavior", () => {
// Expectation depends on the implementation of the wait action.
// For instance, it might be that there's no immediate output,
// or the output indicates waiting, so adjust the expectation accordingly.
expect(result).toEqual(expect.anything()); // Update this line based on the expected behavior of the wait action
expect(result).toEqual(true); // Update this line based on the expected behavior of the wait action
}, 60000);
});
5 changes: 3 additions & 2 deletions src/lib/actions/continue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export default {
validate: async (_runtime: BgentRuntime, _message: Message) => {
return true;
},
handler: async (_runtime: BgentRuntime, message: Message) => {
console.log("continue", message);
handler: async (runtime: BgentRuntime, message: Message) => {
const data = await runtime.handleRequest(message);
return data;
},
condition:
"The agent wants to continue speaking and say something else as a continuation of the last thought",
Expand Down
6 changes: 4 additions & 2 deletions src/lib/actions/ignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ export default {
description:
"Ignore the user and do not respond, use this if your role involves being sassy, or mad at user",
handler: async (
_runtime: BgentRuntime,
runtime: BgentRuntime,
message: Message,
): Promise<boolean> => {
console.log("Ignored:", message);
if (runtime.debugMode) {
console.log("Ignored message: ", message.content);
}
return true;
},
condition: "The agent wants to ignore the user",
Expand Down
5 changes: 4 additions & 1 deletion src/lib/actions/wait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ export default {
description:
"Do nothing and wait for another person to reply to the last message, or to continue their thought",
handler: async (
_runtime: BgentRuntime,
runtime: BgentRuntime,
_message: Message,
): Promise<boolean> => {
if (runtime.debugMode) {
console.log("Waited.");
}
return true;
},
condition: "The agent wants to wait for the user to respond",
Expand Down

0 comments on commit 95f44e3

Please sign in to comment.