Skip to content

Commit f215a29

Browse files
committed
Finish onboarding all provisioning for neural sparse search
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent 7e840b2 commit f215a29

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

common/interfaces.ts

+9
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ export type SparseEncodingProcessor = IngestProcessor & {
6161
};
6262
};
6363

64+
export type IndexConfiguration = {
65+
settings: {};
66+
mappings: IndexMappings;
67+
};
68+
69+
export type IndexMappings = {
70+
properties: {};
71+
};
72+
6473
export type TemplateNode = {
6574
id: string;
6675
type: string;

public/pages/workflow_detail/utils/workflow_to_template_utils.ts

+29-14
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
NEURAL_SPARSE_TOKENIZER_TRANSFORMER,
3535
REGISTER_LOCAL_SPARSE_ENCODING_MODEL_STEP_TYPE,
3636
SparseEncodingProcessor,
37+
IndexMappings,
3738
} from '../../../../common';
3839

3940
/**
@@ -266,20 +267,12 @@ function indexerToTemplateNode(
266267
directlyConnectedNode,
267268
]);
268269

269-
return {
270-
id: flowNode.data.id,
271-
type: CREATE_INDEX_STEP_TYPE,
272-
previous_node_inputs: {
273-
[directlyConnectedNode.id]: 'pipeline_id',
274-
},
275-
user_inputs: {
276-
index_name: indexName,
277-
configurations: {
278-
settings: {
279-
default_pipeline: `\${{${directlyConnectedNode.id}.pipeline_id}}`,
280-
},
281-
mappings: {
282-
properties: {
270+
// index mappings are different per use case
271+
const finalIndexMappings = {
272+
properties:
273+
directlyConnectedNode.data.type ===
274+
COMPONENT_CLASS.TEXT_EMBEDDING_TRANSFORMER
275+
? {
283276
[vectorField]: {
284277
type: 'knn_vector',
285278
// TODO: remove hardcoding, fetch from the selected model
@@ -295,8 +288,30 @@ function indexerToTemplateNode(
295288
[inputField]: {
296289
type: 'text',
297290
},
291+
}
292+
: {
293+
[vectorField]: {
294+
type: 'rank_features',
295+
},
296+
[inputField]: {
297+
type: 'text',
298+
},
298299
},
300+
} as IndexMappings;
301+
302+
return {
303+
id: flowNode.data.id,
304+
type: CREATE_INDEX_STEP_TYPE,
305+
previous_node_inputs: {
306+
[directlyConnectedNode.id]: 'pipeline_id',
307+
},
308+
user_inputs: {
309+
index_name: indexName,
310+
configurations: {
311+
settings: {
312+
default_pipeline: `\${{${directlyConnectedNode.id}.pipeline_id}}`,
299313
},
314+
mappings: finalIndexMappings,
300315
},
301316
},
302317
};

0 commit comments

Comments
 (0)