Skip to content

Commit

Permalink
other 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 May 15, 2024
1 parent 7080932 commit e9e0957
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 59 deletions.
17 changes: 0 additions & 17 deletions public/pages/workflow_detail/resizable_workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,7 @@ export function ResizableWorkspace(props: ResizableWorkspaceProps) {

// Initialize the form state to an existing workflow, if applicable.
useEffect(() => {
// if (workflow?.ui_metadata?.workspace_flow) {
// const initFormValues = {} as WorkspaceFormValues;
// const initSchemaObj = {} as WorkspaceSchemaObj;
// workflow.ui_metadata.workspace_flow.nodes.forEach((node) => {
// initFormValues[node.id] = componentDataToFormik(node.data);
// initSchemaObj[node.id] = getComponentSchema(node.data);
// });
// const initFormSchema = yup.object(initSchemaObj) as WorkspaceSchema;
// setFormValues(initFormValues);
// setFormSchema(initFormSchema);
// }
if (workflow?.ui_metadata?.config) {
// TODO: implement below fns to generate the final form and schema objs.
// Should generate the form and its values on-the-fly
// similar to what we do with ComponentData in above commented-out code.
// This gives us more flexibility and maintainability instead of having to update
// low-level form and schema when making config changes (e.g., if of type 'string',
// automatically generate the default form values, and the default validation schema)
const initFormValues = uiConfigToFormik(workflow.ui_metadata.config);
const initFormSchema = uiConfigToSchema(workflow.ui_metadata.config);
setFormValues(initFormValues);
Expand Down
60 changes: 18 additions & 42 deletions public/pages/workflows/new_workflow/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
START_FROM_SCRATCH_WORKFLOW_NAME,
DEFAULT_NEW_WORKFLOW_NAME,
UIState,
IConfig,
} from '../../../../common';

// Fn to produce the complete preset template with all necessary UI metadata.
Expand Down Expand Up @@ -59,8 +60,11 @@ function fetchEmptyMetadata(): UIState {
processors: [],
},
index: {
id: 'index',
fields: [],
name: {
id: 'indexName',
type: 'string',
label: 'Index name',
},
},
},
search: {
Expand All @@ -82,49 +86,21 @@ 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();
const processor = new TextEmbeddingProcessor();
return {
config: {
ingest: {
source: {
id: 'source',
fields: [],
},
enrich: {
processors: [
{
id: processor.id,
fields: processor.fields,
metadata: {
label: processor.name,
},
},
],
},
index: {
name: {
id: 'indexName',
type: 'string',
label: 'Index name',
},
},
},
search: {
request: {
id: 'request',
fields: [],
},
enrichRequest: {
id: 'enrichRequest',
fields: [],
},
enrichResponse: {
id: 'enrichResponse',
fields: [],
},
// @ts-ignore
baseState.config.ingest.enrich.processors = [
{
id: processor.id,
fields: processor.fields,
metadata: {
label: processor.name,
},
},
};
] as IConfig[];
return baseState;
}

// function fetchSemanticSearchWorkspaceFlow(): WorkspaceFlowState {
Expand Down

0 comments on commit e9e0957

Please sign in to comment.