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

[Backport 2.x] Minor improvements #535

Merged
merged 1 commit into from
Dec 13, 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
13 changes: 2 additions & 11 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export enum WORKFLOW_TYPE {
SEMANTIC_SEARCH = 'Semantic search',
MULTIMODAL_SEARCH = 'Multimodal search',
HYBRID_SEARCH = 'Hybrid search',
SENTIMENT_ANALYSIS = 'Sentiment analysis',
RAG = 'Retrieval-augmented generation',
CUSTOM = 'Custom',
UNKNOWN = 'Unknown',
Expand Down Expand Up @@ -174,6 +173,8 @@ export const ML_INFERENCE_RESPONSE_DOCS_LINK =
'https://opensearch.org/docs/latest/search-plugins/search-pipelines/ml-inference-search-response/#request-fields';
export const ML_CHOOSE_MODEL_LINK =
'https://opensearch.org/docs/latest/ml-commons-plugin/integrating-ml-models/#choosing-a-model';
export const ML_REMOTE_MODEL_LINK =
'https://opensearch.org/docs/latest/ml-commons-plugin/remote-models/index/';
export const TEXT_CHUNKING_PROCESSOR_LINK =
'https://opensearch.org/docs/latest/ingest-pipelines/processors/text-chunking/';
export const CREATE_WORKFLOW_LINK =
Expand Down Expand Up @@ -206,7 +207,6 @@ export const SHARED_OPTIONAL_FIELDS = ['max_chunk_limit', 'description', 'tag'];
export const DEFAULT_TEXT_FIELD = 'my_text';
export const DEFAULT_VECTOR_FIELD = 'my_embedding';
export const DEFAULT_IMAGE_FIELD = 'my_image';
export const DEFAULT_LABEL_FIELD = 'label';
export const DEFAULT_LLM_RESPONSE_FIELD = 'llm_response';

/**
Expand Down Expand Up @@ -239,15 +239,6 @@ export const TERM_QUERY_TEXT = {
},
},
};
export const TERM_QUERY_LABEL = {
query: {
term: {
[LABEL_FIELD_PATTERN]: {
value: QUERY_TEXT_PATTERN,
},
},
},
};
export const KNN_QUERY = {
_source: {
excludes: [VECTOR_FIELD_PATTERN],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import {
EuiCompressedSuperSelect,
EuiSuperSelectOption,
EuiText,
EuiSmallButton,
} from '@elastic/eui';
import {
MODEL_STATE,
WorkflowFormValues,
ModelFormValue,
IConfigField,
ML_CHOOSE_MODEL_LINK,
ML_REMOTE_MODEL_LINK,
} from '../../../../../common';
import { AppState } from '../../../../store';

Expand All @@ -45,6 +47,7 @@ export function ModelField(props: ModelFieldProps) {
// re-fetch here as it could overload client-side if user clicks back and forth /
// keeps re-rendering this component (and subsequently re-fetching data) as they're building flows
const models = useSelector((state: AppState) => state.ml.models);
//const models = {};

const { errors, touched, values } = useFormikContext<WorkflowFormValues>();

Expand Down Expand Up @@ -83,6 +86,31 @@ export function ModelField(props: ModelFieldProps) {
<EuiSpacer size="s" />
</>
)}
{isEmpty(deployedModels) && (
<>
<EuiCallOut
size="s"
title="No deployed models found"
iconType={'alert'}
color="warning"
>
<EuiText size="s">
To create and deploy models and make them accessible in
OpenSearch, see documentation.
</EuiText>
<EuiSpacer size="s" />
<EuiSmallButton
target="_blank"
href={ML_REMOTE_MODEL_LINK}
iconSide="right"
iconType={'popout'}
>
Documentation
</EuiSmallButton>
</EuiCallOut>
<EuiSpacer size="s" />
</>
)}
<Field name={props.fieldPath}>
{({ field, form }: FieldProps) => {
return (
Expand All @@ -98,6 +126,7 @@ export function ModelField(props: ModelFieldProps) {
helpText={'The model ID.'}
>
<EuiCompressedSuperSelect
disabled={isEmpty(deployedModels)}
options={deployedModels.map(
(option) =>
({
Expand Down
39 changes: 3 additions & 36 deletions public/pages/workflows/new_workflow/quick_configure_inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
BEDROCK_DIMENSIONS,
COHERE_DIMENSIONS,
DEFAULT_IMAGE_FIELD,
DEFAULT_LABEL_FIELD,
DEFAULT_LLM_RESPONSE_FIELD,
DEFAULT_TEXT_FIELD,
DEFAULT_VECTOR_FIELD,
Expand Down Expand Up @@ -87,13 +86,6 @@ export function QuickConfigureInputs(props: QuickConfigureInputsProps) {
};
break;
}
case WORKFLOW_TYPE.SENTIMENT_ANALYSIS: {
defaultFieldValues = {
textField: DEFAULT_TEXT_FIELD,
labelField: DEFAULT_LABEL_FIELD,
};
break;
}
case WORKFLOW_TYPE.RAG: {
defaultFieldValues = {
textField: DEFAULT_TEXT_FIELD,
Expand Down Expand Up @@ -188,17 +180,13 @@ export function QuickConfigureInputs(props: QuickConfigureInputsProps) {
<EuiCompressedFormRow
fullWidth={true}
label={
props.workflowType === WORKFLOW_TYPE.SENTIMENT_ANALYSIS
? 'Model'
: props.workflowType === WORKFLOW_TYPE.RAG
props.workflowType === WORKFLOW_TYPE.RAG
? 'Large language model'
: 'Embedding model'
}
isInvalid={false}
helpText={
props.workflowType === WORKFLOW_TYPE.SENTIMENT_ANALYSIS
? 'The sentiment analysis model'
: props.workflowType === WORKFLOW_TYPE.RAG
props.workflowType === WORKFLOW_TYPE.RAG
? 'The large language model to generate user-friendly responses'
: 'The model to generate embeddings'
}
Expand Down Expand Up @@ -245,9 +233,7 @@ export function QuickConfigureInputs(props: QuickConfigureInputsProps) {
label={'Text field'}
isInvalid={false}
helpText={`The name of the text document field to be ${
props.workflowType === WORKFLOW_TYPE.SENTIMENT_ANALYSIS
? 'analyzed'
: props.workflowType === WORKFLOW_TYPE.RAG
props.workflowType === WORKFLOW_TYPE.RAG
? 'used as context to the large language model (LLM)'
: 'embedded'
}`}
Expand Down Expand Up @@ -328,25 +314,6 @@ export function QuickConfigureInputs(props: QuickConfigureInputsProps) {
</EuiCompressedFormRow>
</>
)}
{props.workflowType === WORKFLOW_TYPE.SENTIMENT_ANALYSIS && (
<EuiCompressedFormRow
fullWidth={true}
label={'Label field'}
isInvalid={false}
helpText="The name of the document field containing the sentiment label"
>
<EuiCompressedFieldText
fullWidth={true}
value={fieldValues?.labelField || ''}
onChange={(e) => {
setFieldValues({
...fieldValues,
labelField: e.target.value,
});
}}
/>
</EuiCompressedFormRow>
)}
{props.workflowType === WORKFLOW_TYPE.RAG && (
<>
<EuiCompressedFormRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ function injectQuickConfigureFields(
switch (workflow.ui_metadata?.type) {
case WORKFLOW_TYPE.SEMANTIC_SEARCH:
case WORKFLOW_TYPE.HYBRID_SEARCH:
case WORKFLOW_TYPE.MULTIMODAL_SEARCH:
case WORKFLOW_TYPE.SENTIMENT_ANALYSIS: {
case WORKFLOW_TYPE.MULTIMODAL_SEARCH: {
if (!isEmpty(quickConfigureFields) && workflow.ui_metadata?.config) {
workflow.ui_metadata.config = updateIngestProcessors(
workflow.ui_metadata.config,
Expand Down
22 changes: 1 addition & 21 deletions public/pages/workflows/new_workflow/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
FETCH_ALL_QUERY,
customStringify,
TERM_QUERY_TEXT,
TERM_QUERY_LABEL,
MULTIMODAL_SEARCH_QUERY_BOOL,
IProcessorConfig,
VECTOR_TEMPLATE_PLACEHOLDER,
Expand Down Expand Up @@ -50,10 +49,6 @@ export function enrichPresetWorkflowWithUiMetadata(
uiMetadata = fetchHybridSearchMetadata();
break;
}
case WORKFLOW_TYPE.SENTIMENT_ANALYSIS: {
uiMetadata = fetchSentimentAnalysisMetadata();
break;
}
case WORKFLOW_TYPE.RAG: {
uiMetadata = fetchRAGMetadata();
break;
Expand Down Expand Up @@ -175,7 +170,7 @@ export function fetchMultimodalSearchMetadata(): UIState {
baseState.config.search.enrichRequest.processors = [
injectQueryTemplateInProcessor(
new MLSearchRequestProcessor().toObj(),
MULTIMODAL_SEARCH_QUERY_BOOL
KNN_QUERY
),
];
return baseState;
Expand Down Expand Up @@ -204,21 +199,6 @@ export function fetchHybridSearchMetadata(): UIState {
return baseState;
}

export function fetchSentimentAnalysisMetadata(): UIState {
let baseState = fetchEmptyMetadata();
baseState.type = WORKFLOW_TYPE.SENTIMENT_ANALYSIS;
baseState.config.ingest.enrich.processors = [new MLIngestProcessor().toObj()];
baseState.config.ingest.index.name.value = generateId('knn_index', 6);
baseState.config.ingest.index.settings.value = customStringify({
[`index.knn`]: true,
});
baseState.config.search.request.value = customStringify(TERM_QUERY_LABEL);
baseState.config.search.enrichRequest.processors = [
new MLSearchRequestProcessor().toObj(),
];
return baseState;
}

export function fetchRAGMetadata(): UIState {
let baseState = fetchEmptyMetadata();
baseState.type = WORKFLOW_TYPE.RAG;
Expand Down
4 changes: 2 additions & 2 deletions public/pages/workflows/workflow_list/workflow_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ export function WorkflowList(props: WorkflowListProps) {
<EuiFlyoutBody>
{selectedWorkflow?.ui_metadata === undefined ||
isEmpty(selectedWorkflow?.ui_metadata) ||
selectedWorkflow?.ui_metadata?.type === WORKFLOW_TYPE.CUSTOM ? (
selectedWorkflow?.ui_metadata?.type === WORKFLOW_TYPE.UNKNOWN ? (
<EuiEmptyPrompt
title={<h2>Invalid workflow type</h2>}
titleSize="s"
body={
<>
<EuiText size="s">
Displaying resources from custom workflows is not
Displaying resources from workflows of unknown type is not
currently supported.
</EuiText>
</>
Expand Down
11 changes: 0 additions & 11 deletions server/resources/templates/sentiment_analysis.json

This file was deleted.

Loading