Skip to content

Commit

Permalink
Only add input map / output map if applicable; simplify k/v placeholder
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Jun 11, 2024
1 parent cec79a6 commit 6ceeb6c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions common/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ export type SearchPhaseResultsProcessor = SearchProcessor & {};
export type MLInferenceProcessor = IngestProcessor & {
ml_inference: {
model_id: string;
input_map: {};
output_map: {};
input_map?: {};
output_map?: {};
};
};

Expand Down
18 changes: 11 additions & 7 deletions public/pages/workflow_detail/utils/workflow_to_template_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,21 @@ function mlProcessorConfigToTemplateNodes(
};
const ingestPipelineName = generateId('ingest_pipeline');

const finalProcessor = {
let finalProcessor = {
ml_inference: {
model_id: model.id,
input_map: inputMap.map((mapEntry) => ({
[mapEntry.key]: mapEntry.value,
})),
output_map: outputMap.map((mapEntry) => ({
[mapEntry.key]: mapEntry.value,
})),
},
} as MLInferenceProcessor;
if (inputMap?.length > 0) {
finalProcessor.ml_inference.input_map = inputMap.map((mapEntry) => ({
[mapEntry.key]: mapEntry.value,
}));
}
if (outputMap?.length > 0) {
finalProcessor.ml_inference.output_map = outputMap.map((mapEntry) => ({
[mapEntry.key]: mapEntry.value,
}));
}

const finalIngestPipelineDescription =
'An ingest pipeline with an ML inference processor.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ export function MapField(props: MapFieldProps) {
startControl={
<input
type="string"
placeholder="Key"
// TODO: find a way to config/title the placeholder text.
// For example, K/V values have different meanings if input
// map or output map for ML inference processors.
placeholder="Input"
className="euiFieldText"
value={mapping.key}
onChange={(e) => {
Expand All @@ -109,7 +112,7 @@ export function MapField(props: MapFieldProps) {
endControl={
<input
type="string"
placeholder="Value"
placeholder="Output"
className="euiFieldText"
value={mapping.value}
onChange={(e) => {
Expand Down

0 comments on commit 6ceeb6c

Please sign in to comment.