41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { compileProcessGraph } from '../ai-processes.compiler';
|
|
import { demoRegisterNewPetProcess } from '../demo-process';
|
|
import { runCompiledGraph } from '../ai-processes.runner';
|
|
import { ToolRegistry } from '../tools/tool-registry';
|
|
|
|
describe('ai-processes runner', () => {
|
|
it('runs the demo process until human input is required', async () => {
|
|
const compiled = compileProcessGraph(demoRegisterNewPetProcess, {
|
|
tenantId: 'default',
|
|
version: 1,
|
|
});
|
|
|
|
const result = await runCompiledGraph({
|
|
compiledGraph: compiled,
|
|
input: {
|
|
accountName: 'Acme Inc',
|
|
firstName: 'Jamie',
|
|
lastName: 'Doe',
|
|
},
|
|
toolRegistry: new ToolRegistry(),
|
|
toolContext: { tenantId: 'default', userId: 'user-1' },
|
|
llmDecision: async (node, state) => {
|
|
if (node.id === 'decide_account') {
|
|
return { accountAction: 'find', accountName: state.accountName };
|
|
}
|
|
if (node.id === 'decide_contact') {
|
|
return {
|
|
contactAction: 'find',
|
|
firstName: state.firstName,
|
|
lastName: state.lastName,
|
|
};
|
|
}
|
|
return {};
|
|
},
|
|
});
|
|
|
|
expect(result.status).toBe('waiting');
|
|
expect(result.currentNodeId).toBe('need_pet');
|
|
});
|
|
});
|