diff --git a/x-pack/plugins/integration_assistant/docs/imgs/categorization_graph.png b/x-pack/plugins/integration_assistant/docs/imgs/categorization_graph.png index a15dbf54d905a..de45a18546b40 100644 Binary files a/x-pack/plugins/integration_assistant/docs/imgs/categorization_graph.png and b/x-pack/plugins/integration_assistant/docs/imgs/categorization_graph.png differ diff --git a/x-pack/plugins/integration_assistant/docs/imgs/cel_graph.png b/x-pack/plugins/integration_assistant/docs/imgs/cel_graph.png new file mode 100644 index 0000000000000..8b339caa83798 Binary files /dev/null and b/x-pack/plugins/integration_assistant/docs/imgs/cel_graph.png differ diff --git a/x-pack/plugins/integration_assistant/docs/imgs/log_detection_graph.png b/x-pack/plugins/integration_assistant/docs/imgs/log_detection_graph.png index 285e012c57a14..f89ffc800f0a5 100644 Binary files a/x-pack/plugins/integration_assistant/docs/imgs/log_detection_graph.png and b/x-pack/plugins/integration_assistant/docs/imgs/log_detection_graph.png differ diff --git a/x-pack/plugins/integration_assistant/docs/imgs/related_graph.png b/x-pack/plugins/integration_assistant/docs/imgs/related_graph.png index 73a2c3acac0d4..222c864f3115f 100644 Binary files a/x-pack/plugins/integration_assistant/docs/imgs/related_graph.png and b/x-pack/plugins/integration_assistant/docs/imgs/related_graph.png differ diff --git a/x-pack/plugins/integration_assistant/docs/imgs/unstructured_graph.png b/x-pack/plugins/integration_assistant/docs/imgs/unstructured_graph.png new file mode 100644 index 0000000000000..45ab5abc8d6b3 Binary files /dev/null and b/x-pack/plugins/integration_assistant/docs/imgs/unstructured_graph.png differ diff --git a/x-pack/plugins/integration_assistant/scripts/draw_graphs_script.ts b/x-pack/plugins/integration_assistant/scripts/draw_graphs_script.ts index 12a37f71b184a..f9fd71c1f934f 100644 --- a/x-pack/plugins/integration_assistant/scripts/draw_graphs_script.ts +++ b/x-pack/plugins/integration_assistant/scripts/draw_graphs_script.ts @@ -20,6 +20,8 @@ import { getEcsGraph, getEcsSubGraph } from '../server/graphs/ecs/graph'; import { getLogFormatDetectionGraph } from '../server/graphs/log_type_detection/graph'; import { getRelatedGraph } from '../server/graphs/related/graph'; import { getKVGraph } from '../server/graphs/kv/graph'; +import { getUnstructuredGraph } from '../server/graphs/unstructured'; +import { getCelGraph } from '../server/graphs/cel/graph'; // Some mock elements just to get the graph to compile const model = new FakeLLM({ @@ -45,17 +47,20 @@ async function drawGraph(compiledGraph: RunnableGraph, graphName: string) { await saveFile(`${graphName}.png`, buffer); } +const GRAPH_LIST = { + related_graph: getRelatedGraph, + log_detection_graph: getLogFormatDetectionGraph, + categorization_graph: getCategorizationGraph, + kv_graph: getKVGraph, + ecs_graph: getEcsGraph, + ecs_subgraph: getEcsSubGraph, + unstructured_graph: getUnstructuredGraph, + cel_graph: getCelGraph, +}; + export async function drawGraphs() { - const relatedGraph = (await getRelatedGraph({ client, model })).getGraph(); - const logFormatDetectionGraph = (await getLogFormatDetectionGraph({ client, model })).getGraph(); - const categorizationGraph = (await getCategorizationGraph({ client, model })).getGraph(); - const ecsSubGraph = (await getEcsSubGraph({ model })).getGraph(); - const ecsGraph = (await getEcsGraph({ model })).getGraph(); - const kvGraph = (await getKVGraph({ client, model })).getGraph(); - drawGraph(relatedGraph, 'related_graph'); - drawGraph(logFormatDetectionGraph, 'log_detection_graph'); - drawGraph(categorizationGraph, 'categorization_graph'); - drawGraph(ecsSubGraph, 'ecs_subgraph'); - drawGraph(ecsGraph, 'ecs_graph'); - drawGraph(kvGraph, 'kv_graph'); + for (const [name, graph] of Object.entries(GRAPH_LIST)) { + const compiledGraph = (await graph({ client, model })).getGraph(); + drawGraph(compiledGraph, name); + } } diff --git a/x-pack/plugins/integration_assistant/server/graphs/categorization/graph.ts b/x-pack/plugins/integration_assistant/server/graphs/categorization/graph.ts index 2f07bcd106862..cc1601095da62 100644 --- a/x-pack/plugins/integration_assistant/server/graphs/categorization/graph.ts +++ b/x-pack/plugins/integration_assistant/server/graphs/categorization/graph.ts @@ -233,6 +233,6 @@ export async function getCategorizationGraph({ client, model }: CategorizationGr } ); - const compiledCategorizationGraph = workflow.compile().withConfig({ runName: 'Categorization' }); + const compiledCategorizationGraph = workflow.compile(); return compiledCategorizationGraph; } diff --git a/x-pack/plugins/integration_assistant/server/graphs/cel/graph.ts b/x-pack/plugins/integration_assistant/server/graphs/cel/graph.ts index a8f2e0521c788..5d58f82f6f744 100644 --- a/x-pack/plugins/integration_assistant/server/graphs/cel/graph.ts +++ b/x-pack/plugins/integration_assistant/server/graphs/cel/graph.ts @@ -104,6 +104,6 @@ export async function getCelGraph({ model }: CelInputGraphParams) { .addEdge('handleGetStateVariables', 'handleGetStateDetails') .addEdge('handleGetStateDetails', 'modelOutput'); - const compiledCelGraph = workflow.compile().withConfig({ runName: 'CEL' }); + const compiledCelGraph = workflow.compile(); return compiledCelGraph; } diff --git a/x-pack/plugins/integration_assistant/server/graphs/ecs/graph.ts b/x-pack/plugins/integration_assistant/server/graphs/ecs/graph.ts index 89a7e5c600723..dc2f26f9505e4 100644 --- a/x-pack/plugins/integration_assistant/server/graphs/ecs/graph.ts +++ b/x-pack/plugins/integration_assistant/server/graphs/ecs/graph.ts @@ -78,7 +78,7 @@ export async function getEcsSubGraph({ model }: EcsGraphParams) { }) .addEdge('modelSubOutput', END); - const compiledEcsSubGraph = workflow.compile().withConfig({ runName: 'ECS Mapping (Chunk)' }); + const compiledEcsSubGraph = workflow.compile(); return compiledEcsSubGraph; } @@ -96,7 +96,7 @@ export async function getEcsGraph({ model }: EcsGraphParams) { .addNode('handleMergedSubGraphResponse', (state: EcsMappingState) => modelMergedInputFromSubGraph({ state }) ) - .addNode('subGraph', subGraph) + .addNode('subGraph', subGraph.withConfig({ runName: 'ECS Mapping (Chunk)' })) .addEdge(START, 'modelInput') .addEdge('subGraph', 'handleMergedSubGraphResponse') .addEdge('handleDuplicates', 'handleValidation') @@ -119,6 +119,6 @@ export async function getEcsGraph({ model }: EcsGraphParams) { }) .addEdge('modelOutput', END); - const compiledEcsGraph = workflow.compile().withConfig({ runName: 'ECS Mapping' }); + const compiledEcsGraph = workflow.compile(); return compiledEcsGraph; } diff --git a/x-pack/plugins/integration_assistant/server/graphs/kv/graph.ts b/x-pack/plugins/integration_assistant/server/graphs/kv/graph.ts index f72984655c1f8..6f7b43ba40f22 100644 --- a/x-pack/plugins/integration_assistant/server/graphs/kv/graph.ts +++ b/x-pack/plugins/integration_assistant/server/graphs/kv/graph.ts @@ -139,6 +139,6 @@ export async function getKVGraph({ model, client }: KVGraphParams) { }) .addEdge('modelOutput', END); - const compiledKVGraph = workflow.compile().withConfig({ runName: 'Key-Value' }); + const compiledKVGraph = workflow.compile(); return compiledKVGraph; } diff --git a/x-pack/plugins/integration_assistant/server/graphs/log_type_detection/graph.ts b/x-pack/plugins/integration_assistant/server/graphs/log_type_detection/graph.ts index 95d624a7436c7..ae4c607ab3f68 100644 --- a/x-pack/plugins/integration_assistant/server/graphs/log_type_detection/graph.ts +++ b/x-pack/plugins/integration_assistant/server/graphs/log_type_detection/graph.ts @@ -118,8 +118,14 @@ export async function getLogFormatDetectionGraph({ model, client }: LogDetection .addNode('handleLogFormatDetection', (state: LogFormatDetectionState) => handleLogFormatDetection({ state, model, client }) ) - .addNode('handleKVGraph', await getKVGraph({ model, client })) - .addNode('handleUnstructuredGraph', await getUnstructuredGraph({ model, client })) + .addNode( + 'handleKVGraph', + (await getKVGraph({ model, client })).withConfig({ runName: 'Key-Value' }) + ) + .addNode( + 'handleUnstructuredGraph', + (await getUnstructuredGraph({ model, client })).withConfig({ runName: 'Unstructured' }) + ) .addNode('handleCSV', (state: LogFormatDetectionState) => handleCSV({ state, model, client })) .addEdge(START, 'modelInput') .addEdge('modelInput', 'handleLogFormatDetection') @@ -138,6 +144,6 @@ export async function getLogFormatDetectionGraph({ model, client }: LogDetection } ); - const compiledLogFormatDetectionGraph = workflow.compile().withConfig({ runName: 'Log Format' }); + const compiledLogFormatDetectionGraph = workflow.compile(); return compiledLogFormatDetectionGraph; } diff --git a/x-pack/plugins/integration_assistant/server/graphs/related/graph.ts b/x-pack/plugins/integration_assistant/server/graphs/related/graph.ts index e8dc44a152e80..20ac1c639dcf4 100644 --- a/x-pack/plugins/integration_assistant/server/graphs/related/graph.ts +++ b/x-pack/plugins/integration_assistant/server/graphs/related/graph.ts @@ -179,6 +179,6 @@ export async function getRelatedGraph({ client, model }: RelatedGraphParams) { } ); - const compiledRelatedGraph = workflow.compile().withConfig({ runName: 'Related' }); + const compiledRelatedGraph = workflow.compile(); return compiledRelatedGraph; } diff --git a/x-pack/plugins/integration_assistant/server/graphs/unstructured/graph.ts b/x-pack/plugins/integration_assistant/server/graphs/unstructured/graph.ts index cf3a645effa68..6048404728bfb 100644 --- a/x-pack/plugins/integration_assistant/server/graphs/unstructured/graph.ts +++ b/x-pack/plugins/integration_assistant/server/graphs/unstructured/graph.ts @@ -107,6 +107,6 @@ export async function getUnstructuredGraph({ model, client }: UnstructuredGraphP .addEdge('handleUnstructuredError', 'handleUnstructuredValidate') .addEdge('modelOutput', END); - const compiledUnstructuredGraph = workflow.compile().withConfig({ runName: 'Unstructured' }); + const compiledUnstructuredGraph = workflow.compile(); return compiledUnstructuredGraph; } diff --git a/x-pack/plugins/integration_assistant/server/routes/analyze_logs_routes.ts b/x-pack/plugins/integration_assistant/server/routes/analyze_logs_routes.ts index 639cd62f275b1..04ba66acbebfb 100644 --- a/x-pack/plugins/integration_assistant/server/routes/analyze_logs_routes.ts +++ b/x-pack/plugins/integration_assistant/server/routes/analyze_logs_routes.ts @@ -91,7 +91,9 @@ export function registerAnalyzeLogsRoutes( logSamples, }; const graph = await getLogFormatDetectionGraph({ model, client }); - const graphResults = await graph.invoke(logFormatParameters, options); + const graphResults = await graph + .withConfig({ runName: 'Log Format' }) + .invoke(logFormatParameters, options); const graphLogFormat = graphResults.results.samplesFormat.name; if (graphLogFormat === 'unsupported') { throw new UnsupportedLogFormatError(GenerationErrorCode.UNSUPPORTED_LOG_SAMPLES_FORMAT); diff --git a/x-pack/plugins/integration_assistant/server/routes/categorization_routes.test.ts b/x-pack/plugins/integration_assistant/server/routes/categorization_routes.test.ts index abe626cf7ae73..0e6f4ffa0491a 100644 --- a/x-pack/plugins/integration_assistant/server/routes/categorization_routes.test.ts +++ b/x-pack/plugins/integration_assistant/server/routes/categorization_routes.test.ts @@ -23,7 +23,9 @@ const mockResult = jest.fn().mockResolvedValue({ jest.mock('../graphs/categorization', () => { return { getCategorizationGraph: jest.fn().mockResolvedValue({ - invoke: () => mockResult(), + withConfig: () => ({ + invoke: () => mockResult(), + }), }), }; }); diff --git a/x-pack/plugins/integration_assistant/server/routes/categorization_routes.ts b/x-pack/plugins/integration_assistant/server/routes/categorization_routes.ts index 77ce549f589f4..10d72b92563fe 100644 --- a/x-pack/plugins/integration_assistant/server/routes/categorization_routes.ts +++ b/x-pack/plugins/integration_assistant/server/routes/categorization_routes.ts @@ -99,7 +99,9 @@ export function registerCategorizationRoutes( }; const graph = await getCategorizationGraph({ client, model }); - const results = await graph.invoke(parameters, options); + const results = await graph + .withConfig({ runName: 'Categorization' }) + .invoke(parameters, options); return res.ok({ body: CategorizationResponse.parse(results) }); } catch (err) { diff --git a/x-pack/plugins/integration_assistant/server/routes/cel_route.test.ts b/x-pack/plugins/integration_assistant/server/routes/cel_route.test.ts index be435aa9866bb..02b5f03948a12 100644 --- a/x-pack/plugins/integration_assistant/server/routes/cel_route.test.ts +++ b/x-pack/plugins/integration_assistant/server/routes/cel_route.test.ts @@ -22,7 +22,9 @@ const mockResult = jest.fn().mockResolvedValue({ jest.mock('../graphs/cel', () => { return { getCelGraph: jest.fn().mockResolvedValue({ - invoke: () => mockResult(), + withConfig: () => ({ + invoke: () => mockResult(), + }), }), }; }); diff --git a/x-pack/plugins/integration_assistant/server/routes/cel_routes.ts b/x-pack/plugins/integration_assistant/server/routes/cel_routes.ts index ecf012a88cfe5..5f417bbc0aec9 100644 --- a/x-pack/plugins/integration_assistant/server/routes/cel_routes.ts +++ b/x-pack/plugins/integration_assistant/server/routes/cel_routes.ts @@ -78,7 +78,7 @@ export function registerCelInputRoutes(router: IRouter { return { getEcsGraph: jest.fn().mockResolvedValue({ - invoke: () => mockResult(), + withConfig: () => ({ + invoke: () => mockResult(), + }), }), }; }); diff --git a/x-pack/plugins/integration_assistant/server/routes/ecs_routes.ts b/x-pack/plugins/integration_assistant/server/routes/ecs_routes.ts index 43ca0fe396cae..0bc293492b24d 100644 --- a/x-pack/plugins/integration_assistant/server/routes/ecs_routes.ts +++ b/x-pack/plugins/integration_assistant/server/routes/ecs_routes.ts @@ -92,7 +92,9 @@ export function registerEcsRoutes(router: IRouter { return { getRelatedGraph: jest.fn().mockResolvedValue({ - invoke: () => mockResult(), + withConfig: () => ({ + invoke: () => mockResult(), + }), }), }; }); diff --git a/x-pack/plugins/integration_assistant/server/routes/related_routes.ts b/x-pack/plugins/integration_assistant/server/routes/related_routes.ts index fe3a63abd4ce9..8e147e8385dc0 100644 --- a/x-pack/plugins/integration_assistant/server/routes/related_routes.ts +++ b/x-pack/plugins/integration_assistant/server/routes/related_routes.ts @@ -90,7 +90,9 @@ export function registerRelatedRoutes(router: IRouter