Skip to content
English

replyFormatChecks ​

KIT · constant · 运行时值

导入 ​

ts
import { replyFormatChecks } from '@jangts/agent-core/kits/presentation';
js
import { replyFormatChecks } from '@jangts/agent-core/kits/presentation';

其他公开入口:@jangts/agent-core/types、@jangts/agent-core/kits/presentation、@jangts/agent-core/kits。

定义 ​

成员目录 ​

成员用途
bubblesEvery bubble is non-empty and the total (primary text included) stays within the limit.
textBudgetThe joined reply stays within the app's text budget.

成员详情 ​

bubbles ​

Every bubble is non-empty and the total (primary text included) stays within the limit.

ts
replyFormatChecks.bubbles(totalLimit: number): ReplyFormatCheck

Every bubble is non-empty and the total (primary text included) stays within the limit.

参数类型传递说明
totalLimitnumber必需—

返回: ReplyFormatCheck。

返回值结构
字段类型必需说明
idstring必需只读。Stable check id referenced by formats.
descriptionstring必需只读。Human-readable statement of the template requirement.
accepts(bubbles: readonly string[]) => boolean必需只读。Returns whether the reply satisfies this requirement.

textBudget ​

The joined reply stays within the app's text budget.

ts
replyFormatChecks.textBudget(maxChars: number): ReplyFormatCheck

The joined reply stays within the app's text budget.

参数类型传递说明
maxCharsnumber必需—

返回: ReplyFormatCheck。

返回值结构
字段类型必需说明
idstring必需只读。Stable check id referenced by formats.
descriptionstring必需只读。Human-readable statement of the template requirement.
accepts(bubbles: readonly string[]) => boolean必需只读。Returns whether the reply satisfies this requirement.

使用示例 ​

先组合一段生成文本 ​

入门 · Node.js

ts
import { Presentation } from '@jangts/agent-core/kits/presentation';
const outputs = Presentation.defineOutputCatalog([
  { id: 'reply', kind: 'text', fields: [{ id: 'text', owner: 'generated' }] },
]);
console.log(outputs.toModelSchema('reply'));
const output = outputs.compose({ outputId: 'reply', input: { generated: { text: '普通对象即可定义节点。' } } }, { app: {}, signal: new AbortController().signal });
console.log(output.value);
js
import { Presentation } from '@jangts/agent-core/kits/presentation';
const outputs = Presentation.defineOutputCatalog([
    { id: 'reply', kind: 'text', fields: [{ id: 'text', owner: 'generated' }] },
]);
console.log(outputs.toModelSchema('reply'));
const output = outputs.compose({ outputId: 'reply', input: { generated: { text: '普通对象即可定义节点。' } } }, { app: {}, signal: new AbortController().signal });
console.log(output.value);

相同 compose 让程序持有说明前缀 ​

配置 · Node.js

ts
import { Presentation } from '@jangts/agent-core/kits/presentation';
const outputs = Presentation.defineOutputCatalog([
  { id: 'reply', kind: 'master', master: '{{prefix}}{{text}}', fields: [
    { id: 'prefix', owner: 'constant', constantValue: '接口说明:' },
    { id: 'text', owner: 'generated' },
  ] },
]);
console.log(outputs.toModelSchema('reply')); // 只有 text 由模型填写
console.log(outputs.compose({ outputId: 'reply', input: { generated: { text: '普通对象即可定义节点。' } } }, { app: {}, signal: new AbortController().signal }).value);
js
import { Presentation } from '@jangts/agent-core/kits/presentation';
const outputs = Presentation.defineOutputCatalog([
    { id: 'reply', kind: 'master', master: '{{prefix}}{{text}}', fields: [
            { id: 'prefix', owner: 'constant', constantValue: '接口说明:' },
            { id: 'text', owner: 'generated' },
        ] },
]);
console.log(outputs.toModelSchema('reply')); // 只有 text 由模型填写
console.log(outputs.compose({ outputId: 'reply', input: { generated: { text: '普通对象即可定义节点。' } } }, { app: {}, signal: new AbortController().signal }).value);

增加绑定字段和语义键,保持 compose 入口 ​

扩展 · Node.js

ts
import { Presentation } from '@jangts/agent-core/kits/presentation';
const outputs = Presentation.defineOutputCatalog<{ displayName: string }>([
  { id: 'reply', kind: 'record', fields: [
    { id: 'text', owner: 'generated' },
    { id: 'author', owner: 'bound', providerId: 'author' },
    { id: 'tone', owner: 'semantic', providerId: 'tone', semanticKeys: ['brief', 'detailed'] },
  ] },
], { providers: [
  { id: 'author', resolve: (_input, { app }) => app.displayName },
  { id: 'tone', resolve: ({ key }) => key === 'brief' ? '简洁说明' : '详细说明' },
] });
const result = outputs.compose({ outputId: 'reply', input: { generated: { text: '普通对象即可。', tone: 'brief' } } }, { app: { displayName: '示例助手' }, signal: new AbortController().signal });
console.log(result.value);
js
import { Presentation } from '@jangts/agent-core/kits/presentation';
const outputs = Presentation.defineOutputCatalog([
    { id: 'reply', kind: 'record', fields: [
            { id: 'text', owner: 'generated' },
            { id: 'author', owner: 'bound', providerId: 'author' },
            { id: 'tone', owner: 'semantic', providerId: 'tone', semanticKeys: ['brief', 'detailed'] },
        ] },
], { providers: [
        { id: 'author', resolve: (_input, { app }) => app.displayName },
        { id: 'tone', resolve: ({ key }) => key === 'brief' ? '简洁说明' : '详细说明' },
    ] });
const result = outputs.compose({ outputId: 'reply', input: { generated: { text: '普通对象即可。', tone: 'brief' } } }, { app: { displayName: '示例助手' }, signal: new AbortController().signal });
console.log(result.value);

相关策略源码 ​

相关定义 ​

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