Class ChatSession (1.28.1)

ChatSession(
    model: vertexai.language_models._language_models.ChatModel,
    context: typing.Optional[str] = None,
    examples: typing.Optional[
        typing.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: typing.Optional[
        typing.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.

Properties

message_history

List of previous messages.

Methods

send_message

send_message(
    message: str,
    *,
    max_output_tokens: typing.Optional[int] = None,
    temperature: typing.Optional[float] = None,
    top_k: typing.Optional[int] = None,
    top_p: typing.Optional[float] = None
) -> vertexai.language_models._language_models.TextGenerationResponse

Sends message to the language model and gets a response.