Skip to main content

Class: PromptHelper

A collection of helper functions for working with prompts.

Constructors

new PromptHelper()

new PromptHelper(options?): PromptHelper

Parameters

options?: PromptHelperOptions

Returns

PromptHelper

Defined in

packages/core/indices/dist/indices/index.d.ts:29

Properties

chunkOverlapRatio

chunkOverlapRatio: number

Defined in

packages/core/indices/dist/indices/index.d.ts:25


chunkSizeLimit

chunkSizeLimit: undefined | number

Defined in

packages/core/indices/dist/indices/index.d.ts:26


contextWindow

contextWindow: number

Defined in

packages/core/indices/dist/indices/index.d.ts:23


numOutput

numOutput: number

Defined in

packages/core/indices/dist/indices/index.d.ts:24


separator

separator: string

Defined in

packages/core/indices/dist/indices/index.d.ts:28


tokenizer

tokenizer: Tokenizer

Defined in

packages/core/indices/dist/indices/index.d.ts:27

Methods

getTextSplitterGivenPrompt()

getTextSplitterGivenPrompt(prompt, numChunks?, padding?): SentenceSplitter

Creates a text splitter with the correct chunk sizes and overlaps given a prompt.

Parameters

prompt: PromptTemplate<string[], string[], string>

numChunks?: number

padding?: number

Returns

SentenceSplitter

Defined in

packages/core/indices/dist/indices/index.d.ts:43


repack()

repack(prompt, textChunks, padding?): string[]

Repack resplits the strings based on the optimal text splitter.

Parameters

prompt: PromptTemplate<string[], string[], string>

textChunks: string[]

padding?: number

Returns

string[]

Defined in

packages/core/indices/dist/indices/index.d.ts:47


fromLLMMetadata()

static fromLLMMetadata(metadata, options?): PromptHelper

Parameters

metadata: LLMMetadata

options?

options.chunkOverlapRatio?: number

options.chunkSizeLimit?: number

options.separator?: string

options.tokenizer?: Tokenizer

Returns

PromptHelper

Defined in

packages/core/indices/dist/indices/index.d.ts:48