Skip to content
English

ReplyFormatDefinition ​

KIT · interface · 类型合同

A template-bound reply format, matched against per-turn facts.

导入 ​

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

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

定义 ​

ts
interface ReplyFormatDefinition<Context>

泛型参数 ​

类型参数约束默认类型
Context—unknown

字段结构 ​

字段类型必需说明
idstring必需只读。Stable format id.
descriptionstring必需只读。Human-readable statement of the template.
checksreadonly string[]必需只读。Check ids this template requires.
when(context: Context) => boolean必需只读。Whether the current turn uses this template.

成员目录 ​

成员用途
whenWhether the current turn uses this template.

成员详情 ​

when ​

Whether the current turn uses this template.

ts
ReplyFormatDefinition.when(context: Context): boolean
参数类型传递说明
contextContext必需—

返回: boolean。

使用示例 ​

先组合一段生成文本 ​

入门 · 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);

相关策略源码 ​

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