ChatGeneration#

class langchain_core.outputs.chat_generation.ChatGeneration[source]#

Bases: Generation

A single chat generation output.

A subclass of Generation that represents the response from a chat model that generates chat messages.

The message attribute is a structured representation of the chat message. Most of the time, the message will be of type AIMessage.

Users working with chat models will usually access information via either AIMessage (returned from runnable interfaces) or LLMResult (available via callbacks).

Initialize a Generation.

param generation_info: dict[str, Any] | None = None#

Raw response from the provider.

May include things like the reason for finishing or token log probabilities.

param message: BaseMessage [Required]#

The message output by the chat model.

param type: Literal['ChatGeneration'] = 'ChatGeneration'#

Type is used exclusively for serialization purposes.

property text: str#

Set the text attribute to be the contents of the message.

Examples using ChatGeneration