Class LengthBasedExampleSelector

A specialized example selector that selects examples based on their length, ensuring that the total length of the selected examples does not exceed a specified maximum length.

Hierarchy

Constructors

Properties

examplePrompt: PromptTemplate<any, any>
exampleTextLengths: number[] = []
getTextLength: ((text) => number) = getLengthBased

Type declaration

    • (text): number
    • Parameters

      • text: string

      Returns number

maxLength: number = 2048
examples: Example[] = []

Methods

  • Adds an example to the list of examples and calculates its length.

    Parameters

    • example: Example

      The example to be added.

    Returns Promise<void>

    Promise that resolves when the example has been added and its length calculated.

  • Calculates the lengths of the examples.

    Parameters

    Returns Promise<number[]>

    Promise that resolves with an array of lengths of the examples.

  • Selects examples until the total length of the selected examples reaches the maxLength.

    Parameters

    • inputVariables: Example

      The input variables for the examples.

    Returns Promise<Example[]>

    Promise that resolves with an array of selected examples.

  • Creates a new instance of LengthBasedExampleSelector and adds a list of examples to it.

    Parameters

    Returns Promise<LengthBasedExampleSelector>

    Promise that resolves with a new instance of LengthBasedExampleSelector with the examples added.

Generated using TypeDoc