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).

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 text: str = ''#

SHOULD NOT BE SET DIRECTLY The text contents of the output message.

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

Type is used exclusively for serialization purposes.

Examples using ChatGeneration