Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Aug 20, 2024
1 parent 055b1ee commit 4c41897
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ export function ConfigureSearchRequest(props: ConfigureSearchRequestProps) {

return (
<>
{isEditModalOpen && <EditQueryModal setModalOpen={setIsEditModalOpen} />}
{isEditModalOpen && (
<EditQueryModal
setModalOpen={setIsEditModalOpen}
queryFieldPath="search.request"
/>
)}
<EuiFlexGroup direction="column">
<EuiFlexItem grow={false}>
<EuiTitle size="s">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ import {
} from '../../../../../common';

interface EditQueryModalProps {
queryFieldPath: string;
setModalOpen(isOpen: boolean): void;
}

/**
* Specialized component to render the text chunking ingest processor. The list of optional
* params we display is dependent on the source algorithm that is chosen. Internally, we persist
* all of the params, but only choose the relevant ones when constructing the final ingest processor
* template. This is to minimize the amount of ui config / form / schema updates we would need
* to do if we only persisted the subset of optional params specific to the currently-chosen algorithm.
* Basic modal for configuring a query. Provides a dropdown to select from
* a set of pre-defined queries targeted for different use cases.
*/
export function EditQueryModal(props: EditQueryModalProps) {
// Form state
Expand All @@ -48,7 +46,7 @@ export function EditQueryModal(props: EditQueryModalProps) {
useEffect(() => {
setQueryPreset(
QUERY_PRESETS.find(
(preset) => preset.query === getIn(values, 'search.request')
(preset) => preset.query === getIn(values, props.queryFieldPath)
)?.name
);
}, []);
Expand Down Expand Up @@ -86,7 +84,7 @@ export function EditQueryModal(props: EditQueryModalProps) {
onChange={(option: string) => {
setQueryPreset(option);
setFieldValue(
'search.request',
props.queryFieldPath,
QUERY_PRESETS.find((preset) => preset.name === option)?.query
);
}}
Expand All @@ -95,7 +93,7 @@ export function EditQueryModal(props: EditQueryModalProps) {
<EuiSpacer size="s" />
<JsonField
label="Query"
fieldPath={'search.request'}
fieldPath={props.queryFieldPath}
editorHeight="25vh"
readOnly={false}
/>
Expand Down
6 changes: 0 additions & 6 deletions public/pages/workflows/new_workflow/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ function fetchEmptyMetadata(): UIState {
}

function fetchSemanticSearchMetadata(): UIState {
// We can reuse the base state. Only need to override a few things,
// such as preset ingest processors.
let baseState = fetchEmptyMetadata();
baseState.type = WORKFLOW_TYPE.SEMANTIC_SEARCH;
baseState.config.ingest.enrich.processors = [new MLIngestProcessor().toObj()];
Expand All @@ -134,8 +132,6 @@ function fetchSemanticSearchMetadata(): UIState {
}

function fetchMultimodalSearchMetadata(): UIState {
// We can reuse the base state. Only need to override a few things,
// such as preset ingest processors.
let baseState = fetchEmptyMetadata();
baseState.type = WORKFLOW_TYPE.MULTIMODAL_SEARCH;
baseState.config.ingest.enrich.processors = [new MLIngestProcessor().toObj()];
Expand All @@ -150,8 +146,6 @@ function fetchMultimodalSearchMetadata(): UIState {
}

function fetchHybridSearchMetadata(): UIState {
// We can reuse the base state. Only need to override a few things,
// such as preset ingest processors.
let baseState = fetchEmptyMetadata();
baseState.type = WORKFLOW_TYPE.HYBRID_SEARCH;
baseState.config.ingest.enrich.processors = [new MLIngestProcessor().toObj()];
Expand Down

0 comments on commit 4c41897

Please sign in to comment.