Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add existing indices as a source data option; improve config autofilling #346

Merged
merged 7 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const BASE_NODE_API_PATH = '/api/flow_framework';
// OpenSearch node APIs
export const BASE_OPENSEARCH_NODE_API_PATH = `${BASE_NODE_API_PATH}/opensearch`;
export const CAT_INDICES_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/catIndices`;
export const GET_MAPPINGS_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/mappings`;
export const SEARCH_INDEX_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/search`;
export const INGEST_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/ingest`;
export const BULK_NODE_API_PATH = `${BASE_OPENSEARCH_NODE_API_PATH}/bulk`;
Expand Down
4 changes: 2 additions & 2 deletions common/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ export type NormalizationProcessor = SearchProcessor & {
};

export type IndexConfiguration = {
settings: {};
settings: { [key: string]: any };
mappings: IndexMappings;
};

export type IndexMappings = {
properties: {};
properties: { [key: string]: any };
};

export type TemplateNode = {
Expand Down
13 changes: 12 additions & 1 deletion common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import moment from 'moment';
import { DATE_FORMAT_PATTERN } from './';
import { DATE_FORMAT_PATTERN, WORKFLOW_TYPE, Workflow } from './';
import { isEmpty } from 'lodash';

export function toFormattedDate(timestampMillis: number): String {
Expand Down Expand Up @@ -39,3 +39,14 @@ export function getCharacterLimitedString(
export function customStringify(jsonObj: {}): string {
return JSON.stringify(jsonObj, undefined, 2);
}

export function isVectorSearchUseCase(workflow: Workflow | undefined): boolean {
return (
workflow?.ui_metadata?.type !== undefined &&
[
WORKFLOW_TYPE.HYBRID_SEARCH,
WORKFLOW_TYPE.MULTIMODAL_SEARCH,
WORKFLOW_TYPE.SEMANTIC_SEARCH,
].includes(workflow?.ui_metadata?.type)
);
}
8 changes: 2 additions & 6 deletions public/pages/workflow_detail/resizable_workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import React, { useRef, useState, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { Form, Formik } from 'formik';
import * as yup from 'yup';
import {
Expand All @@ -21,6 +20,7 @@ import {
WorkflowConfig,
WorkflowFormValues,
WorkflowSchema,
customStringify,
} from '../../../common';
import {
isValidUiWorkflow,
Expand Down Expand Up @@ -286,11 +286,7 @@ export function ResizableWorkspace(props: ResizableWorkspaceProps) {
</EuiFlexItem>
<EuiFlexItem grow={7}>
<EuiCodeBlock language="json" fontSize="m" isCopyable={false}>
{JSON.stringify(
reduceToTemplate(props.workflow as Workflow),
undefined,
2
)}
{customStringify(reduceToTemplate(props.workflow as Workflow))}
</EuiCodeBlock>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
3 changes: 3 additions & 0 deletions public/pages/workflow_detail/workflow_detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getCore } from '../../services';
import { WorkflowDetailHeader } from './components';
import {
AppState,
catIndices,
getWorkflow,
searchModels,
useAppDispatch,
Expand Down Expand Up @@ -101,9 +102,11 @@ export function WorkflowDetail(props: WorkflowDetailProps) {
// On initial load:
// - fetch workflow
// - fetch available models as their IDs may be used when building flows
// - fetch all indices
useEffect(() => {
dispatch(getWorkflow({ workflowId, dataSourceId }));
dispatch(searchModels({ apiBody: FETCH_ALL_QUERY, dataSourceId }));
dispatch(catIndices({ pattern: '*,-.*', dataSourceId }));
}, []);

return errorMessage.includes(ERROR_GETTING_WORKFLOW_MSG) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule } from '@elastic/eui';
import { SourceData } from './source_data';
import { EnrichData } from './enrich_data';
import { IngestData } from './ingest_data';
import { WorkflowConfig } from '../../../../../common';
import { Workflow, WorkflowConfig } from '../../../../../common';

interface IngestInputsProps {
setIngestDocs: (docs: string) => void;
uiConfig: WorkflowConfig;
setUiConfig: (uiConfig: WorkflowConfig) => void;
workflow: Workflow | undefined;
}

/**
Expand All @@ -23,7 +24,11 @@ export function IngestInputs(props: IngestInputsProps) {
return (
<EuiFlexGroup direction="column">
<EuiFlexItem grow={false}>
<SourceData setIngestDocs={props.setIngestDocs} />
<SourceData
workflow={props.workflow}
uiConfig={props.uiConfig}
setIngestDocs={props.setIngestDocs}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiHorizontalRule margin="none" />
Expand Down
Loading
Loading