Class ChatSession (1.76.0)

ChatSession(
    model: vertexai.generative_models._generative_models._GenerativeModel,
    *,
    history: typing.Optional[
        typing.List[vertexai.generative_models._generative_models.Content]
    ] = None,
    response_validation: bool = True,
    responder: typing.Optional[
        vertexai.generative_models._generative_models.AutomaticFunctionCallingResponder
    ] = None,
    raise_on_blocked: typing.Optional[bool] = None
)

Chat session holds the chat history.

Methods

send_message

send_message(
    content: PartsType,
    *,
    generation_config: typing.Optional[GenerationConfigType] = None,
    safety_settings: typing.Optional[SafetySettingsType] = None,
    tools: typing.Optional[
        typing.List[vertexai.generative_models._generative_models.Tool]
    ] = None,
    labels: typing.Optional[typing.Dict[str, str]] = None,
    stream: bool = False
) -> typing.Union[
    vertexai.generative_models._generative_models.GenerationResponse,
    typing.Iterable[vertexai.generative_models._generative_models.GenerationResponse],
]

Generates content.

Exceptions
Type Description
ResponseValidationError If the response was blocked or is incomplete.

send_message_async

send_message_async(
    content: PartsType,
    *,
    generation_config: typing.Optional[GenerationConfigType] = None,
    safety_settings: typing.Optional[SafetySettingsType] = None,
    tools: typing.Optional[
        typing.List[vertexai.generative_models._generative_models.Tool]
    ] = None,
    labels: typing.Optional[typing.Dict[str, str]] = None,
    stream: bool = False
) -> typing.Union[
    typing.Awaitable[vertexai.generative_models._generative_models.GenerationResponse],
    typing.Awaitable[
        typing.AsyncIterable[
            vertexai.generative_models._generative_models.GenerationResponse
        ]
    ],
]

Generates content asynchronously.

Exceptions
Type Description
ResponseValidationError If the response was blocked or is incomplete.