-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support optional params for all processors; onboard text_chunking pro…
…cessor (#265) (#266) Signed-off-by: Tyler Ohlsen <[email protected]> (cherry picked from commit e2d22c3) Co-authored-by: Tyler Ohlsen <[email protected]>
- Loading branch information
1 parent
fe93f51
commit 03b5c44
Showing
26 changed files
with
695 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
public/configs/ingest_processors/text_chunking_ingest_processor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { PROCESSOR_TYPE, TEXT_CHUNKING_ALGORITHM } from '../../../common'; | ||
import { generateId } from '../../utils'; | ||
import { Processor } from '../processor'; | ||
|
||
/** | ||
* The text chunking ingest processor | ||
*/ | ||
export class TextChunkingIngestProcessor extends Processor { | ||
constructor() { | ||
super(); | ||
this.name = 'Text Chunking Processor'; | ||
this.type = PROCESSOR_TYPE.TEXT_CHUNKING; | ||
this.id = generateId('text_chunking_processor_ingest'); | ||
this.fields = [ | ||
{ | ||
id: 'field_map', | ||
type: 'map', | ||
}, | ||
{ | ||
id: 'algorithm', | ||
type: 'select', | ||
selectOptions: [ | ||
TEXT_CHUNKING_ALGORITHM.FIXED_TOKEN_LENGTH, | ||
TEXT_CHUNKING_ALGORITHM.DELIMITER, | ||
], | ||
}, | ||
]; | ||
// optional params include all of those possible from both text chunking algorithms. | ||
// for more details, see https://opensearch.org/docs/latest/ingest-pipelines/processors/text-chunking/ | ||
// the list of optional params per algorithm and shared across algorithms is persisted in | ||
// common/constants.ts | ||
this.optionalFields = [ | ||
// fixed_token_length optional params | ||
{ | ||
id: 'token_limit', | ||
type: 'number', | ||
value: 384, | ||
}, | ||
{ | ||
id: 'tokenizer', | ||
type: 'string', | ||
value: 'standard', | ||
}, | ||
{ | ||
id: 'overlap_rate', | ||
type: 'number', | ||
value: 0, | ||
}, | ||
// delimiter optional params | ||
{ | ||
id: 'delimiter', | ||
type: 'string', | ||
}, | ||
// shared optional params (independent of algorithm) | ||
{ | ||
id: 'max_chunk_limit', | ||
type: 'number', | ||
value: 100, | ||
}, | ||
{ | ||
id: 'description', | ||
type: 'string', | ||
}, | ||
{ | ||
id: 'tag', | ||
type: 'string', | ||
}, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.