Class ChatSession (1.26.0)

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

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

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.