类 GeminiLlmConnection
java.lang.Object
com.google.adk.models.GeminiLlmConnection
- All Implemented Interfaces:
BaseLlmConnection
通过 WebSockets 管理与 Gemini 模型的持久性、双向连接,以实现实时交互。
该连接支持发送对话记录、单条消息、功能响应以及实时媒体数据(例如音频片段),同时能够持续接收来自模型的响应。
-
方法概述
Modifier and TypeMethodDescriptionvoidclose()关闭连接。void以错误状态关闭连接。io.reactivex.rxjava3.core.Flowable<LlmResponse> receive()接收模型的响应结果。io.reactivex.rxjava3.core.CompletablesendContent(com.google.genai.types.Content content) 将用户生成的内容发送给模型。io.reactivex.rxjava3.core.CompletablesendContent(com.google.genai.types.Content content, boolean partial) 将用户内容发送给模型;同时可以选择让当前轮次保持开放状态,以便用户继续添加更多内容。io.reactivex.rxjava3.core.CompletablesendHistory(List<com.google.genai.types.Content> history) 发送history如果视频没有音频内容,那么这样的直播环节就无法被重新播放(即无法被回放)。_adk_live这些工件引用(artifact references)无法被模型解析(model cannot resolve them)。io.reactivex.rxjava3.core.CompletablesendRealtime(com.google.genai.types.Blob blob) 实时将一段音频或一帧视频数据发送给模型。
-
方法详细信息(Method Details)
-
sendHistory
public io.reactivex.rxjava3.core.Completable sendHistory(List<com.google.genai.types.Content> history) 发送history如果视频没有音频内容,那么这样的直播环节就无法被重新播放(即无法被回放)。_adk_live模型无法解析的工件引用(artifact references)。模型会完成当前轮次的处理,并只有在剩余的对话历史记录以用户的操作(user turn)结束时才会给出答案。- Specified by:
sendHistoryin interfaceBaseLlmConnection
-
sendContent
public io.reactivex.rxjava3.core.Completable sendContent(com.google.genai.types.Content content) 描述内容复制自接口文档:BaseLlmConnection将用户生成的内容发送给模型。该模型在接收到内容后会立即作出响应。如果您发送的是函数响应(function responses),那么内容中的所有部分都必须是函数响应。
- Specified by:
sendContentin interfaceBaseLlmConnection
-
sendContent
public io.reactivex.rxjava3.core.Completable sendContent(com.google.genai.types.Content content, boolean partial) 描述内容复制自接口文档:BaseLlmConnection将用户内容发送给模型;同时可以选择让当前轮次保持开放状态,以便用户继续添加更多内容。默认的实现会忽略这一点。
partial并调用(相关函数或方法)BaseLlmConnection.sendContent(Content)仅由函数返回的结果组成的内容,总是以“工具响应”(tool response)的形式被发送出去。- Specified by:
sendContentin interfaceBaseLlmConnection- Parameters:
content- the content to sendpartial- whether this content is a partial update that does not complete the current turn
-
sendRealtime
public io.reactivex.rxjava3.core.Completable sendRealtime(com.google.genai.types.Blob blob) 描述内容复制自接口文档:BaseLlmConnection实时将一段音频或一帧视频数据发送给模型。该模型在接收到数据后可能不会立即做出响应。它会先进行语音活动检测,然后决定何时再作出回应。
- Specified by:
sendRealtimein interfaceBaseLlmConnection
-
receive
-
close
public void close()描述内容复制自接口文档:BaseLlmConnection关闭连接。- Specified by:
closein interfaceBaseLlmConnection
-
close
-