Skip to content

Commit

Permalink
UX fit-n-finish updates IV (#565) (#566)
Browse files Browse the repository at this point in the history
(cherry picked from commit 096bdfa)

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 5803762 commit 8b846fe
Show file tree
Hide file tree
Showing 22 changed files with 373 additions and 90 deletions.
5 changes: 4 additions & 1 deletion common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export enum WORKFLOW_TYPE {
MULTIMODAL_SEARCH = 'Multimodal search',
HYBRID_SEARCH = 'Hybrid search',
RAG = 'Retrieval-augmented generation',
VECTOR_SEARCH_WITH_RAG = 'Vector search with retrieval-augmented generation',
CUSTOM = 'Custom',
UNKNOWN = 'Unknown',
}
Expand Down Expand Up @@ -281,12 +282,13 @@ export const VECTOR = 'vector';
export const VECTOR_PATTERN = `{{${VECTOR}}}`;
export const VECTOR_TEMPLATE_PLACEHOLDER = `\$\{${VECTOR}\}`;
export const DEFAULT_K = 10;
export const DEFAULT_FETCH_SIZE = 10;

export const FETCH_ALL_QUERY = {
query: {
match_all: {},
},
size: 1000,
size: DEFAULT_FETCH_SIZE,
};
export const TERM_QUERY_TEXT = {
query: {
Expand Down Expand Up @@ -578,6 +580,7 @@ export const EMPTY_FIELD_STRING = '--';
export const OMIT_SYSTEM_INDEX_PATTERN = '*,-.*';
export const INDEX_NOT_FOUND_EXCEPTION = 'index_not_found_exception';
export const ERROR_GETTING_WORKFLOW_MSG = 'Failed to retrieve template';
export const INVALID_DATASOURCE_MSG = 'No Living connections';
export const NO_TEMPLATES_FOUND_MSG = 'There are no templates';
export const NO_MODIFICATIONS_FOUND_TEXT =
'Template does not contain any modifications';
Expand Down
3 changes: 2 additions & 1 deletion common/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ export type PromptPreset = {
};

export type QuickConfigureFields = {
modelId?: string;
embeddingModelId?: string;
llmId?: string;
vectorField?: string;
textField?: string;
imageField?: string;
Expand Down
1 change: 1 addition & 0 deletions common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function isVectorSearchUseCase(workflow: Workflow | undefined): boolean {
WORKFLOW_TYPE.HYBRID_SEARCH,
WORKFLOW_TYPE.MULTIMODAL_SEARCH,
WORKFLOW_TYPE.SEMANTIC_SEARCH,
WORKFLOW_TYPE.VECTOR_SEARCH_WITH_RAG,
].includes(workflow?.ui_metadata?.type)
);
}
74 changes: 51 additions & 23 deletions public/pages/workflow_detail/components/export_modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import React, { useEffect, useState } from 'react';
import yaml from 'js-yaml';
import { isEmpty, toLower } from 'lodash';
import {
EuiCodeBlock,
EuiFlexGroup,
EuiFlexItem,
EuiCompressedRadioGroup,
EuiText,
EuiLink,
EuiModal,
Expand All @@ -20,6 +20,7 @@ import {
EuiSmallButtonEmpty,
EuiCallOut,
EuiSpacer,
EuiSmallButtonGroup,
} from '@elastic/eui';
import {
CREATE_WORKFLOW_LINK,
Expand All @@ -38,21 +39,10 @@ interface ExportModalProps {
}

enum EXPORT_OPTION {
JSON = 'json',
YAML = 'yaml',
JSON = 'JSON',
YAML = 'YAML',
}

const exportOptions = [
{
id: EXPORT_OPTION.JSON,
label: 'JSON',
},
{
id: EXPORT_OPTION.YAML,
label: 'YAML',
},
];

/**
* Modal containing all of the export options
*/
Expand All @@ -75,6 +65,18 @@ export function ExportModal(props: ExportModalProps) {
}
}, [props.workflow, selectedOption]);

// client-side file to be downloaded if the user so chooses. Generate a file
// and its corresponding URL.
const [formattedConfigHref, setFormattedConfigHref] = useState<string>('');
useEffect(() => {
if (!isEmpty(formattedConfig)) {
const formattedConfigFile = new Blob([formattedConfig], {
type: `text/${toLower(selectedOption)}`,
});
setFormattedConfigHref(URL.createObjectURL(formattedConfigFile));
}
}, [formattedConfig]);

return (
<EuiModal
maxWidth={false}
Expand Down Expand Up @@ -115,19 +117,45 @@ export function ExportModal(props: ExportModalProps) {
>{`Note: certain resource IDs in the template, such as model IDs, may be cluster-specific and not work out-of-the-box
in other environments. Ensure these values are updated before attempting to provision in other environments.`}</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiCompressedRadioGroup
options={exportOptions}
idSelected={selectedOption}
onChange={(option) => {
setSelectedOption(option as EXPORT_OPTION);
}}
/>
<EuiFlexItem>
<EuiFlexGroup direction="row" justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiSmallButtonGroup
legend="Choose how to view your workflow"
options={[
{
id: EXPORT_OPTION.JSON,
label: EXPORT_OPTION.JSON,
},
{
id: EXPORT_OPTION.YAML,
label: EXPORT_OPTION.YAML,
},
]}
idSelected={selectedOption}
onChange={(id) => setSelectedOption(id as EXPORT_OPTION)}
data-testid="exportDataToggleButtonGroup"
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiSmallButtonEmpty
iconType="download"
iconSide="right"
href={formattedConfigHref}
download={`${props.workflow?.name}.${toLower(
selectedOption
)}`}
onClick={() => {}}
>
{`Download ${selectedOption} file`}
</EuiSmallButtonEmpty>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
{props.workflow !== undefined && (
<EuiFlexItem grow={false}>
<EuiCodeBlock
language={selectedOption}
language={toLower(selectedOption)}
fontSize="m"
isCopyable={true}
>
Expand Down
1 change: 1 addition & 0 deletions public/pages/workflow_detail/workflow_detail.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ describe('WorkflowDetail Page Functionality (Custom Workflow)', () => {
jest.clearAllMocks();
});
test('tests Export button, Tools panel toggling, and Workspace preview', async () => {
global.URL.createObjectURL = jest.fn();
const { getByText, container, getByTestId } = renderWithRouter(
workflowId,
workflowName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function JsonField(props: JsonFieldProps) {
value={jsonStr}
onChange={(input) => {
setJsonStr(input);
form.setFieldValue(field.name, input);
}}
onBlur={() => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export function OverrideQueryModal(props: OverrideQueryModalProps) {
validate={false}
label={'Query template'}
fieldPath={'request'}
editorHeight="30vh"
/>
{finalModelOutputs.length > 0 && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function SearchInputs(props: SearchInputsProps) {
<ConfigureSearchRequest />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiHorizontalRule margin="none" />
<EuiHorizontalRule margin="m" />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EnrichSearchRequest
Expand All @@ -48,7 +48,7 @@ export function SearchInputs(props: SearchInputsProps) {
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiHorizontalRule margin="none" />
<EuiHorizontalRule margin="m" />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EnrichSearchResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ export function WorkflowInputs(props: WorkflowInputsProps) {
);
dispatch(bulk({ apiBody: { body: bulkBody }, dataSourceId }))
.unwrap()
.then(async (resp) => {
.then(async (resp: any) => {
props.setIngestResponse(customStringify(resp));
props.setIsRunningIngest(false);
setLastIngested(Date.now());
Expand Down
Loading

0 comments on commit 8b846fe

Please sign in to comment.