langchain.output_parsers.openai_functions.PydanticOutputFunctionsParser

class langchain.output_parsers.openai_functions.PydanticOutputFunctionsParser(*, args_only: bool = True, pydantic_schema: Union[Type[BaseModel], Dict[str, Type[BaseModel]]])[source]

Bases: OutputFunctionsParser

Parse an output as a pydantic object.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param args_only: bool = True

Whether to only return the arguments to the function call.

param pydantic_schema: Union[Type[pydantic.main.BaseModel], Dict[str, Type[pydantic.main.BaseModel]]] [Required]

The pydantic schema to parse the output with.

invoke(input: str | langchain.schema.messages.BaseMessage, config: langchain.schema.runnable.RunnableConfig | None = None) T
parse_result(result: List[Generation]) Any[source]

Parse a list of candidate model Generations into a specific format.

Parameters

result – A list of Generations to be parsed. The Generations are assumed to be different candidate outputs for a single model input.

Returns

Structured output.

to_json() Union[SerializedConstructor, SerializedNotImplemented]
to_json_not_implemented() SerializedNotImplemented
validator validate_schema  »  all fields[source]
property lc_attributes: Dict

Return a list of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor.

property lc_namespace: List[str]

Return the namespace of the langchain object. eg. [“langchain”, “llms”, “openai”]

property lc_secrets: Dict[str, str]

Return a map of constructor argument names to secret ids. eg. {“openai_api_key”: “OPENAI_API_KEY”}

property lc_serializable: bool

Return whether or not the class is serializable.

model Config

Bases: object

extra = 'ignore'