langchain.schema.output.LLMResult¶
- class langchain.schema.output.LLMResult(*, generations: List[List[Generation]], llm_output: Optional[dict] = None, run: Optional[List[RunInfo]] = None)[source]¶
Bases:
BaseModelClass that contains all results for a batched LLM call.
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 generations: List[List[langchain.schema.output.Generation]] [Required]¶
List of generated outputs. This is a List[List[]] because each input could have multiple candidate generations.
- param llm_output: Optional[dict] = None¶
Arbitrary LLM provider-specific output.
- param run: Optional[List[langchain.schema.output.RunInfo]] = None¶
List of metadata info for model call for each input.
- flatten() List[LLMResult][source]¶
Flatten generations into a single list.
- Unpack List[List[Generation]] -> List[LLMResult] where each returned LLMResult
contains only a single Generation. If token usage information is available, it is kept only for the LLMResult corresponding to the top-choice Generation, to avoid over-counting of token usage downstream.
- Returns
- List of LLMResults where each returned LLMResult contains a single
Generation.