-
Notifications
You must be signed in to change notification settings - Fork 15
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
2 changed files
with
85 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,84 @@ | ||
// test evaluation injection | ||
// test evaluator *not* running if no evalauation handlers are true | ||
// test evaluation handling and response | ||
import { type User } from "@supabase/supabase-js"; | ||
import { BgentRuntime } from "../runtime"; | ||
import { type Message } from "../types"; | ||
import { createRuntime } from "../../test/createRuntime"; | ||
import { type UUID } from "crypto"; | ||
|
||
describe('Evaluation Process', () => { | ||
let runtime: BgentRuntime; | ||
let user: User; | ||
const zeroUuid = '00000000-0000-0000-0000-000000000000'; | ||
|
||
beforeAll(async () => { | ||
const setup = await createRuntime(process.env as Record<string, string>); | ||
runtime = setup.runtime; | ||
user = setup.user as User; | ||
|
||
// Assuming the evaluator 'reflect' is already registered in the runtime setup | ||
}); | ||
|
||
test('Evaluation Injection - Evaluator Creates Memory', async () => { | ||
const message: Message = { | ||
senderId: user.id as UUID, | ||
agentId: zeroUuid, | ||
userIds: [user?.id as UUID, zeroUuid], | ||
content: 'Trigger evaluator content', | ||
room_id: zeroUuid | ||
}; | ||
|
||
await runtime.handleRequest(message); | ||
|
||
// Assuming the 'reflect' evaluator tags the memories it creates with 'reflection' | ||
const memories = await runtime.reflectionManager.getMemoriesByIds({ | ||
userIds: [user.id as UUID, zeroUuid], | ||
count: 1 | ||
}); | ||
|
||
// Expect at least one memory to be created with the 'reflection' tag | ||
expect(memories.length).toBeGreaterThan(0); | ||
}); | ||
|
||
test('Evaluator Not Running if No Evaluation Handlers are True', async () => { | ||
const message: Message = { | ||
senderId: user?.id as UUID, | ||
agentId: zeroUuid, | ||
userIds: [user?.id as UUID, zeroUuid], | ||
content: 'Non-triggering content', | ||
room_id: zeroUuid | ||
}; | ||
|
||
await runtime.handleRequest(message); | ||
|
||
// Assuming the 'reflect' evaluator tags the memories it creates with 'reflection' | ||
const memories = await runtime.reflectionManager.getMemoriesByIds({ | ||
userIds: [user.id as UUID, zeroUuid], | ||
count: 10 | ||
}); | ||
|
||
// Assuming the previous test ran and created exactly one memory | ||
// Expect the number of memories to remain unchanged | ||
expect(memories.length).toBe(1); | ||
}); | ||
|
||
test('Evaluation Handling and Response - Evaluator Updates Memory', async () => { | ||
const message: Message = { | ||
senderId: user.id as UUID, | ||
agentId: zeroUuid, | ||
userIds: [user.id as UUID, zeroUuid], | ||
content: 'Content that leads to a specific evaluator response', | ||
room_id: zeroUuid | ||
}; | ||
|
||
await runtime.handleRequest(message); | ||
|
||
// Assuming the 'reflect' evaluator updates the 'content' of memories it processes | ||
// Fetch the updated memory | ||
const memories = await runtime.reflectionManager.getMemoriesByIds({ | ||
userIds: [user.id as UUID, zeroUuid], | ||
count: 1 | ||
}); | ||
|
||
// Expect the updated memory to contain specific content | ||
expect(memories[0].content).toContain('specific content'); | ||
}); | ||
}); |