PromptHelper
Defined in: .build/typescript/packages/core/src/indices/prompt-helper.ts:46
A collection of helper functions for working with prompts.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PromptHelper(
options):PromptHelper
Defined in: .build/typescript/packages/core/src/indices/prompt-helper.ts:54
Parameters
Section titled “Parameters”options
Section titled “options”PromptHelperOptions = {}
Returns
Section titled “Returns”PromptHelper
Properties
Section titled “Properties”contextWindow
Section titled “contextWindow”contextWindow:
number
Defined in: .build/typescript/packages/core/src/indices/prompt-helper.ts:47
numOutput
Section titled “numOutput”numOutput:
number
Defined in: .build/typescript/packages/core/src/indices/prompt-helper.ts:48
chunkOverlapRatio
Section titled “chunkOverlapRatio”chunkOverlapRatio:
number
Defined in: .build/typescript/packages/core/src/indices/prompt-helper.ts:49
chunkSizeLimit
Section titled “chunkSizeLimit”chunkSizeLimit:
undefined|number
Defined in: .build/typescript/packages/core/src/indices/prompt-helper.ts:50
tokenizer
Section titled “tokenizer”tokenizer:
Tokenizer
Defined in: .build/typescript/packages/core/src/indices/prompt-helper.ts:51
separator
Section titled “separator”separator:
string
Defined in: .build/typescript/packages/core/src/indices/prompt-helper.ts:52
Methods
Section titled “Methods”getTextSplitterGivenPrompt()
Section titled “getTextSplitterGivenPrompt()”getTextSplitterGivenPrompt(
prompt,numChunks,padding):TextSplitter
Defined in: .build/typescript/packages/core/src/indices/prompt-helper.ts:112
Creates a text splitter configured to maximally pack the available context window.
Parameters
Section titled “Parameters”prompt
Section titled “prompt”numChunks
Section titled “numChunks”number = 1
padding
Section titled “padding”number = DEFAULT_PADDING
Returns
Section titled “Returns”truncate()
Section titled “truncate()”truncate(
prompt,textChunks,padding):string[]
Defined in: .build/typescript/packages/core/src/indices/prompt-helper.ts:133
Truncate text chunks to fit within the available context window.
Parameters
Section titled “Parameters”prompt
Section titled “prompt”textChunks
Section titled “textChunks”string[]
padding
Section titled “padding”number = DEFAULT_PADDING
Returns
Section titled “Returns”string[]
repack()
Section titled “repack()”repack(
prompt,textChunks,padding):string[]
Defined in: .build/typescript/packages/core/src/indices/prompt-helper.ts:149
Repack text chunks to better utilize the available context window.
Parameters
Section titled “Parameters”prompt
Section titled “prompt”textChunks
Section titled “textChunks”string[]
padding
Section titled “padding”number = DEFAULT_PADDING
Returns
Section titled “Returns”string[]
fromLLMMetadata()
Section titled “fromLLMMetadata()”
staticfromLLMMetadata(metadata,options?):PromptHelper
Defined in: .build/typescript/packages/core/src/indices/prompt-helper.ts:162
Parameters
Section titled “Parameters”metadata
Section titled “metadata”options?
Section titled “options?”chunkOverlapRatio?
Section titled “chunkOverlapRatio?”number
chunkSizeLimit?
Section titled “chunkSizeLimit?”number
tokenizer?
Section titled “tokenizer?”Tokenizer
separator?
Section titled “separator?”string
Returns
Section titled “Returns”PromptHelper