Search Results for

    Show / Hide Table of Contents

    Class LengthBasedExampleSelector

    Select examples for FewShotPromptTemplate based on length.

    Inheritance
    object
    LengthBasedExampleSelector
    Implements
    IExampleSelector
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: DotnetPrompt.Prompts.ExampleSelectors
    Assembly: DotnetPrompt.dll
    Syntax
    public class LengthBasedExampleSelector : IExampleSelector

    Constructors

    | Improve this Doc View Source

    LengthBasedExampleSelector(IList<IDictionary<string, string>>, IPromptTemplate)

    Declaration
    public LengthBasedExampleSelector(IList<IDictionary<string, string>> examples, IPromptTemplate examplePrompt)
    Parameters
    Type Name Description
    IList<IDictionary<string, string>> examples

    A list of the examples that the prompt template expects.

    IPromptTemplate examplePrompt

    Prompt template used to format the examples.

    Properties

    | Improve this Doc View Source

    GetTextLength

    Function to measure prompt length. Defaults to word count.

    Declaration
    public Func<string, int> GetTextLength { get; init; }
    Property Value
    Type Description
    Func<string, int>
    | Improve this Doc View Source

    MaxLength

    Max length for the prompt, beyond which examples are cut.

    Declaration
    public int MaxLength { get; init; }
    Property Value
    Type Description
    int

    Methods

    | Improve this Doc View Source

    AddExample(IDictionary<string, string>)

    Add new example to store for a key.

    Declaration
    public void AddExample(IDictionary<string, string> example)
    Parameters
    Type Name Description
    IDictionary<string, string> example

    List of examples to select.

    Remarks

    Example should be a dictionary with the keys being the input variables and the values being the values for those input variables.

    | Improve this Doc View Source

    SelectExamples(IDictionary<string, string>)

    Select which examples to use based on the inputs.

    Declaration
    public IList<IDictionary<string, string>> SelectExamples(IDictionary<string, string> inputVariables)
    Parameters
    Type Name Description
    IDictionary<string, string> inputVariables

    List of input variables that should be user for calculation of possible examples

    Returns
    Type Description
    IList<IDictionary<string, string>>

    Implements

    IExampleSelector
    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright 2023 © Pavel «xakpc» Osadchuk for DotnetPrompt