AS AgentScopeAPI 手册 / API Reference

OkHttpTransport

public class OkHttpTransport implements HttpTransport
源码Source io/agentscope/core/model/transport/OkHttpTransport.java:62–498

Ok 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.

源码Source io/agentscope/core/model/transport/OkHttpTransport.java:76–78

OkHttpTransport

public OkHttpTransport(HttpTransportConfig config)

创建新的OkHttpTransport 使用自定义配置。

Create a new OkHttpTransport with custom configuration.

参数Parameters
名称Name类型Type说明Description
configHttpTransportConfig传输层配置。the transport configuration
源码Source io/agentscope/core/model/transport/OkHttpTransport.java:85–88

OkHttpTransport

public OkHttpTransport(OkHttpClient client, HttpTransportConfig config)

初始化 OkHttpTransport 实例。

Create a new OkHttpTransport with an existing OkHttpClient.

参数Parameters
名称Name类型Type说明Description
clientOkHttpClientOkHttpClient 到使用。the OkHttpClient to use
configHttpTransportConfig配置对象(类型 `HttpTransportConfig`)。the transport configuration (used for reference only)
源码Source io/agentscope/core/model/transport/OkHttpTransport.java:99–102

方法详情Method Detail

execute

public HttpResponse execute(HttpRequest request) throws HttpTransportException

设置执行。

Performs the execute operation.

参数Parameters
名称Name类型Type说明Description
requestHttpRequest请求(类型 `HttpRequest`)。The request.
返回Returns HttpResponse
返回HttpResponse。Returns http response.
抛出Throws
源码Source io/agentscope/core/model/transport/OkHttpTransport.java:204–213

stream

public Flux<String> stream(HttpRequest request)

设置流。

Performs the stream operation.

参数Parameters
名称Name类型Type说明Description
requestHttpRequest请求(类型 `HttpRequest`)。The request.
返回Returns Flux<String>
返回Flux。Returns flux.
源码Source io/agentscope/core/model/transport/OkHttpTransport.java:215–311

close

public void close()

关闭连接并释放相关资源。

Releases resources and connections.

源码Source io/agentscope/core/model/transport/OkHttpTransport.java:313–317

getClient

public OkHttpClient getClient()

获取客户端。

Get the underlying OkHttpClient instance.

返回Returns OkHttpClient
返回OkHttpClient。the OkHttpClient
源码Source io/agentscope/core/model/transport/OkHttpTransport.java:326–328

getConfig

public HttpTransportConfig getConfig()

获取传输层配置。

Get the transport configuration.

返回Returns HttpTransportConfig
配置。the configuration
源码Source io/agentscope/core/model/transport/OkHttpTransport.java:335–337

builder

public static Builder builder()
static

创建用于OkHttpTransport的构建器。

Create a new builder for OkHttpTransport.

返回Returns Builder
一种新的构建器实例。a new Builder instance
源码Source io/agentscope/core/model/transport/OkHttpTransport.java:421–423

嵌套类详情Nested Class Detail

Builder

public static class Builder

OkHttpTransport的构建器。位于 io.agentscope.core.model.transport 包。核心成员包括 config、client、build。

Builder for OkHttpTransport.

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.