Class BaseOutputParser<T>

java.lang.Object
com.hw.langchain.schema.BaseLLMOutputParser<T>
com.hw.langchain.schema.BaseOutputParser<T>
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AgentOutputParser, ListOutputParser, NoOpOutputParser, StructuredOutputParser, StructuredQueryOutputParser

public abstract class BaseOutputParser<T> extends BaseLLMOutputParser<T>
Class to parse the output of an LLM call. Output parsers help structure language model responses.
Author:
HamaWhite
See Also:
  • Constructor Details

    • BaseOutputParser

      public BaseOutputParser()
  • Method Details

    • parseResult

      public T parseResult(List<? extends Generation> result)
      Description copied from class: BaseLLMOutputParser
      Parse LLM Result.
      Specified by:
      parseResult in class BaseLLMOutputParser<T>
    • parse

      public abstract T parse(String text)
      Parse the output of an LLM call. A method which takes in a string (assumed output of a language model) and parses it into some structure.
      Parameters:
      text - output of language model
      Returns:
      structured output
    • parseWithPrompt

      public Object parseWithPrompt(String completion, PromptValue prompt)
      Optional method to parse the output of an LLM call with a prompt. The prompt is largely provided in the event the OutputParser wants to retry or fix the output in some way, and needs information from the prompt to do so.
      Parameters:
      completion - output of language model
      prompt - prompt value
      Returns:
      structured output
    • getFormatInstructions

      public String getFormatInstructions()
      Instructions on how the LLM output should be formatted.
      Returns:
      format instructions