Class to parse the output of an LLM call into a dictionary.

Hierarchy (view full)

  • Toolkit<Record<string, string>>
    • RegexParser



outputKeys: string[]
regex: string | RegExp
defaultOutputKey?: string


  • Returns a string with instructions on how the LLM output should be formatted to match the regex pattern.

    Returns string

    A string with formatting instructions.

  • Parses the given text using the regex pattern and returns a dictionary with the parsed output. If the regex pattern does not match the text and no defaultOutputKey is provided, throws an OutputParserException.


    • text: string

      The text to be parsed.

    Returns Promise<Record<string, string>>

    A dictionary with the parsed output.