Class: PromptHelper
A collection of helper functions for working with prompts.
Constructors
new PromptHelper()
new PromptHelper(
options
?):PromptHelper
Parameters
• options?: PromptHelperOptions
Returns
Defined in
packages/core/indices/dist/index.d.ts:30
Properties
chunkOverlapRatio
chunkOverlapRatio:
number
Defined in
packages/core/indices/dist/index.d.ts:26
chunkSizeLimit
chunkSizeLimit:
undefined
|number
Defined in
packages/core/indices/dist/index.d.ts:27
contextWindow
contextWindow:
number
Defined in
packages/core/indices/dist/index.d.ts:24
numOutput
numOutput:
number
Defined in
packages/core/indices/dist/index.d.ts:25
separator
separator:
string
Defined in
packages/core/indices/dist/index.d.ts:29
tokenizer
tokenizer:
Tokenizer
Defined in
packages/core/indices/dist/index.d.ts:28
Methods
getTextSplitterGivenPrompt()
getTextSplitterGivenPrompt(
prompt
,numChunks
?,padding
?):TextSplitter
Creates a text splitter configured to maximally pack the available context window.
Parameters
• prompt: BasePromptTemplate
<string
[], string
[]>
• numChunks?: number
• padding?: number
Returns
Defined in
packages/core/indices/dist/index.d.ts:34
repack()
repack(
prompt
,textChunks
,padding
?):string
[]
Repack text chunks to better utilize the available context window.
Parameters
• prompt: BasePromptTemplate
<string
[], string
[]>
• textChunks: string
[]
• padding?: number
Returns
string
[]
Defined in
packages/core/indices/dist/index.d.ts:42
truncate()
truncate(
prompt
,textChunks
,padding
?):string
[]
Truncate text chunks to fit within the available context window.
Parameters
• prompt: BasePromptTemplate
<string
[], string
[]>
• textChunks: string
[]
• padding?: number
Returns
string
[]
Defined in
packages/core/indices/dist/index.d.ts:38
fromLLMMetadata()
static
fromLLMMetadata(metadata
,options
?):PromptHelper
Parameters
• metadata: LLMMetadata
• options?
• options.chunkOverlapRatio?: number
• options.chunkSizeLimit?: number
• options.separator?: string
• options.tokenizer?: Tokenizer
Returns
Defined in
packages/core/indices/dist/index.d.ts:43