mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-06-10 11:17:00 +08:00
Fix: 超时时间参数映射
This commit is contained in:
@@ -47,9 +47,8 @@ public class DnJsonTransport implements Transport, Callback {
|
||||
Request dnJsonRequest = buildDnJsonRequest(config, request);
|
||||
|
||||
client = new okhttp3.OkHttpClient.Builder()
|
||||
.connectTimeout(config.getTimeout())
|
||||
.readTimeout(config.getTimeout())
|
||||
.writeTimeout(config.getTimeout())
|
||||
.connectTimeout(config.getConnectTimeout())
|
||||
.readTimeout(config.getReadTimeout())
|
||||
.build();
|
||||
|
||||
this.listener.onStart(pipeline.getContext());
|
||||
|
||||
@@ -30,8 +30,8 @@ public class HttpTransport implements Transport {
|
||||
public ChatResponse startBlocking(ChatConfig config, ChatRequest request, ChunkProcessPipeline pipeline) {
|
||||
try (HttpUtil httpUtil = HttpUtil
|
||||
.builder()
|
||||
.connectTimeout(config.getTimeout())
|
||||
.readTimeout(config.getTimeout())
|
||||
.connectTimeout(config.getConnectTimeout())
|
||||
.readTimeout(config.getReadTimeout())
|
||||
.build()) {
|
||||
// 构建请求体
|
||||
String requestBody = buildRequestBody(config, request);
|
||||
|
||||
@@ -45,9 +45,8 @@ public class SseTransport extends EventSourceListener implements Transport {
|
||||
|
||||
// 创建EventSource实例
|
||||
client = new okhttp3.OkHttpClient.Builder()
|
||||
.connectTimeout(config.getTimeout())
|
||||
.readTimeout(config.getTimeout())
|
||||
.writeTimeout(config.getTimeout())
|
||||
.connectTimeout(config.getConnectTimeout())
|
||||
.readTimeout(config.getReadTimeout())
|
||||
.build();
|
||||
|
||||
this.eventSource = EventSources.createFactory(client)
|
||||
|
||||
@@ -30,7 +30,9 @@ public class ModelConfig implements RequestBodyConvertible, RequestHeaderConvert
|
||||
|
||||
protected String model;
|
||||
|
||||
protected Duration timeout = Duration.ofSeconds(60);
|
||||
protected Duration connectTimeout = Duration.ofSeconds(60);
|
||||
|
||||
protected Duration readTimeout = Duration.ofSeconds(60);
|
||||
|
||||
protected Map<String, Object> headersConfig = new LinkedHashMap<>();
|
||||
|
||||
@@ -47,7 +49,8 @@ public class ModelConfig implements RequestBodyConvertible, RequestHeaderConvert
|
||||
String apiKey,
|
||||
String provider,
|
||||
String model,
|
||||
Duration timeout,
|
||||
Duration connectTimeout,
|
||||
Duration readTimeout,
|
||||
Map<String, Object> headersConfig
|
||||
) {
|
||||
this.apiUrl = apiUrl;
|
||||
@@ -55,7 +58,8 @@ public class ModelConfig implements RequestBodyConvertible, RequestHeaderConvert
|
||||
this.apiKey = apiKey;
|
||||
this.provider = provider;
|
||||
this.model = model;
|
||||
this.timeout = timeout;
|
||||
this.connectTimeout = connectTimeout;
|
||||
this.readTimeout = readTimeout;
|
||||
this.headersConfig = headersConfig;
|
||||
}
|
||||
|
||||
@@ -65,7 +69,8 @@ public class ModelConfig implements RequestBodyConvertible, RequestHeaderConvert
|
||||
this.apiKey = builder.apiKey;
|
||||
this.provider = builder.provider;
|
||||
this.model = builder.model;
|
||||
this.timeout = builder.timeout;
|
||||
this.connectTimeout = builder.connectTimeout;
|
||||
this.readTimeout = builder.readTimeout;
|
||||
this.headersConfig.putAll(builder.headersConfig);
|
||||
}
|
||||
|
||||
@@ -133,12 +138,20 @@ public class ModelConfig implements RequestBodyConvertible, RequestHeaderConvert
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public Duration getTimeout() {
|
||||
return timeout;
|
||||
public Duration getConnectTimeout() {
|
||||
return connectTimeout;
|
||||
}
|
||||
|
||||
public void setTimeout(Duration timeout) {
|
||||
this.timeout = timeout;
|
||||
public void setConnectTimeout(Duration connectTimeout) {
|
||||
this.connectTimeout = connectTimeout;
|
||||
}
|
||||
|
||||
public Duration getReadTimeout() {
|
||||
return readTimeout;
|
||||
}
|
||||
|
||||
public void setReadTimeout(Duration readTimeout) {
|
||||
this.readTimeout = readTimeout;
|
||||
}
|
||||
|
||||
public Map<String, Object> getHeadersConfig() {
|
||||
@@ -168,7 +181,9 @@ public class ModelConfig implements RequestBodyConvertible, RequestHeaderConvert
|
||||
|
||||
protected String model;
|
||||
|
||||
protected Duration timeout = Duration.ofSeconds(60);
|
||||
protected Duration connectTimeout = Duration.ofSeconds(60);
|
||||
|
||||
protected Duration readTimeout = Duration.ofSeconds(60);
|
||||
|
||||
protected Map<String, Object> headersConfig = new LinkedHashMap<>();
|
||||
|
||||
@@ -199,8 +214,13 @@ public class ModelConfig implements RequestBodyConvertible, RequestHeaderConvert
|
||||
return self();
|
||||
}
|
||||
|
||||
public B timeout(Duration timeout) {
|
||||
this.timeout = timeout;
|
||||
public B connectTimeout(Duration connectTimeout) {
|
||||
this.connectTimeout = connectTimeout;
|
||||
return self();
|
||||
}
|
||||
|
||||
public B readTimeout(Duration readTimeout) {
|
||||
this.readTimeout = readTimeout;
|
||||
return self();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,13 +34,14 @@ public class ChatConfig extends ModelConfig {
|
||||
String apiKey,
|
||||
String provider,
|
||||
String model,
|
||||
Duration timeout,
|
||||
Duration connectTimeout,
|
||||
Duration readTimeout,
|
||||
Map<String, Object> headersConfig,
|
||||
boolean autoToolCallEnabled,
|
||||
boolean streaming,
|
||||
TransportType transportType
|
||||
) {
|
||||
super(apiUrl, endPoint, apiKey, provider, model, timeout, headersConfig);
|
||||
super(apiUrl, endPoint, apiKey, provider, model, connectTimeout, readTimeout, headersConfig);
|
||||
this.autoToolCallEnabled = autoToolCallEnabled;
|
||||
this.streaming = streaming;
|
||||
this.transportType = transportType;
|
||||
|
||||
@@ -25,13 +25,14 @@ public class OllamaChatConfig extends ChatConfig {
|
||||
String apiKey,
|
||||
String provider,
|
||||
String model,
|
||||
Duration timeout,
|
||||
Duration connectTimeout,
|
||||
Duration readTimeout,
|
||||
Map<String, Object> headersConfig,
|
||||
boolean autoToolCallEnabled,
|
||||
boolean streaming,
|
||||
TransportType transportType
|
||||
) {
|
||||
super(apiUrl, endPoint, apiKey, provider, model, timeout,
|
||||
super(apiUrl, endPoint, apiKey, provider, model, connectTimeout, readTimeout,
|
||||
headersConfig, autoToolCallEnabled, streaming, transportType);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@ public class OllamaModelTest {
|
||||
.provider(OllamaConstant.PROVIDER_NAME)
|
||||
.model("qwen3:32b")
|
||||
.streaming(false)
|
||||
.timeout(Duration.of(10, ChronoUnit.MINUTES))
|
||||
.connectTimeout(Duration.of(10, ChronoUnit.MINUTES))
|
||||
.readTimeout(Duration.of(10, ChronoUnit.MINUTES))
|
||||
.transportType(TransportType.HTTP)
|
||||
.build();
|
||||
|
||||
@@ -93,7 +94,8 @@ public class OllamaModelTest {
|
||||
.provider(OllamaConstant.PROVIDER_NAME)
|
||||
.model("qwen3:32b")
|
||||
.streaming(true)
|
||||
.timeout(Duration.of(10, ChronoUnit.MINUTES))
|
||||
.connectTimeout(Duration.of(10, ChronoUnit.MINUTES))
|
||||
.readTimeout(Duration.of(10, ChronoUnit.MINUTES))
|
||||
.transportType(TransportType.DnJson)
|
||||
.build();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user