ReplyFormatDefinition
KIT · interface · Type contract
A template-bound reply format, matched against per-turn facts.
Import
ts
import type { ReplyFormatDefinition } from '@jangts/agent-core/kits/presentation';js
/** @typedef {import('@jangts/agent-core/kits/presentation').ReplyFormatDefinition} ReplyFormatDefinition */Other public entry points:@jangts/agent-core/types, @jangts/agent-core/kits/presentation, @jangts/agent-core/kits.
Definition
ts
interface ReplyFormatDefinition<Context>Type parameters
| Type parameter | Constraint | Default type |
|---|---|---|
Context | — | unknown |
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Required | Read-only. Stable format id. |
description | string | Required | Read-only. Human-readable statement of the template. |
checks | readonly string[] | Required | Read-only. Check ids this template requires. |
when | (context: Context) => boolean | Required | Read-only. Whether the current turn uses this template. |
Member index
| Member | Purpose |
|---|---|
when | Whether the current turn uses this template. |
Member details
when
Whether the current turn uses this template.
ts
ReplyFormatDefinition.when(context: Context): boolean| Parameter | Type | Passing | Description |
|---|---|---|---|
context | Context | Required | — |
Returns: boolean.
Examples
- Presentation: field ownership and final output: The model fills only the fields it is assigned; fixed text, bound values, and semantic keys are owned by the program.
First compose one piece of generated text
Beginner · 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);Let the program own the explanatory prefix in the same compose
Configuration · 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);