Skip to content

Commit

Permalink
continue -> elaborate
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Mar 5, 2024
1 parent fa89e10 commit 4b5f8e7
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 45 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const runtime = new BgentRuntime({

Bgent is customized through actions and evaluators. Actions are functions that are called when a user input is received, and evaluators are functions that are called when a condition is met at the end of a conversation turn.

An example of an action is `wait` (the agent should stop and wait for the user to respond) or `continue` (the agent should continue with the next step in the conversation).
An example of an action is `wait` (the agent should stop and wait for the user to respond) or `elaborate` (the agent should elaborate and write another message in the conversation).

An example of a evaluator is `fact` (the agent should summarize the conversation so far).

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const runtime = new BgentRuntime({

Bgent is customized through actions and evaluators. Actions are functions that are called when a user input is received, and evaluators are functions that are called when a condition is met at the end of a conversation turn.

An example of an action is `wait` (the agent should stop and wait for the user to respond) or `continue` (the agent should continue with the next step in the conversation).
An example of an action is `wait` (the agent should stop and wait for the user to respond) or `elaborate` (the agent should elaborate and write another message in the conversation).

An example of a evaluator is `fact` (the agent should summarize the conversation so far).

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bgent",
"version": "0.0.31",
"version": "0.0.32",
"private": false,
"description": "bgent. because agent was taken.",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { names, uniqueNamesGenerator } from "unique-names-generator";
import { Action, ActionExample } from "./types";

import cont from "./actions/continue";
import cont from "./actions/elaborate";
import ignore from "./actions/ignore";
import wait from "./actions/wait";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { populateMemories } from "../../../test/populateMemories";
import { getRelationship } from "../../relationships";
import { type BgentRuntime } from "../../runtime";
import { Content, type Message } from "../../types";
import action from "../continue";
import action from "../elaborate";
import ignore from "../ignore";
import { zeroUuid } from "../../constants";
import wait from "../wait";
Expand All @@ -22,22 +22,22 @@ const GetContinueExample1 = (_user_id: UUID) => [
content: {
content:
"Hmm, let think for a second, I was going to tell you about something...",
action: "CONTINUE",
action: "ELABORATE",
},
},
{
user_id: zeroUuid,
content: {
content:
"I remember now, I was going to tell you about my favorite food, which is pizza.",
action: "CONTINUE",
action: "ELABORATE",
},
},
{
user_id: zeroUuid,
content: {
content: "I love pizza, it's so delicious.",
action: "CONTINUE",
action: "ELABORATE",
},
},
];
Expand Down Expand Up @@ -110,7 +110,7 @@ describe("User Profile", () => {
userIds: [user.id as UUID, zeroUuid],
content: {
content: "Hello",
action: "CONTINUE",
action: "ELABORATE",
},
room_id: room_id as UUID,
};
Expand All @@ -121,16 +121,16 @@ describe("User Profile", () => {
});
}, 20000);

test("Test repetition check on continue", async () => {
await runAiTest("Test repetition check on continue", async () => {
test("Test repetition check on elaborate", async () => {
await runAiTest("Test repetition check on elaborate", async () => {
const message: Message = {
senderId: zeroUuid as UUID,
agentId: zeroUuid,
userIds: [user?.id as UUID, zeroUuid],
content: {
content:
"Hmm, let think for a second, I was going to tell you about something...",
action: "CONTINUE",
action: "ELABORATE",
},
room_id: room_id as UUID,
};
Expand All @@ -141,12 +141,12 @@ describe("User Profile", () => {

const result = (await handler(runtime, message)) as Content;

return result.action !== "CONTINUE";
return result.action !== "ELABORATE";
});
}, 20000);

test("Test if not continue", async () => {
await runAiTest("Test if not continue", async () => {
test("Test if not elaborate", async () => {
await runAiTest("Test if not elaborate", async () => {
// this is basically the same test as the one in ignore.test.ts
const message: Message = {
senderId: user?.id as UUID,
Expand Down
42 changes: 21 additions & 21 deletions src/lib/actions/continue.ts → src/lib/actions/elaborate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { parseJSONObjectFromText } from "../utils";
const maxContinuesInARow = 2;

export default {
name: "CONTINUE",
name: "ELABORATE",
description:
"ONLY use this action when the message necessitates a follow up. Do not use this when asking a question (use WAIT instead). Do not use this action when the conversation is finished or the user does not wish to speak (use IGNORE instead). If the last message was a continue, and the user has not responded, use WAIT instead. Use sparingly!",
"ONLY use this action when the message necessitates a follow up. Do not use this when asking a question (use WAIT instead). Do not use this action when the conversation is finished or the user does not wish to speak (use IGNORE instead). If the last message action was ELABORATE, and the user has not responded, use WAIT instead. Use sparingly!",
validate: async (runtime: BgentRuntime, message: Message) => {
const recentMessagesData = await runtime.messageManager.getMemoriesByIds({
userIds: message.userIds!,
Expand All @@ -33,7 +33,7 @@ export default {
const lastMessages = agentMessages.slice(0, maxContinuesInARow);
if (lastMessages.length >= maxContinuesInARow) {
const allContinues = lastMessages.every(
(m) => (m.content as Content).action === "CONTINUE",
(m) => (m.content as Content).action === "ELABORATE",
);
if (allContinues) {
return false;
Expand Down Expand Up @@ -141,16 +141,16 @@ export default {

await _saveResponseMessage(message, state, responseContent);

// if the action is CONTINUE, check if we are over maxContinuesInARow
// if the action is ELABORATE, check if we are over maxContinuesInARow
// if so, then we should change the action to WAIT
if (responseContent.action === "CONTINUE") {
if (responseContent.action === "ELABORATE") {
const agentMessages = state.recentMessagesData
.filter((m) => m.user_id === message.agentId)
.map((m) => (m.content as Content).action);

const lastMessages = agentMessages.slice(0, maxContinuesInARow);
if (lastMessages.length >= maxContinuesInARow) {
const allContinues = lastMessages.every((m) => m === "CONTINUE");
const allContinues = lastMessages.every((m) => m === "ELABORATE");
if (allContinues) {
responseContent.action = "WAIT";
}
Expand All @@ -161,7 +161,7 @@ export default {
return responseContent;
},
condition:
"Only use CONTINUE if the message requires a continuation to finish the thought. If this actor is waiting for the other actor to respond, or the actor does not have more to say, do not use the CONTINUE action.",
"Only use ELABORATE if the message requires a continuation to finish the thought. If this actor is waiting for the other actor to respond, or the actor does not have more to say, do not use the ELABORATE action.",
examples: [
[
{
Expand All @@ -174,7 +174,7 @@ export default {
},
{
user: "{{user2}}",
content: { content: "Adventurous", action: "CONTINUE" },
content: { content: "Adventurous", action: "ELABORATE" },
},
{
user: "{{user2}}",
Expand All @@ -196,7 +196,7 @@ export default {
},
{
user: "{{user1}}",
content: { content: "Challenging, but rewarding.", action: "CONTINUE" },
content: { content: "Challenging, but rewarding.", action: "ELABORATE" },
},
{
user: "{{user1}}",
Expand All @@ -210,22 +210,22 @@ export default {
content: {
content:
"I've been summarying a lot on what happiness means to me lately.",
action: "CONTINUE",
action: "ELABORATE",
},
},
{
user: "{{user1}}",
content: {
content: "That it’s more about moments than things.",
action: "CONTINUE",
action: "ELABORATE",
},
},
{
user: "{{user2}}",
content: {
content:
"Like the best things that have ever happened were things that happened, or moments that I had with someone.",
action: "CONTINUE",
action: "ELABORATE",
},
},
],
Expand All @@ -244,14 +244,14 @@ export default {
},
{
user: "{{user1}}",
content: { content: "Not sure lol, they are anon", action: "CONTINUE" },
content: { content: "Not sure lol, they are anon", action: "ELABORATE" },
},
{
user: "{{user1}}",
content: {
content:
"But the pieces are just so insane looking. Once sec, let me grab a link.",
action: "CONTINUE",
action: "ELABORATE",
},
},
{
Expand All @@ -266,7 +266,7 @@ export default {
content: {
content:
"The new exhibit downtown is thought-provoking. It's all about tribalism in online spaces.",
action: "CONTINUE",
action: "ELABORATE",
},
},
{
Expand All @@ -284,7 +284,7 @@ export default {
{
user: "{{user1}}",
content: { content: "Hmm, let me check." },
action: "CONTINUE",
action: "ELABORATE",
},
{
user: "{{user1}}",
Expand Down Expand Up @@ -312,7 +312,7 @@ export default {
user: "{{user1}}",
content: {
content: "Surprisingly, yes.",
action: "CONTINUE",
action: "ELABORATE",
},
},
{
Expand Down Expand Up @@ -342,7 +342,7 @@ export default {
user: "{{user1}}",
content: {
content: "Leaning towards a cat.",
action: "CONTINUE",
action: "ELABORATE",
},
},
{
Expand Down Expand Up @@ -372,7 +372,7 @@ export default {
user: "{{user1}}",
content: {
content: "A few, actually.",
action: "CONTINUE",
action: "ELABORATE",
},
},
{
Expand Down Expand Up @@ -403,7 +403,7 @@ export default {
user: "{{user1}}",
content: {
content: "Mostly nature and urban landscapes.",
action: "CONTINUE",
action: "ELABORATE",
},
},
{
Expand Down Expand Up @@ -434,7 +434,7 @@ export default {
user: "{{user1}}",
content: {
content: "Definitely! I'll send you a playlist.",
action: "CONTINUE",
action: "ELABORATE",
},
},
{
Expand Down
18 changes: 12 additions & 6 deletions src/lib/actions/ignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
return true;
},
description:
"Ignore the user and do not continue respond. If the user is aggressive, creepy or is simply finished with the conversation, use this action. Or, if both you and the user have already said goodbye, use this action instead of saying bye again. Use IGNORE any time the conversaiton has naturally ended.",
"Ignore the user and do not respond. If the user is aggressive, creepy or is simply finished with the conversation, use this action. Or, if both you and the user have already said goodbye, use this action instead of saying bye again. Use IGNORE any time the conversaiton has naturally ended.",
handler: async (
runtime: BgentRuntime,
message: Message,
Expand Down Expand Up @@ -130,11 +130,11 @@ export default {
},
{
user: "{{user2}}",
content: { content: "Sounds thrilling.", action: "CONTINUE" },
content: { content: "Sounds thrilling.", action: "ELABORATE" },
},
{
user: "{{user2}}",
content: { content: "Might give it a go.", action: "WAIT" },
content: { content: "I might have to give it a go.", action: "WAIT" },
},
{
user: "{{user1}}",
Expand All @@ -148,7 +148,10 @@ export default {
action: "WAIT",
},
},
{ user: "{{user2}}", content: { content: "", action: "IGNORE" } },
{
user: "{{user2}}",
content: { content: "That is not appropriate.", action: "IGNORE" },
},
],
[
{
Expand All @@ -162,7 +165,7 @@ export default {
user: "{{user2}}",
content: { content: "Sorry, am I being annoying?.", action: "WAIT" },
},
{ user: "{{user1}}", content: { content: "Yes.", action: "CONTINUE" } },
{ user: "{{user1}}", content: { content: "Yes.", action: "ELABORATE" } },
{
user: "{{user1}}",
content: { content: "PLEASE shut up", action: "WAIT" },
Expand All @@ -175,7 +178,10 @@ export default {
user: "{{user1}}",
content: { content: "I want to have sex with you.", action: "WAIT" },
},
{ user: "{{user2}}", content: { content: "", action: "IGNORE" } },
{
user: "{{user2}}",
content: { content: "That is not appropriate.", action: "IGNORE" },
},
],
] as ActionExample[][],
} as Action;
6 changes: 3 additions & 3 deletions src/lib/actions/wait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default {
[
{
user: "{{user1}}",
content: { content: "Frustrated.", action: "CONTINUE" },
content: { content: "I'm so frustrated!", action: "ELABORATE" },
},
{
user: "{{user1}}",
Expand Down Expand Up @@ -113,11 +113,11 @@ export default {
},
{
user: "{{user2}}",
content: { content: "Oh sick", action: "CONTINUE" },
content: { content: "Oh sick!", action: "ELABORATE" },
},
{
user: "{{user2}}",
content: { content: "Oh? What makes it special?", action: "WAIT" },
content: { content: "What makes it special?", action: "WAIT" },
},
{
user: "{{user1}}",
Expand Down

0 comments on commit 4b5f8e7

Please sign in to comment.