Skip to content
English

ReplyPreviewOptions ​

SUPPORT · interface · 类型合同

Settings for createReplyPreview; sink receives every bubble list and is required.

导入 ​

ts
import type { ReplyPreviewOptions } from '@jangts/agent-core/support';
js
/** @typedef {import('@jangts/agent-core/support').ReplyPreviewOptions} ReplyPreviewOptions */

其他公开入口:@jangts/agent-core/support。

定义 ​

ts
interface ReplyPreviewOptions

继承或实现: ReplyPreviewSettings。

字段结构 ​

字段类型必需说明
sink(bubbles: string[]) => void | Promise<void>必需只读。Receives the current bubble list; rejection propagates to the event caller.
rulesreadonly ReplyPreviewRule[]必需见类型定义及调用场景。
render((text: string) => string) | undefined可省略Presentation only; must not authorize, persist or execute a proposal.
maxCharsnumber | undefined可省略Streamed characters tolerated before preview is disabled; default 16000.

成员目录 ​

成员用途
sinkReceives the current bubble list; rejection propagates to the event caller.

成员详情 ​

sink ​

Receives the current bubble list; rejection propagates to the event caller.

ts
ReplyPreviewOptions.sink(bubbles: string[]): void | Promise<void>
参数类型传递说明
bubblesstring[]必需—

返回: void \| Promise<void>。

等待后的值: void。

使用示例 ​

为纯文本阶段增加预览 ​

入门 · Node.js

ts
import { ModelRunner, Support } from '@jangts/agent-core';
const preview = Support.createReplyPreview({ rules: [{ stageId: 'reply' }],
  sink: bubbles => { console.log('preview', bubbles); },
});
const runner = new ModelRunner({ provider: { async *stream() { yield '你好'; yield ',Core'; } }, sink: { output: preview } });
console.log((await runner.invoke({ input: '你好', stageId: 'reply' })).value);
js
import { ModelRunner, Support } from '@jangts/agent-core';
const preview = Support.createReplyPreview({ rules: [{ stageId: 'reply' }],
    sink: bubbles => { console.log('preview', bubbles); },
});
const runner = new ModelRunner({ provider: { async *stream() { yield '你好'; yield ',Core'; } }, sink: { output: preview } });
console.log((await runner.invoke({ input: '你好', stageId: 'reply' })).value);

只允许明确正文协议的可展示字段 ​

配置 · Node.js

规则必须对应 App 实际登记的 reply Tool 与 Schema,配置预览本身不创建模型 Tool。

ts
import { Support } from '@jangts/agent-core';
const preview = Support.createReplyPreview({
  rules: [{ stageId: 'reply', toolId: 'reply', paths: [['answer'], ['bubbles', '*']],
    when: { path: ['kind'], values: ['reply'] } }],
  sink: async bubbles => { console.log('当前暂态正文', bubbles); },
  maxChars: 4000,
});
console.log(typeof preview);
js
import { Support } from '@jangts/agent-core';
const preview = Support.createReplyPreview({
    rules: [{ stageId: 'reply', toolId: 'reply', paths: [['answer'], ['bubbles', '*']],
            when: { path: ['kind'], values: ['reply'] } }],
    sink: async (bubbles) => { console.log('当前暂态正文', bubbles); },
    maxChars: 4000,
});
console.log(typeof preview);

相关定义 ​

接口参考、使用示例与开发指南。