From 6470127e25d9fb0782ba60f0a9c7bac1e4d7e487 Mon Sep 17 00:00:00 2001 From: Flavien David Date: Thu, 6 Mar 2025 17:25:16 +0100 Subject: [PATCH] Add search label tool for include/process --- front/lib/api/assistant/actions/process.ts | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/front/lib/api/assistant/actions/process.ts b/front/lib/api/assistant/actions/process.ts index 59666bad684b..06c714882c14 100644 --- a/front/lib/api/assistant/actions/process.ts +++ b/front/lib/api/assistant/actions/process.ts @@ -1,4 +1,5 @@ import type { + ActionConfigurationType, AgentActionSpecification, FunctionCallType, FunctionMessageTypeModel, @@ -23,7 +24,10 @@ import { import _ from "lodash"; import { runActionStreamed } from "@app/lib/actions/server"; -import { DEFAULT_PROCESS_ACTION_NAME } from "@app/lib/api/assistant/actions/constants"; +import { + DEFAULT_PROCESS_ACTION_NAME, + DEFAULT_SEARCH_LABELS_ACTION_NAME, +} from "@app/lib/api/assistant/actions/constants"; import { applyDataSourceFilters, parseTimeFrame, @@ -39,6 +43,7 @@ import type { Authenticator } from "@app/lib/auth"; import { AgentProcessAction } from "@app/lib/models/assistant/actions/process"; import { cloneBaseConfig, getDustProdAction } from "@app/lib/registry"; import { DataSourceViewResource } from "@app/lib/resources/data_source_view_resource"; +import { generateRandomModelSId } from "@app/lib/resources/string_ids"; import logger from "@app/logger/logger"; interface ProcessActionBlob { @@ -144,6 +149,30 @@ export class ProcessConfigurationServerRunner extends BaseActionConfigurationSer return new Ok(spec); } + getSupportingActions(): ActionConfigurationType[] { + const hasAutoTags = this.actionConfiguration.dataSources.some( + (ds) => ds.filter.tags?.mode === "auto" + ); + + if (hasAutoTags) { + return [ + { + id: -1, + sId: generateRandomModelSId(), + type: "search_labels_configuration", + // Tool name must be unique. We use the parent tool name to make it unique. + name: `${DEFAULT_SEARCH_LABELS_ACTION_NAME}_${this.actionConfiguration.name}`, + dataSourceViewIds: this.actionConfiguration.dataSources.map( + (ds) => ds.dataSourceViewId + ), + parentTool: this.actionConfiguration.name, + }, + ]; + } + + return []; + } + // This method is in charge of running the retrieval and creating an AgentProcessAction object in // the database. It does not create any generic model related to the conversation. It is possible // for an AgentProcessAction to be stored (once the query params are infered) but for its execution