langchain_core.output_parsers.list.CommaSeparatedListOutputParser

Note

CommaSeparatedListOutputParser implements the standard Runnable Interface. 🏃

class langchain_core.output_parsers.list.CommaSeparatedListOutputParser[source]

Bases: ListOutputParser

Parse the output of an LLM call to a comma-separated list.

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.

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[source]

Instructions on how the LLM output should be formatted.

Return type

str

parse(text: str) List[str][source]

Parse the output of an LLM call.

Parameters

text (str) –

Return type

List[str]

parse_iter(text: str) Iterator[Match]

Parse the output of an LLM call.

Parameters

text (str) –

Return type

Iterator[Match]

parse_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

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