Skip to content

Commit d3c40e5

Browse files
committed
Update preset filter fns
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent b7cf1f3 commit d3c40e5

File tree

5 files changed

+47
-48
lines changed

5 files changed

+47
-48
lines changed

common/utils.ts

+16-5
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,26 @@ export function customStringifySingleLine(jsonObj: {}): string {
4444
return JSON.stringify(jsonObj, undefined, 0);
4545
}
4646

47-
export function isVectorSearchUseCase(workflow: Workflow | undefined): boolean {
47+
export function isVectorSearchUseCase(workflowType?: WORKFLOW_TYPE): boolean {
4848
return (
49-
workflow?.ui_metadata?.type !== undefined &&
49+
workflowType !== undefined &&
5050
[
51-
WORKFLOW_TYPE.HYBRID_SEARCH,
52-
WORKFLOW_TYPE.MULTIMODAL_SEARCH,
5351
WORKFLOW_TYPE.SEMANTIC_SEARCH,
52+
WORKFLOW_TYPE.MULTIMODAL_SEARCH,
53+
WORKFLOW_TYPE.HYBRID_SEARCH,
54+
WORKFLOW_TYPE.VECTOR_SEARCH_WITH_RAG,
55+
WORKFLOW_TYPE.HYBRID_SEARCH_WITH_RAG,
56+
].includes(workflowType)
57+
);
58+
}
59+
60+
export function isRAGUseCase(workflowType?: WORKFLOW_TYPE): boolean {
61+
return (
62+
workflowType !== undefined &&
63+
[
64+
WORKFLOW_TYPE.RAG,
5465
WORKFLOW_TYPE.VECTOR_SEARCH_WITH_RAG,
5566
WORKFLOW_TYPE.HYBRID_SEARCH_WITH_RAG,
56-
].includes(workflow?.ui_metadata?.type)
67+
].includes(workflowType)
5768
);
5869
}

public/pages/workflow_detail/workflow_inputs/ingest_inputs/source_data.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function SourceData(props: SourceDataProps) {
6868

6969
// try to clear out any default values for the ML ingest processor, if applicable
7070
if (
71-
isVectorSearchUseCase(props.workflow) &&
71+
isVectorSearchUseCase(props.workflow?.ui_metadata?.type) &&
7272
isEditModalOpen &&
7373
selectedOption !== SOURCE_OPTIONS.EXISTING_INDEX
7474
) {

public/pages/workflow_detail/workflow_inputs/ingest_inputs/source_data_modal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export function SourceDataModal(props: SourceDataProps) {
112112

113113
// 2. Update several form values if an index is selected (and if vector search)
114114
if (selectedIndex !== undefined) {
115-
if (isVectorSearchUseCase(props.workflow)) {
115+
if (isVectorSearchUseCase(props.workflow?.ui_metadata?.type)) {
116116
dispatch(getMappings({ index: selectedIndex, dataSourceId }))
117117
.unwrap()
118118
.then((resp: IndexMappings) => {

public/pages/workflows/new_workflow/quick_configure_modal.tsx

+25-33
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import {
5959
MODEL_STATE,
6060
ML_REMOTE_MODEL_LINK,
6161
MODEL_CATEGORY,
62+
isRAGUseCase,
6263
} from '../../../../common';
6364
import { APP_PATH, getInitialValue } from '../../../utils';
6465
import { AppState, createWorkflow, useAppDispatch } from '../../../store';
@@ -140,11 +141,7 @@ export function QuickConfigureModal(props: QuickConfigureModalProps) {
140141
// If not custom/blank, we will have more req'd form fields for the users to supply
141142
if (workflowType !== WORKFLOW_TYPE.CUSTOM) {
142143
// if a RAG workflow, require an LLM
143-
if (
144-
workflowType === WORKFLOW_TYPE.RAG ||
145-
workflowType === WORKFLOW_TYPE.VECTOR_SEARCH_WITH_RAG ||
146-
workflowType === WORKFLOW_TYPE.HYBRID_SEARCH_WITH_RAG
147-
) {
144+
if (isRAGUseCase(workflowType)) {
148145
tempFormValues = {
149146
...tempFormValues,
150147
llm: getInitialValue('model'),
@@ -298,30 +295,25 @@ export function QuickConfigureModal(props: QuickConfigureModalProps) {
298295
/>
299296
</EuiFlexItem>
300297
)}
301-
{(props.workflow?.ui_metadata?.type === WORKFLOW_TYPE.RAG ||
302-
props.workflow?.ui_metadata?.type ===
303-
WORKFLOW_TYPE.VECTOR_SEARCH_WITH_RAG ||
304-
props.workflow?.ui_metadata?.type ===
305-
WORKFLOW_TYPE.HYBRID_SEARCH_WITH_RAG) &&
306-
!isEmpty(deployedModels) && (
307-
<EuiFlexItem>
308-
<ModelField
309-
modelCategory={MODEL_CATEGORY.LLM}
310-
fieldPath="llm"
311-
showMissingInterfaceCallout={false}
312-
label="Large language model"
313-
helpText="The large language model to generate user-friendly responses."
314-
fullWidth={true}
315-
showError={true}
316-
onModelChange={(modelId) =>
317-
setQuickConfigureFields({
318-
...quickConfigureFields,
319-
llmId: modelId,
320-
})
321-
}
322-
/>
323-
</EuiFlexItem>
324-
)}
298+
{isRAGUseCase(props.workflow?.ui_metadata?.type) && (
299+
<EuiFlexItem>
300+
<ModelField
301+
modelCategory={MODEL_CATEGORY.LLM}
302+
fieldPath="llm"
303+
showMissingInterfaceCallout={false}
304+
label="Large language model"
305+
helpText="The large language model to generate user-friendly responses."
306+
fullWidth={true}
307+
showError={true}
308+
onModelChange={(modelId) =>
309+
setQuickConfigureFields({
310+
...quickConfigureFields,
311+
llmId: modelId,
312+
})
313+
}
314+
/>
315+
</EuiFlexItem>
316+
)}
325317
{props.workflow?.ui_metadata?.type !== WORKFLOW_TYPE.CUSTOM &&
326318
props.workflow?.ui_metadata?.type !== WORKFLOW_TYPE.RAG &&
327319
!isEmpty(deployedModels) && (
@@ -452,7 +444,7 @@ function injectQuickConfigureFields(
452444
workflow.ui_metadata.config,
453445
quickConfigureFields,
454446
embeddingModelInterface,
455-
isVectorSearchUseCase(workflow)
447+
isVectorSearchUseCase(workflow?.ui_metadata?.type)
456448
);
457449
workflow.ui_metadata.config = updateIndexConfig(
458450
workflow.ui_metadata.config,
@@ -466,7 +458,7 @@ function injectQuickConfigureFields(
466458
workflow.ui_metadata.config,
467459
quickConfigureFields,
468460
embeddingModelInterface,
469-
isVectorSearchUseCase(workflow)
461+
isVectorSearchUseCase(workflow?.ui_metadata?.type)
470462
);
471463
}
472464
break;
@@ -492,7 +484,7 @@ function injectQuickConfigureFields(
492484
workflow.ui_metadata.config,
493485
quickConfigureFields,
494486
embeddingModelInterface,
495-
isVectorSearchUseCase(workflow)
487+
isVectorSearchUseCase(workflow?.ui_metadata?.type)
496488
);
497489
workflow.ui_metadata.config = updateIndexConfig(
498490
workflow.ui_metadata.config,
@@ -506,7 +498,7 @@ function injectQuickConfigureFields(
506498
workflow.ui_metadata.config,
507499
quickConfigureFields,
508500
embeddingModelInterface,
509-
isVectorSearchUseCase(workflow)
501+
isVectorSearchUseCase(workflow?.ui_metadata?.type)
510502
);
511503
workflow.ui_metadata.config = updateRAGSearchResponseProcessors(
512504
workflow.ui_metadata.config,

public/pages/workflows/new_workflow/quick_configure_optional_fields.tsx

+4-8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {
2626
ModelInterface,
2727
QuickConfigureFields,
2828
WORKFLOW_TYPE,
29+
isRAGUseCase,
30+
isVectorSearchUseCase,
2931
} from '../../../../common';
3032
import { AppState } from '../../../store';
3133
import { getEmbeddingModelDimensions, parseModelInputs } from '../../../utils';
@@ -199,11 +201,7 @@ export function QuickConfigureOptionalFields(
199201
<EuiSpacer size="s" />
200202
</>
201203
)}
202-
{(props.workflowType === WORKFLOW_TYPE.SEMANTIC_SEARCH ||
203-
props.workflowType === WORKFLOW_TYPE.MULTIMODAL_SEARCH ||
204-
props.workflowType === WORKFLOW_TYPE.HYBRID_SEARCH ||
205-
props.workflowType === WORKFLOW_TYPE.VECTOR_SEARCH_WITH_RAG ||
206-
props.workflowType === WORKFLOW_TYPE.HYBRID_SEARCH_WITH_RAG) && (
204+
{isVectorSearchUseCase(props.workflowType) && (
207205
<>
208206
<EuiCompressedFormRow
209207
fullWidth={true}
@@ -246,9 +244,7 @@ export function QuickConfigureOptionalFields(
246244
)}
247245
</>
248246
)}
249-
{(props.workflowType === WORKFLOW_TYPE.RAG ||
250-
props.workflowType === WORKFLOW_TYPE.VECTOR_SEARCH_WITH_RAG ||
251-
props.workflowType === WORKFLOW_TYPE.HYBRID_SEARCH_WITH_RAG) && (
247+
{isRAGUseCase(props.workflowType) && (
252248
<>
253249
<EuiCompressedFormRow
254250
fullWidth={true}

0 commit comments

Comments
 (0)