Class ChatSession (1.26.1)

ChatSession(
    model: vertexai.language_models._language_models.ChatModel,
    context: Optional[str] = None,
    examples: Optional[
        List[vertexai.language_models._language_models.InputOutputTextPair]
    ] = None,
    max_output_tokens: int = 128,
    temperature: float = 0.0,
    top_k: int = 40,
    top_p: float = 0.95,
    message_history: Optional[
        List[vertexai.language_models._language_models.ChatMessage]
    ] = None,
)

ChatSession represents a chat session with a language model.

Within a chat session, the model keeps context and remembers the previous conversation.

Inheritance

builtins.object > vertexai.language_models._language_models._ChatSessionBase > ChatSession

Properties

message_history

List of previous messages.

Methods

send_message

send_message(
    message: str,
    *,
    max_output_tokens: Optional[int] = None,
    temperature: Optional[float] = None,
    top_k: Optional[int] = None,
    top_p: Optional[float] = None
)

Sends message to the language model and gets a response.