diff --git a/tests/agentFilters/test_filter_params.ts b/tests/agentFilters/test_filter_params.ts index eceb5d312..01a93c4e3 100644 --- a/tests/agentFilters/test_filter_params.ts +++ b/tests/agentFilters/test_filter_params.ts @@ -7,7 +7,6 @@ import test from "node:test"; import assert from "node:assert"; const httpAgentFilter: AgentFilterFunction = async (context, next) => { - console.log(context.filterParams); return next(context); }; @@ -36,7 +35,7 @@ test("test filterParams on agent filter", async () => { agent: httpAgentFilter, filterParams: { agentServer: { - baseUrl: "http://localhost:8085/agents/", + baseUrl: "http://localhost:8085/agentFilters/", stream: true, }, }, @@ -47,11 +46,48 @@ test("test filterParams on agent filter", async () => { const graph = new GraphAI({ ...graph_data }, { ...defaultTestAgents, ...callbackDictonary }, { agentFilters }); const result = await graph.run(); - console.log(JSON.stringify(result)); - assert.deepStrictEqual(result, { bypassAgent: [{ agentServer: { baseUrl: "http://localhost:8085/agents/", stream: true } }] }); + // console.log(JSON.stringify(result)); + assert.deepStrictEqual(result, { bypassAgent: [{ agentServer: { baseUrl: "http://localhost:8085/agentFilters/", stream: true } }] }); +}); + +test("test filterParams on node", async () => { + const graph_data = { + version: 0.3, + nodes: { + echo: { + agent: "echoAgent", + params: { + filterParams: true, + }, + filterParams: { + agentServer: { + baseUrl: "http://localhost:8081/nodeParameter/", + }, + }, + }, + bypassAgent: { + agent: "bypassAgent", + inputs: [":echo"], + isResult: true, + }, + }, + }; + const agentFilters = [ + { + name: "httpAgentFilter", + agent: httpAgentFilter, + agentIds: ["echoAgent"], + }, + ]; + + const graph = new GraphAI({ ...graph_data }, { ...defaultTestAgents, ...callbackDictonary }, { agentFilters }); + + const result = await graph.run(); + // console.log(JSON.stringify(result)); + assert.deepStrictEqual(result, { bypassAgent: [{ agentServer: { baseUrl: "http://localhost:8081/nodeParameter/" } }] }); }); -test("test filterParams on agent filter2", async () => { +test("test filterParams on agent filter and node. Then node.ts use filterParams on node", async () => { const graph_data = { version: 0.3, nodes: { @@ -62,7 +98,7 @@ test("test filterParams on agent filter2", async () => { }, filterParams: { agentServer: { - baseUrl: "http://localhost:8081/agents/", + baseUrl: "http://localhost:8081/nodeParameter/", }, }, }, @@ -79,7 +115,7 @@ test("test filterParams on agent filter2", async () => { agent: httpAgentFilter, filterParams: { agentServer: { - baseUrl: "http://localhost:8085/agents/", + baseUrl: "http://localhost:8085/agentFilters/", stream: true, }, }, @@ -91,5 +127,55 @@ test("test filterParams on agent filter2", async () => { const result = await graph.run(); console.log(JSON.stringify(result)); - assert.deepStrictEqual(result, { bypassAgent: [{ agentServer: { baseUrl: "http://localhost:8081/agents/", stream: true } }] }); + assert.deepStrictEqual(result, { bypassAgent: [{ agentServer: { baseUrl: "http://localhost:8081/nodeParameter/" } }] }); +}); + +test("test filterParams on each agent", async () => { + const graph_data = { + version: 0.3, + nodes: { + echo: { + agent: "echoAgent", + params: { + filterParams: true, + }, + filterParams: { + agentServer: { + baseUrl: "http://localhost:8081/nodeParameter/", + }, + }, + }, + echo2: { + agent: "echoAgent", + params: { + filterParams: true, + }, + filterParams: { + agentServer: { + baseUrl: "http://localhost:8081/nodeParameter2/", + }, + }, + }, + bypassAgent: { + agent: "bypassAgent", + inputs: [":echo", ":echo2"], + isResult: true, + }, + }, + }; + const agentFilters = [ + { + name: "httpAgentFilter", + agent: httpAgentFilter, + agentIds: ["echoAgent"], + }, + ]; + + const graph = new GraphAI({ ...graph_data }, { ...defaultTestAgents, ...callbackDictonary }, { agentFilters }); + + const result = await graph.run(); + // console.log(JSON.stringify(result)); + assert.deepStrictEqual(result, { + bypassAgent: [{ agentServer: { baseUrl: "http://localhost:8081/nodeParameter/" } }, { agentServer: { baseUrl: "http://localhost:8081/nodeParameter2/" } }], + }); });