public class StreamingChatResponse extends CompletableFuture<String>
CompletableFuture.AsynchronousCompletionTask| Constructor and Description |
|---|
StreamingChatResponse() |
| Modifier and Type | Method and Description |
|---|---|
void |
acceptDelta(String delta)
追加一段文本增量并通知已注册的增量消费者。
|
boolean |
cancel(boolean mayInterruptIfRunning)
取消当前异步操作或 SSE 订阅。
|
void |
fail(Throwable error)
以给定异常结束流式响应。
|
void |
finish()
以当前累计文本正常完成流式响应。
|
String |
getAccumulatedContent()
通过 OpenCode Server HTTP API 获取累计的流式文本。
|
StreamingChatResponse |
onCancel(Runnable action)
绑定底层 EventSource 取消动作。
|
StreamingChatResponse |
onDelta(Consumer<String> consumer)
注册文本增量消费者;后续到达的增量按接收顺序同步通知该消费者。
|
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, complete, completedFuture, completeExceptionally, exceptionally, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, obtrudeException, obtrudeValue, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsyncpublic StreamingChatResponse onDelta(Consumer<String> consumer)
consumer - 事件或文本增量消费者;不得为 nullpublic void acceptDelta(String delta)
delta - 本次到达的文本增量;为空时忽略public void finish()
public void fail(Throwable error)
error - 导致流式响应失败的异常public String getAccumulatedContent()
public StreamingChatResponse onCancel(Runnable action)
action - 取消时执行的回调;不得为 nullCopyright © 2026. All rights reserved.