Skip to content

parser

The base output parser that seeks to mimic the langhain implementation.

BaseOutputParser

Bases: BaseModel, Generic[TTaskInput, TTaskOutput]

The output parser for the page classification system.

Source code in docprompt/tasks/parser.py
class BaseOutputParser(BaseModel, Generic[TTaskInput, TTaskOutput]):
    """The output parser for the page classification system."""

    @abstractmethod
    def from_task_input(
        cls, task_input: TTaskInput
    ) -> "BaseOutputParser[TTaskInput, TTaskOutput]":
        """Create an output parser from the task input."""

    @abstractmethod
    def parse(self, text: str) -> TTaskOutput:
        """Parse the results of the classification task."""

from_task_input(task_input) abstractmethod

Create an output parser from the task input.

Source code in docprompt/tasks/parser.py
@abstractmethod
def from_task_input(
    cls, task_input: TTaskInput
) -> "BaseOutputParser[TTaskInput, TTaskOutput]":
    """Create an output parser from the task input."""

parse(text) abstractmethod

Parse the results of the classification task.

Source code in docprompt/tasks/parser.py
@abstractmethod
def parse(self, text: str) -> TTaskOutput:
    """Parse the results of the classification task."""