OkHttpTransport
public class OkHttpTransport implements HttpTransport
io/agentscope/core/model/transport/OkHttpTransport.java:62–498Ok HTTP 传输层,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.core.model.transport 包,实现 HttpTransport。核心成员包括 execute、stream、close、getClient、getConfig、builder。
OkHttp implementation of the HttpTransport interface.
This implementation uses OkHttp for HTTP communication and supports:
-
Synchronous HTTP requests
-
Server-Sent Events (SSE) streaming
-
Connection pooling
-
Configurable timeouts
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | OkHttpTransport的构建器。 Builder for OkHttpTransport. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public OkHttpTransport() | 创建新的OkHttpTransport 使用默认配置。 Create a new OkHttpTransport with default configuration. |
public OkHttpTransport(HttpTransportConfig config) | 创建新的OkHttpTransport 使用自定义配置。 Create a new OkHttpTransport with custom configuration. |
public OkHttpTransport(OkHttpClient client, HttpTransportConfig config) | 初始化 `OkHttpTransport` 实例。 Create a new OkHttpTransport with an existing OkHttpClient. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public HttpResponse execute(HttpRequest request) throws HttpTransportException | 设置执行。 Performs the execute operation. |
public Flux<String> stream(HttpRequest request) | 设置流。 Performs the stream operation. |
public void close() | 关闭连接并释放相关资源。 Releases resources and connections. |
public OkHttpClient getClient() | 获取客户端。 Get the underlying OkHttpClient instance. |
public HttpTransportConfig getConfig() | 获取传输层配置。 Get the transport configuration. |
public static Builder builder()static | 创建用于OkHttpTransport的构建器。 Create a new builder for OkHttpTransport. |
构造器详情Constructor Detail
OkHttpTransport
public OkHttpTransport()
创建新的OkHttpTransport 使用默认配置。
Create a new OkHttpTransport with default configuration.
io/agentscope/core/model/transport/OkHttpTransport.java:76–78OkHttpTransport
public OkHttpTransport(HttpTransportConfig config)
创建新的OkHttpTransport 使用自定义配置。
Create a new OkHttpTransport with custom configuration.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
config | HttpTransportConfig | 传输层配置。the transport configuration |
io/agentscope/core/model/transport/OkHttpTransport.java:85–88OkHttpTransport
public OkHttpTransport(OkHttpClient client, HttpTransportConfig config)
初始化 OkHttpTransport 实例。
Create a new OkHttpTransport with an existing OkHttpClient.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
client | OkHttpClient | OkHttpClient 到使用。the OkHttpClient to use |
config | HttpTransportConfig | 配置对象(类型 `HttpTransportConfig`)。the transport configuration (used for reference only) |
io/agentscope/core/model/transport/OkHttpTransport.java:99–102方法详情Method Detail
execute
public HttpResponse execute(HttpRequest request) throws HttpTransportException
设置执行。
Performs the execute operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
request | HttpRequest | 请求(类型 `HttpRequest`)。The request. |
HttpResponseHttpTransportException可能抛出 `HttpTransportException`。Thrown when the operation cannot be completed.
io/agentscope/core/model/transport/OkHttpTransport.java:204–213stream
public Flux<String> stream(HttpRequest request)
设置流。
Performs the stream operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
request | HttpRequest | 请求(类型 `HttpRequest`)。The request. |
Flux<String>io/agentscope/core/model/transport/OkHttpTransport.java:215–311close
public void close()
关闭连接并释放相关资源。
Releases resources and connections.
io/agentscope/core/model/transport/OkHttpTransport.java:313–317getClient
public OkHttpClient getClient()
获取客户端。
Get the underlying OkHttpClient instance.
OkHttpClientio/agentscope/core/model/transport/OkHttpTransport.java:326–328getConfig
public HttpTransportConfig getConfig()
获取传输层配置。
Get the transport configuration.
HttpTransportConfigio/agentscope/core/model/transport/OkHttpTransport.java:335–337builder
public static Builder builder()
创建用于OkHttpTransport的构建器。
Create a new builder for OkHttpTransport.
Builderio/agentscope/core/model/transport/OkHttpTransport.java:421–423嵌套类详情Nested Class Detail
Builder
public static class BuilderOkHttpTransport的构建器。位于 io.agentscope.core.model.transport 包。核心成员包括 config、client、build。
Builder for OkHttpTransport.