发布者(Publisher)Runner

Java-friendly wrapper around a Runner. A run is exposed as a Reactive Streams Publisher of events, so Java callers never touch Flow; collect it with AsyncJavaHelpers.collect/forEach or any Reactive Streams consumer. Session management is not a runner concern: to call the session service from Java, create it wrapped in a CompletableFutureSessionService and build the runner with the wrapper's asKotlinSessionService().

类型

Link copied to clipboard
object Companion

属性(Properties)

Link copied to clipboard

函数

Link copied to clipboard

这个“封装后的引擎运行器”(wrapped engine runner)适用于那些已经被转换为 Kotlin 语言的代码。

Link copied to clipboard
open override fun close()

关闭该运行任务(runner),并取消所有待执行的回放操作(rewinds),但不会中断正在进行的运行过程;请先取消相关用户的订阅(subscriptions)。

Link copied to clipboard
fun rewindAsync(userId: String, sessionId: String, rewindBeforeInvocationId: String, coroutineContext: CoroutineContext = EmptyCoroutineContext): CompletableFuture<Void?>

将会话状态恢复到之前的状态。 rewindBeforeInvocationId;参见 Runner.rewindAsync返回的“future”对象只有在“rewind”操作被执行完成后才会完成(即:该“future”对象所代表的操作才会真正执行)。这个“rewind”操作是在调用者的 OpenTelemetry 环境中执行的。 coroutineContext正如……中所提到的那样 `runAsync`.

Link copied to clipboard
fun runAsync(userId: String, sessionId: String, invocationId: String? = null, newMessage: Content? = null, stateDelta: Map<String, Any>? = null, runConfig: RunConfig? = null, coroutineContext: CoroutineContext = EmptyCoroutineContext): Publisher<Event>

运行代理程序,并将其产生的事件数据流式传输出去;设置相关参数。 invocationId 用于恢复被中断的调用。整个运行过程包括工具调用以及订阅者的相关操作。 onNext在……上执行;在……条件下运行 Dispatchers.IO 在本次调用时所处的 OpenTelemetry 环境中(即使用当前的 OpenTelemetry 配置/设置)。 coroutineContext 已添加:pass MDCContext() 从 `kotlin-coroutines-slf4j` 中引入相关组件,以便携带调用者的 MDC(Thread Context)信息;或者使用调度器(dispatcher)来替代传统的 I/O 操作。 Job 在……里面;处于……状态 coroutineContext 该操作没有任何效果,因此应取消通过订阅来执行该任务的行为。

Link copied to clipboard
fun runLive(userId: String, sessionId: String, liveRequestQueue: LiveRequestQueue, runConfig: RunConfig? = null, coroutineContext: CoroutineContext = EmptyCoroutineContext): Publisher<Event>

**实验性功能:** 该功能通过实时连接来运行代理程序,并将整个对话过程中的所有事件数据流式传输出来(详见……)。 Runner.runLive每个订阅都会独立运行,其运行过程会在某个特定条件满足时结束。 liveRequestQueue 如果服务处于关闭状态,或者模型结束了当前的会话,那么订阅也会被取消;取消订阅会断开连接,但队列本身仍然会保持开放状态。 `runAsync`“运行(run)”以及…… onNext 在……上执行;针对……进行处理 Dispatchers.IO不在发送数据到队列的那个线程中;而是在本次调用时所处的 OpenTelemetry 环境中(即当前的 OpenTelemetry 上下文)中。 coroutineContext 已添加;这些工作需要花费较长时间才能完成。 onNext 交给您自己的遗嘱执行人(即您指定的负责执行遗嘱的人)。