[BindServiceMethod(typeof(SessionService), "BindService")]
public abstract class SessionService.SessionServiceBaseReference documentation and code samples for the Gemini Enterprise for Customer Experience v1 API class SessionService.SessionServiceBase.
Base class for server-side implementations of SessionService
Namespace
Google.Cloud.Ces.V1Assembly
Google.Cloud.Ces.V1.dll
Methods
BidiRunSession(IAsyncStreamReader<BidiSessionClientMessage>, IServerStreamWriter<BidiSessionServerMessage>, ServerCallContext)
public virtual Task BidiRunSession(IAsyncStreamReader<BidiSessionClientMessage> requestStream, IServerStreamWriter<BidiSessionServerMessage> responseStream, ServerCallContext context)Establishes a bidirectional streaming connection with the CES agent. The agent processes continuous multimodal inputs (e.g., text, audio) and generates real-time multimodal output streams.
--- Client Request Stream --- The client streams requests in the following order:
Initialization: The first message must contain [SessionConfig][google.cloud.ces.v1.BidiSessionClientMessage.config]. For audio sessions, this should also include [InputAudioConfig][google.cloud.ces.v1.SessionConfig.input_audio_config] and [OutputAudioConfig][google.cloud.ces.v1.SessionConfig.output_audio_config] to define audio processing and synthesis parameters.
Interaction: Subsequent messages stream [SessionInput][google.cloud.ces.v1.BidiSessionClientMessage.realtime_input] containing real-time user input data.
Termination: The client should half-close the stream when there is no more user input. It should also half-close upon receiving [EndSession][google.cloud.ces.v1.BidiSessionServerMessage.end_session] or [GoAway][google.cloud.ces.v1.BidiSessionServerMessage.go_away] from the agent.
--- Server Response Stream --- For each interaction turn, the agent streams messages in the following sequence:
Speech Recognition (First N messages): Contains [RecognitionResult][google.cloud.ces.v1.BidiSessionServerMessage.recognition_result] representing the concatenated user speech segments captured so far. This is only populated for audio sessions.
Response (Next M messages): Contains [SessionOutput][google.cloud.ces.v1.BidiSessionServerMessage.session_output] delivering the agent's response in various modalities (e.g., text, audio).
Turn Completion (Final message of the turn): Contains [SessionOutput][google.cloud.ces.v1.BidiSessionServerMessage.session_output] with [turn_completed][google.cloud.ces.v1.SessionOutput.turn_completed] set to true. This signals the end of the current turn and includes [DiagnosticInfo][google.cloud.ces.v1.SessionOutput.diagnostic_info] with execution details.
--- Audio Best Practices ---
Streaming: Stream [audio data][google.cloud.ces.v1.SessionInput.audio] CONTINUOUSLY, even during silence. Recommended chunk size: 40-120ms (balances latency vs. efficiency).
Playback & Interruption: Play [audio responses][google.cloud.ces.v1.SessionOutput.audio] upon receipt. Stop playback immediately if an [InterruptionSignal][google.cloud.ces.v1.BidiSessionServerMessage.interruption_signal] is received (e.g., user barge-in or new agent response).
| Parameters | |
|---|---|
| Name | Description |
requestStream |
IAsyncStreamReaderBidiSessionClientMessageUsed for reading requests from the client. |
responseStream |
IServerStreamWriterBidiSessionServerMessageUsed for sending responses back to the client. |
context |
ServerCallContextThe context of the server-side call handler being invoked. |
| Returns | |
|---|---|
| Type | Description |
Task |
A task indicating completion of the handler. |
RunSession(RunSessionRequest, ServerCallContext)
public virtual Task<RunSessionResponse> RunSession(RunSessionRequest request, ServerCallContext context)Initiates a single-turn interaction with the CES agent within a session.
| Parameters | |
|---|---|
| Name | Description |
request |
RunSessionRequestThe request received from the client. |
context |
ServerCallContextThe context of the server-side call handler being invoked. |
| Returns | |
|---|---|
| Type | Description |
TaskRunSessionResponse |
The response to send back to the client (wrapped by a task). |
StreamRunSession(RunSessionRequest, IServerStreamWriter<RunSessionResponse>, ServerCallContext)
public virtual Task StreamRunSession(RunSessionRequest request, IServerStreamWriter<RunSessionResponse> responseStream, ServerCallContext context)Initiates a single-turn interaction with the CES agent. Uses server-side streaming to deliver incremental results and partial responses as they are generated.
By default, complete responses (e.g., messages from callbacks or full LLM responses) are sent to the client as soon as they are available. To enable streaming individual text chunks directly from the model, set [enable_text_streaming][google.cloud.ces.v1.SessionConfig.enable_text_streaming] to true.
| Parameters | |
|---|---|
| Name | Description |
request |
RunSessionRequestThe request received from the client. |
responseStream |
IServerStreamWriterRunSessionResponseUsed for sending responses back to the client. |
context |
ServerCallContextThe context of the server-side call handler being invoked. |
| Returns | |
|---|---|
| Type | Description |
Task |
A task indicating completion of the handler. |