diff --git a/public/pages/workflow_detail/prototype/ingestor.tsx b/public/pages/workflow_detail/prototype/ingestor.tsx deleted file mode 100644 index e69de29b..00000000 diff --git a/public/pages/workflow_detail/prototype/query_executor.tsx b/public/pages/workflow_detail/prototype/query_executor.tsx deleted file mode 100644 index e69de29b..00000000 diff --git a/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/configure_prompt_modal.tsx b/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/configure_prompt_modal.tsx index d0c8c1a8..fa9188cd 100644 --- a/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/configure_prompt_modal.tsx +++ b/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/configure_prompt_modal.tsx @@ -122,13 +122,15 @@ export function ConfigurePromptModal(props: ConfigurePromptModalProps) { items: PROMPT_PRESETS.map((preset: PromptPreset) => ({ name: preset.name, onClick: () => { - setFieldValue( - modelConfigPath, - customStringify({ - ...JSON.parse(modelConfig), - prompt: preset.prompt, - }) - ); + try { + setFieldValue( + modelConfigPath, + customStringify({ + ...JSON.parse(modelConfig), + prompt: preset.prompt, + }) + ); + } catch {} setFieldTouched(modelConfigPath, true); setPresetsPopoverOpen(false); }, @@ -158,7 +160,10 @@ export function ConfigurePromptModal(props: ConfigurePromptModalProps) { tabSize={2} onChange={(value) => setPromptStr(value)} onBlur={(e) => { - let updatedModelConfig = JSON.parse(modelConfig); + let updatedModelConfig = {} as any; + try { + updatedModelConfig = JSON.parse(modelConfig); + } catch {} if (isEmpty(promptStr)) { // if the input is blank, it is assumed the user // does not want any prompt. hence, remove the "prompt" field diff --git a/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/input_transform_modal.tsx b/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/input_transform_modal.tsx index 4c901b0c..624cd0b1 100644 --- a/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/input_transform_modal.tsx +++ b/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/input_transform_modal.tsx @@ -27,6 +27,7 @@ import { EuiPopoverTitle, EuiIconTip, EuiSwitch, + EuiCallOut, } from '@elastic/eui'; import { IConfigField, @@ -106,6 +107,22 @@ export function InputTransformModal(props: InputTransformModalProps) { const map = getIn(values, props.inputMapFieldPath) as MapArrayFormValue; const oneToOnePath = `${props.baseConfigPath}.${props.config.id}.one_to_one`; const oneToOne = getIn(values, oneToOnePath); + const docs = getIn(values, 'ingest.docs'); + let docObjs = [] as {}[] | undefined; + try { + docObjs = JSON.parse(docs); + } catch {} + const query = getIn(values, 'search.request'); + let queryObj = {} as {} | undefined; + try { + queryObj = JSON.parse(query); + } catch {} + const onIngestAndNoDocs = + props.context === PROCESSOR_CONTEXT.INGEST && isEmpty(docObjs); + const onSearchAndNoQuery = + (props.context === PROCESSOR_CONTEXT.SEARCH_REQUEST || + props.context === PROCESSOR_CONTEXT.SEARCH_RESPONSE) && + isEmpty(queryObj); // selected transform state const transformOptions = map.map((_, idx) => ({ @@ -226,6 +243,20 @@ export function InputTransformModal(props: InputTransformModalProps) { <> + {(onIngestAndNoDocs || onSearchAndNoQuery) && ( + <> + + + + )} {description} {props.context === PROCESSOR_CONTEXT.SEARCH_RESPONSE && ( @@ -252,6 +283,7 @@ export function InputTransformModal(props: InputTransformModalProps) { { setIsFetching(true); switch (props.context) { diff --git a/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/output_transform_modal.tsx b/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/output_transform_modal.tsx index 334dc620..31b27cf6 100644 --- a/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/output_transform_modal.tsx +++ b/public/pages/workflow_detail/workflow_inputs/processor_inputs/modals/output_transform_modal.tsx @@ -24,6 +24,7 @@ import { EuiSmallButtonEmpty, EuiPopoverTitle, EuiCodeBlock, + EuiCallOut, } from '@elastic/eui'; import { IConfigField, @@ -91,6 +92,22 @@ export function OutputTransformModal(props: OutputTransformModalProps) { const map = getIn(values, props.outputMapFieldPath) as MapArrayFormValue; const fullResponsePathPath = `${props.baseConfigPath}.${props.config.id}.full_response_path`; const fullResponsePath = getIn(values, fullResponsePathPath); + const docs = getIn(values, 'ingest.docs'); + let docObjs = [] as {}[] | undefined; + try { + docObjs = JSON.parse(docs); + } catch {} + const query = getIn(values, 'search.request'); + let queryObj = {} as {} | undefined; + try { + queryObj = JSON.parse(query); + } catch {} + const onIngestAndNoDocs = + props.context === PROCESSOR_CONTEXT.INGEST && isEmpty(docObjs); + const onSearchAndNoQuery = + (props.context === PROCESSOR_CONTEXT.SEARCH_REQUEST || + props.context === PROCESSOR_CONTEXT.SEARCH_RESPONSE) && + isEmpty(queryObj); // popover state containing the model interface details, if applicable const [popoverOpen, setPopoverOpen] = useState(false); @@ -141,6 +158,20 @@ export function OutputTransformModal(props: OutputTransformModalProps) { <> + {(onIngestAndNoDocs || onSearchAndNoQuery) && ( + <> + + + + )} Fetch some sample output data and see how it is transformed. @@ -211,6 +242,7 @@ export function OutputTransformModal(props: OutputTransformModalProps) { { setIsFetching(true); switch (props.context) { diff --git a/public/utils/utils.ts b/public/utils/utils.ts index f03d5c61..4e24e2b7 100644 --- a/public/utils/utils.ts +++ b/public/utils/utils.ts @@ -138,7 +138,10 @@ export function prepareDocsForSimulate( indexName: string ): SimulateIngestPipelineDoc[] { const preparedDocs = [] as SimulateIngestPipelineDoc[]; - const docObjs = JSON.parse(docs) as {}[]; + let docObjs = [] as {}[]; + try { + docObjs = JSON.parse(docs) as {}[]; + } catch {} docObjs.forEach((doc) => { preparedDocs.push({ _index: indexName,