|
10 | 10 | import io.github.easy4j.opencode.api.OpenCodeChatClient; |
11 | 11 | import io.github.easy4j.opencode.api.OpenCodeRequestContext; |
12 | 12 | import io.github.easy4j.opencode.api.OpenCodeSseClient; |
| 13 | +import io.github.easy4j.opencode.api.sse.StreamingChatResponse; |
13 | 14 | import lombok.extern.slf4j.Slf4j; |
14 | 15 | import okhttp3.OkHttpClient; |
15 | 16 |
|
@@ -191,7 +192,7 @@ private void runStartupChecks(OpenCodeHttpClientConfig httpConfig, OpenCodeCliCo |
191 | 192 | if (httpConfig.isEnabled() && httpConfig.isStartupCheckEnabled()) { |
192 | 193 | try { |
193 | 194 | httpClient.health(); |
194 | | - log.info("OpenCode HTTP health check passed: {}", httpConfig.getServerUrl()); |
| 195 | + log.info("OpenCode HTTP health check passed: {}", httpConfig.getBaseUrl()); |
195 | 196 | } catch (Exception e) { |
196 | 197 | if (httpConfig.isFailFastOnUnavailable()) { |
197 | 198 | throw new IllegalStateException( |
@@ -242,7 +243,7 @@ private void copyHttpConfig(OpenCodeHttpClientConfig src) { |
242 | 243 | this.config.getHttp().setEnabled(src.isEnabled()); |
243 | 244 | this.config.getHttp().setStartupCheckEnabled(src.isStartupCheckEnabled()); |
244 | 245 | this.config.getHttp().setFailFastOnUnavailable(src.isFailFastOnUnavailable()); |
245 | | - this.config.getHttp().setServerUrl(src.getServerUrl()); |
| 246 | + this.config.getHttp().setBaseUrl(src.getBaseUrl()); |
246 | 247 | this.config.getHttp().setUsername(src.getUsername()); |
247 | 248 | this.config.getHttp().setPassword(src.getPassword()); |
248 | 249 | this.config.getHttp().setConnectTimeoutMillis(src.getConnectTimeoutMillis()); |
@@ -367,25 +368,25 @@ public ChatResponse chatCompletionWithSession(ChatRequest request, String sessio |
367 | 368 | return ChatMessageMapper.toChatResponse(result); |
368 | 369 | } |
369 | 370 |
|
370 | | - public ChatStreamingResponse chatCompletionStream(ChatRequest request, String sessionKey) { |
| 371 | + public StreamingChatResponse chatCompletionStream(ChatRequest request, String sessionKey) { |
371 | 372 | return chatCompletionStream(request, sessionKey, null); |
372 | 373 | } |
373 | 374 |
|
374 | | - public ChatStreamingResponse chatCompletionStream(ChatRequest request, String sessionKey, |
| 375 | + public StreamingChatResponse chatCompletionStream(ChatRequest request, String sessionKey, |
375 | 376 | OpenCodeRequestContext context) { |
376 | 377 | return chatCompletionStream(request, sessionKey, context, null); |
377 | 378 | } |
378 | 379 |
|
379 | 380 | /** |
380 | 381 | * 流式对话,并在订阅启动前绑定增量回调,避免丢失首批分片。 |
381 | 382 | */ |
382 | | - public ChatStreamingResponse chatCompletionStream(ChatRequest request, String sessionKey, |
| 383 | + public StreamingChatResponse chatCompletionStream(ChatRequest request, String sessionKey, |
383 | 384 | OpenCodeRequestContext context, |
384 | 385 | Consumer<String> deltaConsumer) { |
385 | 386 | String sessionId = httpClient.ensureSession(sessionKey, context); |
386 | 387 | PromptRequest promptRequest = ChatMessageMapper.toPromptRequest(request); |
387 | 388 |
|
388 | | - ChatStreamingResponse stream = new ChatStreamingResponse().onDelta(deltaConsumer); |
| 389 | + StreamingChatResponse stream = new StreamingChatResponse().onDelta(deltaConsumer); |
389 | 390 |
|
390 | 391 | OpenCodeSseClient.QueueSubscription subscription = |
391 | 392 | sseClient.subscribeQueueSubscription(context); |
@@ -529,12 +530,6 @@ public OpenCodeChatClient chat() { |
529 | 530 | return chatClient; |
530 | 531 | } |
531 | 532 |
|
532 | | - /** @deprecated 业务聊天请使用 {@link #chat()},这里只保留原始事件订阅兼容入口。 */ |
533 | | - @Deprecated |
534 | | - public OpenCodeSseClient sse() { |
535 | | - return sseClient; |
536 | | - } |
537 | | - |
538 | 533 | public OpenCodeSseClient eventStream() { |
539 | 534 | return sseClient; |
540 | 535 | } |
|
0 commit comments