dataclass_parser#

DataClassParser will help users convert a dataclass to prompt

Classes

DataClassParser(data_class[, ...])

This is similar to Dspy's signature but more controllable and flexible.

class DataClassParser(data_class: DataClass, return_data_class: bool = False, format_type: Literal['yaml', 'json'] = 'json')[source]#

Bases: Component

This is similar to Dspy’s signature but more controllable and flexible.

get_input_format_str() str[source]#

Return the formatted instructions to use in prompt for the input format.

get_output_format_str() str[source]#

Return the formatted instructions to use in prompt for the output format.

get_input_str(input: DataClass) str[source]#

Return the formatted input string.

get_task_desc_str() str[source]#

Return the task description string.

get_examples_str(examples: List[DataClass], include: List[str] | Dict[str, List[str]] | None = None, exclude: List[str] | Dict[str, List[str]] | None = None) str[source]#

Return the examples string.

call(input: str) Any[source]#

Parse the output string to the desired format and return the parsed output.