From 00ef845a65761f103e17b56b81e7d56c16ee0ce7 Mon Sep 17 00:00:00 2001 From: "Rossdan Craig rossdan@lastmileai.dev" <> Date: Sun, 14 Jan 2024 01:18:52 -0500 Subject: [PATCH] Refactor ConsolidateAIConfig to only take in specificed sub-actions I was having some trouble converting everything to `STREAM_AICONFIG_CHUNK` so I'm just doing really easy steps to keep diffs easy to review and test. You'll see final code changes at end of diff stack. ## This diff No functional changes, but I want to use the `CONSOLIDATE_AICONFIG` event to pass in nested action `STREAM_AICONFIG_CHUNK` action later in stack, without requiring me to pass it in directly to the `aiconfigReducer`. By separating these, they can be distinct types and easier to manage --- .../editor/client/src/components/aiconfigReducer.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/python/src/aiconfig/editor/client/src/components/aiconfigReducer.ts b/python/src/aiconfig/editor/client/src/components/aiconfigReducer.ts index 7a609ff9e..cc9c42e60 100644 --- a/python/src/aiconfig/editor/client/src/components/aiconfigReducer.ts +++ b/python/src/aiconfig/editor/client/src/components/aiconfigReducer.ts @@ -24,9 +24,15 @@ export type MutateAIConfigAction = | UpdatePromptParametersAction | UpdateGlobalParametersAction; +// Actions that appear when called via ConsolidateAIConfigAction +export type ConsolidateAIConfigSubAction = + | AddPromptAction + | RunPromptAction + | UpdatePromptInputAction; + export type ConsolidateAIConfigAction = { type: "CONSOLIDATE_AICONFIG"; - action: MutateAIConfigAction; + action: ConsolidateAIConfigSubAction; config: AIConfig; }; @@ -159,7 +165,7 @@ function reduceInsertPromptAtIndex( function reduceConsolidateAIConfig( state: ClientAIConfig, - action: MutateAIConfigAction, + action: ConsolidateAIConfigSubAction, responseConfig: AIConfig ): ClientAIConfig { // Make sure prompt structure is properly updated. Client input and metadata takes precedence