From 314db1d37759367e5d777c142381c7a70e80c92e Mon Sep 17 00:00:00 2001 From: Henry Fontanier Date: Fri, 13 Dec 2024 18:43:27 +0100 Subject: [PATCH] fix: AB parsing of include actions with timeframe (#9375) Co-authored-by: Henry Fontanier --- front/components/assistant_builder/actions/TimeDropdown.tsx | 4 ++-- .../assistant_builder/server_side_props_helpers.ts | 6 +++--- front/components/assistant_builder/types.ts | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/front/components/assistant_builder/actions/TimeDropdown.tsx b/front/components/assistant_builder/actions/TimeDropdown.tsx index f4e11f658dae..34f010855274 100644 --- a/front/components/assistant_builder/actions/TimeDropdown.tsx +++ b/front/components/assistant_builder/actions/TimeDropdown.tsx @@ -11,7 +11,7 @@ import { TIME_FRAME_UNIT_TO_LABEL } from "@app/components/assistant_builder/shar import type { AssistantBuilderTimeFrame } from "@app/components/assistant_builder/types"; interface TimeUnitDropdownProps< - T extends { timeFrame?: AssistantBuilderTimeFrame }, + T extends { timeFrame?: AssistantBuilderTimeFrame | null }, > { timeFrame: AssistantBuilderTimeFrame; disabled?: boolean; @@ -20,7 +20,7 @@ interface TimeUnitDropdownProps< } export function TimeUnitDropdown< - T extends { timeFrame?: AssistantBuilderTimeFrame }, + T extends { timeFrame?: AssistantBuilderTimeFrame | null }, >({ timeFrame, updateAction, onEdit, disabled }: TimeUnitDropdownProps) { return ( diff --git a/front/components/assistant_builder/server_side_props_helpers.ts b/front/components/assistant_builder/server_side_props_helpers.ts index 5b1d6242165c..df2298c20ca3 100644 --- a/front/components/assistant_builder/server_side_props_helpers.ts +++ b/front/components/assistant_builder/server_side_props_helpers.ts @@ -119,11 +119,11 @@ async function getRetrievalActionConfiguration( ? getDefaultRetrievalSearchActionConfiguration() : getDefaultRetrievalExhaustiveActionConfiguration(); if ( + "timeFrame" in retrievalConfiguration.configuration && action.relativeTimeFrame !== "auto" && - action.relativeTimeFrame !== "none" && - "timeFrame" in retrievalConfiguration + action.relativeTimeFrame !== "none" ) { - retrievalConfiguration.timeFrame = { + retrievalConfiguration.configuration.timeFrame = { value: action.relativeTimeFrame.duration, unit: action.relativeTimeFrame.unit, }; diff --git a/front/components/assistant_builder/types.ts b/front/components/assistant_builder/types.ts index 1f58a6776b9d..6ee7a6a58125 100644 --- a/front/components/assistant_builder/types.ts +++ b/front/components/assistant_builder/types.ts @@ -75,7 +75,7 @@ export type AssistantBuilderRetrievalConfiguration = { }; export type AssistantBuilderRetrievalExhaustiveConfiguration = { - timeFrame?: AssistantBuilderTimeFrame; + timeFrame?: AssistantBuilderTimeFrame | null; } & AssistantBuilderRetrievalConfiguration; // DustAppRun configuration @@ -246,6 +246,7 @@ export function getDefaultRetrievalExhaustiveActionConfiguration() { type: "RETRIEVAL_EXHAUSTIVE", configuration: { dataSourceConfigurations: {}, + timeFrame: null, } as AssistantBuilderRetrievalExhaustiveConfiguration, name: DEFAULT_RETRIEVAL_NO_QUERY_ACTION_NAME, description: "",