Skip to content

Output parser

Defines a base class for output parsers used in Gen AI applications.

Authors

Henry Wicaksono (henry.wicaksono@gdplabs.id)

References

NONE

BaseOutputParser

Bases: ABC, Generic[T]

A base class for output parsers used in Gen AI applications.

The BaseOutputParser class defines the interface for parsing the output of language models. Subclasses must implement the parse method to process and extract meaningful data from the raw output.

parse(result) abstractmethod

Parses the raw output string from the language model.

This abstract method must be implemented by subclasses to define how the result is parsed and processed.

Parameters:

Name Type Description Default
result str

The raw output string from the language model.

required

Returns:

Name Type Description
T T

The parsed result of type T.

Raises:

Type Description
NotImplementedError

If the method is not implemented in a subclass.