langchain_community.output_parsers.ernie_functions.JsonOutputFunctionsParser

Note

JsonOutputFunctionsParser implements the standard Runnable Interface. 🏃

class langchain_community.output_parsers.ernie_functions.JsonOutputFunctionsParser[source]

Bases: BaseCumulativeTransformOutputParser[Any]

Parse an output as the Json 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 diff: bool = False

In streaming mode, whether to yield diffs between the previous and current parsed output, or just the current parsed output.

param strict: bool = False

Whether to allow non-JSON-compliant strings.

See: https://docs.python.org/3/library/json.html#encoders-and-decoders

Useful when the parsed output may include unicode characters or new lines.

async aparse(text: str) T

Parse a single string model output into some structure.

Parameters

text (str) – String output of a language model.

Returns

Structured output.

Return type

T

async aparse_result(result: List[Generation], *, partial: bool = False) T

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

The return value is parsed from only the first Generation in the result, which

is assumed to be the highest-likelihood Generation.

Parameters
  • result (List[Generation]) – A list of Generations to be parsed. The Generations are assumed to be different candidate outputs for a single model input.

  • partial (bool) –

Returns

Structured output.

Return type

T

get_format_instructions() str

Instructions on how the LLM output should be formatted.

Return type

str

parse(text: str) Any[source]

Parse a single string model output into some structure.

Parameters

text (str) – String output of a language model.

Returns

Structured output.

Return type

Any

parse_result(result: List[Generation], *, partial: bool = False) Any[source]

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

The return value is parsed from only the first Generation in the result, which

is assumed to be the highest-likelihood Generation.

Parameters
  • result (List[Generation]) – A list of Generations to be parsed. The Generations are assumed to be different candidate outputs for a single model input.

  • partial (bool) –

Returns

Structured output.

Return type

Any

parse_with_prompt(completion: str, prompt: PromptValue) Any

Parse the output of an LLM call with the input prompt for context.

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 (str) – String output of a language model.

  • prompt (PromptValue) – Input PromptValue.

Returns

Structured output

Return type

Any