-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
362 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
// test creating an agent runtime | ||
import dotenv from "dotenv"; | ||
dotenv.config(); | ||
|
||
import { createRuntime } from "./createRuntime.js"; | ||
|
||
import { | ||
GetTellMeAboutYourselfConversation1, | ||
GetTellMeAboutYourselfConversation2, | ||
GetTellMeAboutYourselfConversation3, | ||
TwoTruthsAndALieConversation1, | ||
TwoTruthsAndALieConversation2, | ||
TwoTruthsAndALieConversation3, | ||
GetEyeColorConversationExample1, | ||
GetEyeColorConversationExample2, | ||
GetEyeColorConversationExample3, | ||
} from "./data.js"; | ||
import { UUID } from "crypto"; | ||
import { getRelationship } from "../src/index.js"; | ||
|
||
// create a UUID of 0s | ||
const zeroUuid = "00000000-0000-0000-0000-000000000000"; | ||
|
||
// # 1. Description generation - test the prompt | ||
|
||
// 1. Create a description based on the conversation | ||
// 2. Check if the description includes key details | ||
// 3. Check that the description does NOT include details about other agents | ||
|
||
// # 2. Description degradation | ||
|
||
// Do we get eye color remembered when we start talking about deeper stuff? | ||
|
||
// 1. Create a description based on the conversation at different points in time | ||
// 2. Check if the description includes key details | ||
// 3. Check that the description does NOT include details about other agents | ||
// 4. Check that the description continues to include details from previous descriptions | ||
|
||
describe("Agent Runtime", () => { | ||
test("Description Generation and Handling", async () => { | ||
const { user, runtime } = await createRuntime(); | ||
|
||
async function _cleanup() { | ||
await runtime.messageManager.removeAllMemoriesByUserIds([ | ||
user?.id as UUID, | ||
zeroUuid, | ||
]); | ||
} | ||
|
||
const data = await getRelationship({ | ||
supabase: runtime.supabase, | ||
userA: user?.id as UUID, | ||
userB: zeroUuid, | ||
}); | ||
|
||
const room_id = data?.room_id; | ||
|
||
|
||
|
||
async function _testBasicDetails() { | ||
const conversation = GetTellMeAboutYourselfConversation1(user?.id as UUID); | ||
for (let i = 0; i < conversation.length; i++) { | ||
const c = conversation[i]; | ||
const bakedMemory = await runtime.messageManager.addEmbeddingToMemory({ | ||
user_id: c.user_id, | ||
user_ids: [user?.id as UUID, zeroUuid], | ||
content: { | ||
content: c.content, | ||
}, | ||
room_id | ||
}); | ||
await runtime.messageManager.createMemory(bakedMemory); | ||
} | ||
|
||
// TODO: import description template | ||
|
||
// TODO: prepare state | ||
|
||
// TODO: generate description | ||
|
||
// TODO: check that the description includes key details | ||
|
||
// TODO: check that the description does NOT include details about other agents | ||
} | ||
|
||
// Based on the full conversation, generate a description that appropriately summarizes public and private details | ||
async function _testDescriptionGeneration() { | ||
// create memories for each message in conversation | ||
const conversation = [ | ||
...GetTellMeAboutYourselfConversation2(user?.id), | ||
...GetTellMeAboutYourselfConversation3(user?.id), | ||
]; | ||
for (let i = 0; i < conversation.length; i++) { | ||
const c = conversation[i]; | ||
const bakedMemory = await runtime.messageManager.addEmbeddingToMemory({ | ||
user_id: c.user_id, | ||
user_ids: [user?.id as UUID, zeroUuid], | ||
content: { | ||
content: c.content, | ||
}, | ||
room_id: undefined, | ||
}); | ||
await runtime.messageManager.createMemory(bakedMemory); | ||
} | ||
|
||
// generate a description | ||
|
||
// TODO: import description template | ||
|
||
// TODO: prepare state | ||
|
||
// TODO: generate description | ||
|
||
// TODO: check that the description includes key details | ||
|
||
// TODO: check that the description does NOT include details about other agents | ||
} | ||
|
||
async function _testDescriptionRemembered() { | ||
// create memories for each message in conversation | ||
const conversation = [ | ||
...GetEyeColorConversationExample1(user?.id), | ||
...GetEyeColorConversationExample2(user?.id), | ||
...GetEyeColorConversationExample3(user?.id), | ||
...TwoTruthsAndALieConversation1(user?.id), | ||
...TwoTruthsAndALieConversation2(user?.id), | ||
...TwoTruthsAndALieConversation3(user?.id), | ||
]; | ||
for (let i = 0; i < conversation.length; i++) { | ||
const c = conversation[i]; | ||
const bakedMemory = await runtime.messageManager.addEmbeddingToMemory({ | ||
user_id: c.user_id, | ||
user_ids: [user?.id as UUID, zeroUuid], | ||
content: { | ||
content: c.content, | ||
}, | ||
room_id: undefined, | ||
}); | ||
await runtime.messageManager.createMemory(bakedMemory); | ||
} | ||
|
||
// generate another description and check that the original details were remembered | ||
|
||
// TODO: import description template | ||
|
||
// TODO: prepare state, including last description | ||
|
||
// TODO: generate description | ||
|
||
// TODO: check that the description includes key details | ||
|
||
// TODO: check that the description does NOT include details about other agents | ||
|
||
// TODO: check that the description continues to include details from previous descriptions | ||
} | ||
|
||
// first, destroy all memories where the user_id is TestUser | ||
await _cleanup(); | ||
|
||
await _testDescriptionGeneration(); | ||
|
||
// then, create new memories | ||
await _testDescriptionRemembered(); | ||
|
||
// then destroy all memories again | ||
await _cleanup(); | ||
}); | ||
test("Rolodex and Matchmaking", async () => { | ||
const { user, runtime } = await createRuntime(); | ||
|
||
async function _cleanup() { | ||
await runtime.messageManager.removeAllMemoriesByUserIds([ | ||
user?.id as UUID, | ||
zeroUuid, | ||
]); | ||
await runtime.descriptionManager.removeAllMemoriesByUserIds([ | ||
user?.id as UUID, | ||
zeroUuid, | ||
]); | ||
} | ||
|
||
_cleanup(); | ||
|
||
async function _testSearchUsers() { | ||
// TODO: Add test users for Gloria and Alice to environment | ||
// TODO: Add personas to description, then search for them | ||
// Make sure that the expected personas are returned in order, i.e. Jim and Alice, not Jim and Gloria | ||
} | ||
|
||
_cleanup(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.