Skip to content
中文

ReplyDeliveryOptions ​

KIT · interface · Type contract

Host-controlled delivery of already validated text; not upstream model generation.

Import ​

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

Other public entry points:@jangts/agent-core, @jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/events, @jangts/agent-core/kits/presentation, @jangts/agent-core/kits.

Definition ​

ts
interface ReplyDeliveryOptions

Field structure ​

FieldTypeRequiredDescription
chunkSizenumber | undefinedOptionalCharacters per emitted text event; defaults to 240 and must be a positive integer.
intervalMsnumber | undefinedOptionalDelay between chunks in milliseconds; defaults to 0.
bubblePauseMsnumber | undefinedOptionalDelay between bubbles in milliseconds; defaults to 0.
maxDurationMsnumber | undefinedOptionalUpper bound on intentional pacing time; backpressure and network time are independent.

Examples ​

First output a reply that is already accepted ​

Beginner · Node.js

ts
import { Presentation } from '@jangts/agent-core/kits/presentation';
const context = { signal: new AbortController().signal };
for await (const event of Presentation.publishReplyEvents({ text: '这是已经接受的答复。' }, context)) console.log(event);
js
import { Presentation } from '@jangts/agent-core/kits/presentation';
const context = { signal: new AbortController().signal };
for await (const event of Presentation.publishReplyEvents({ text: '这是已经接受的答复。' }, context))
    console.log(event);

Add chunking and bubbles to the same event entry ​

Configuration · Node.js

ts
import { Presentation } from '@jangts/agent-core/kits/presentation';
const text = Presentation.replyBubbleTexts({ text: '先说明定义。', bubbles: ['再解释输入输出。'] }).join(Presentation.REPLY_BUBBLE_BOUNDARY);
const events = Presentation.publishReplyEvents({ text, delivery: { chunkSize: 6, intervalMs: 10, bubblePauseMs: 30, maxDurationMs: 1000 } }, { signal: new AbortController().signal });
for await (const event of events) {
  if (event.type === 'text') process.stdout.write(event.text);
  else if (event.type === 'bubble') process.stdout.write('\n');
}
js
import { Presentation } from '@jangts/agent-core/kits/presentation';
const text = Presentation.replyBubbleTexts({ text: '先说明定义。', bubbles: ['再解释输入输出。'] }).join(Presentation.REPLY_BUBBLE_BOUNDARY);
const events = Presentation.publishReplyEvents({ text, delivery: { chunkSize: 6, intervalMs: 10, bubblePauseMs: 30, maxDurationMs: 1000 } }, { signal: new AbortController().signal });
for await (const event of events) {
    if (event.type === 'text')
        process.stdout.write(event.text);
    else if (event.type === 'bubble')
        process.stdout.write('\n');
}

API reference, usage examples and developer guides.