Skip to content

Commit

Permalink
Set up the config -> form -> schema -> template transformations for i…
Browse files Browse the repository at this point in the history
…nput_map

Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Nov 20, 2024
1 parent c2f05e4 commit 9b8fff8
Show file tree
Hide file tree
Showing 8 changed files with 357 additions and 55 deletions.
6 changes: 6 additions & 0 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,9 @@ export enum SOURCE_OPTIONS {
UPLOAD = 'upload',
EXISTING_INDEX = 'existing_index',
}
export enum TRANSFORM_TYPE {
STRING = 'string',
FIELD = 'field',
EXPRESSION = 'expression',
TEMPLATE = 'template',
}
26 changes: 24 additions & 2 deletions common/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
COMPONENT_CLASS,
PROCESSOR_TYPE,
PROMPT_FIELD,
TRANSFORM_TYPE,
WORKFLOW_TYPE,
} from './constants';

Expand All @@ -35,9 +36,21 @@ export type ConfigFieldType =
| 'map'
| 'mapArray'
| 'boolean'
| 'number';
| 'number'
| 'transform'
| 'transformArray';

export type ConfigFieldValue = string | {};
export type ConfigFieldTransformValue = {
transformType: TRANSFORM_TYPE;
value: string;
};
export type ConfigFieldTransformArrayValue = ConfigFieldTransformValue[];

export type ConfigFieldValue =
| string
| ConfigFieldTransformValue
| ConfigFieldTransformArrayValue
| {};

export interface IConfigField {
type: ConfigFieldType;
Expand Down Expand Up @@ -100,6 +113,15 @@ export type MapFormValue = MapEntry[];

export type MapArrayFormValue = MapFormValue[];

export type InputMapEntry = {
key: string;
value: ConfigFieldTransformValue;
};

export type InputMapFormValue = InputMapEntry[];

export type InputMapArrayFormValue = InputMapFormValue[];

export type WorkflowFormValues = {
ingest: FormikValues;
search: FormikValues;
Expand Down
2 changes: 1 addition & 1 deletion public/configs/ml_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export abstract class MLProcessor extends Processor {
},
{
id: 'input_map',
type: 'mapArray',
type: 'transformArray',
},
{
id: 'output_map',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ import {
MapFormValue,
} from '../../../../../../common';
import { ModelField } from '../../input_fields';
import {
TRANSFORM_TYPE,
InputMapEntry,
InputMapFormValue,
InputMapArrayFormValue,
} from '../../../../../../common';
import {
ConfigurePromptModal,
InputTransformModal,
Expand Down Expand Up @@ -139,10 +145,13 @@ export function MLProcessorInputs(props: MLProcessorInputsProps) {
parseModelInputs(newModelInterface).map((modelInput) => {
return {
key: modelInput.label,
value: '',
} as MapEntry;
}) as MapFormValue,
] as MapArrayFormValue;
value: {
transformType: TRANSFORM_TYPE.FIELD,
value: '',
},
} as InputMapEntry;
}) as InputMapFormValue,
] as InputMapArrayFormValue;
const modelOutputsAsForm = [
parseModelOutputs(newModelInterface).map((modelOutput) => {
return {
Expand Down
Loading

0 comments on commit 9b8fff8

Please sign in to comment.