fast-tavern 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +202 -0
- package/dist/index.cjs +647 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +462 -0
- package/dist/index.d.ts +462 -0
- package/dist/index.js +627 -0
- package/dist/index.js.map +1 -0
- package/package.json +31 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
type View = 'user_view' | 'model_view';
|
|
2
|
+
type Target = 'preset' | 'world_book' | 'chat_history' | 'model' | 'user';
|
|
3
|
+
/** 统一的消息角色(引擎内部保留 system) */
|
|
4
|
+
type Role = 'system' | 'user' | 'model';
|
|
5
|
+
interface RegexRule {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
mode: 'always' | 'conditional';
|
|
10
|
+
find_regex: string;
|
|
11
|
+
replace_regex: string;
|
|
12
|
+
targets: ('preset' | 'world_book' | 'chat_history' | 'assistant_response' | 'model' | 'user')[];
|
|
13
|
+
views: (View | 'assistant_view')[];
|
|
14
|
+
placement: 'before_macro' | 'after_macro';
|
|
15
|
+
description?: string;
|
|
16
|
+
min_depth?: number;
|
|
17
|
+
max_depth?: number;
|
|
18
|
+
}
|
|
19
|
+
type WorldbookPosition = 'before_char' | 'after_char' | 'fixed';
|
|
20
|
+
/**
|
|
21
|
+
* 世界书条目(输入)
|
|
22
|
+
* - role 可省略(默认 user)
|
|
23
|
+
* - 只有 position=fixed 才需要 depth
|
|
24
|
+
*/
|
|
25
|
+
type WorldbookEntryInput = {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
enabled: boolean | null;
|
|
29
|
+
mode: 'always' | 'conditional';
|
|
30
|
+
content: string;
|
|
31
|
+
role?: Role;
|
|
32
|
+
position: 'before_char' | 'after_char';
|
|
33
|
+
order: number;
|
|
34
|
+
condition?: string;
|
|
35
|
+
/** slot 条目不使用 depth */
|
|
36
|
+
depth?: never;
|
|
37
|
+
} | {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
enabled: boolean | null;
|
|
41
|
+
mode: 'always' | 'conditional';
|
|
42
|
+
content: string;
|
|
43
|
+
role?: Role;
|
|
44
|
+
position: 'fixed';
|
|
45
|
+
order: number;
|
|
46
|
+
/** fixed 条目必须提供 depth */
|
|
47
|
+
depth: number;
|
|
48
|
+
condition?: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* 世界书条目(引擎内部使用:严格版)
|
|
52
|
+
* - role 必有
|
|
53
|
+
* - slot 条目没有 depth
|
|
54
|
+
* - fixed 条目必须有 depth
|
|
55
|
+
*/
|
|
56
|
+
type WorldbookEntry = (Omit<Extract<WorldbookEntryInput, {
|
|
57
|
+
position: 'before_char' | 'after_char';
|
|
58
|
+
}>, 'role'> & {
|
|
59
|
+
role: Role;
|
|
60
|
+
}) | (Omit<Extract<WorldbookEntryInput, {
|
|
61
|
+
position: 'fixed';
|
|
62
|
+
}>, 'role'> & {
|
|
63
|
+
role: Role;
|
|
64
|
+
});
|
|
65
|
+
/** 世界书(输入文件) */
|
|
66
|
+
interface Worldbook {
|
|
67
|
+
name: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
entries: WorldbookEntryInput[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 兼容外部传入的世界书 JSON。
|
|
73
|
+
* - 既可以传完整 worldbook({name, entries})
|
|
74
|
+
* - 也可以直接传 entries 数组
|
|
75
|
+
*/
|
|
76
|
+
type WorldbookInput = Worldbook | WorldbookEntryInput[] | ({
|
|
77
|
+
entries: WorldbookEntryInput[];
|
|
78
|
+
enabled?: boolean;
|
|
79
|
+
name?: string;
|
|
80
|
+
description?: string;
|
|
81
|
+
id?: string;
|
|
82
|
+
});
|
|
83
|
+
type WorldbooksInput = WorldbookInput | WorldbookInput[];
|
|
84
|
+
/** 预设提示词块(严格版) */
|
|
85
|
+
type PromptBlock = {
|
|
86
|
+
identifier: string;
|
|
87
|
+
name: string;
|
|
88
|
+
enabled: boolean | null;
|
|
89
|
+
role: Role;
|
|
90
|
+
position: 'relative';
|
|
91
|
+
content?: string;
|
|
92
|
+
/** relative 不使用 depth */
|
|
93
|
+
depth?: never;
|
|
94
|
+
/** relative 允许 order(如果你想给 UI 排序用),但组装逻辑不会使用它 */
|
|
95
|
+
order?: number;
|
|
96
|
+
} | {
|
|
97
|
+
identifier: string;
|
|
98
|
+
name: string;
|
|
99
|
+
enabled: boolean | null;
|
|
100
|
+
role: Role;
|
|
101
|
+
position: 'fixed';
|
|
102
|
+
content?: string;
|
|
103
|
+
/** fixed 必须提供 depth */
|
|
104
|
+
depth: number;
|
|
105
|
+
/** 注入排序:同 depth 下按 order 升序(fixed 必填) */
|
|
106
|
+
order: number;
|
|
107
|
+
};
|
|
108
|
+
interface PresetConfig {
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
description: string;
|
|
112
|
+
prompts: PromptBlock[];
|
|
113
|
+
regex_rules?: RegexRule[];
|
|
114
|
+
world_book?: Worldbook;
|
|
115
|
+
}
|
|
116
|
+
interface CharacterCard {
|
|
117
|
+
id: string;
|
|
118
|
+
name: string;
|
|
119
|
+
character_name: string;
|
|
120
|
+
avatar?: string;
|
|
121
|
+
description: string;
|
|
122
|
+
message: string[];
|
|
123
|
+
world_book?: Worldbook;
|
|
124
|
+
regex_rules?: RegexRule[];
|
|
125
|
+
}
|
|
126
|
+
interface TaggedContent {
|
|
127
|
+
tag: string;
|
|
128
|
+
role: Role;
|
|
129
|
+
text: string;
|
|
130
|
+
target: Target;
|
|
131
|
+
}
|
|
132
|
+
interface GeminiPart {
|
|
133
|
+
text: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* “类 Gemini”内部格式。
|
|
137
|
+
* 注意:这里我们保留 system。
|
|
138
|
+
* - 当下游输出格式不支持 system 时,才在输出转换阶段做降级(system -> user)。
|
|
139
|
+
*/
|
|
140
|
+
interface GeminiContent {
|
|
141
|
+
role: Role;
|
|
142
|
+
parts: GeminiPart[];
|
|
143
|
+
}
|
|
144
|
+
interface OpenAIMessage {
|
|
145
|
+
role: 'system' | 'user' | 'assistant';
|
|
146
|
+
content: string;
|
|
147
|
+
}
|
|
148
|
+
interface SimpleMessage {
|
|
149
|
+
role: 'system' | 'user' | 'assistant' | 'model';
|
|
150
|
+
text: string;
|
|
151
|
+
}
|
|
152
|
+
type MessageInput = string | string[] | GeminiContent[] | OpenAIMessage[] | SimpleMessage[] | TaggedContent[];
|
|
153
|
+
type MessageFormat = 'auto' | 'gemini' | 'openai' | 'simple' | 'tagged' | 'text';
|
|
154
|
+
/**
|
|
155
|
+
* 兼容外部传入的正则 JSON。
|
|
156
|
+
* - RegexRule[]
|
|
157
|
+
* - { regex_rules: RegexRule[] }
|
|
158
|
+
* - { rules: RegexRule[] }
|
|
159
|
+
* - RegexRule
|
|
160
|
+
* - 以上任意形式的数组(多文件)
|
|
161
|
+
*/
|
|
162
|
+
type RegexesFileInput = RegexRule[] | {
|
|
163
|
+
regex_rules: RegexRule[];
|
|
164
|
+
} | {
|
|
165
|
+
rules: RegexRule[];
|
|
166
|
+
} | RegexRule;
|
|
167
|
+
type RegexesInput = RegexesFileInput | RegexesFileInput[];
|
|
168
|
+
/**
|
|
169
|
+
* 明确的“聊天记录入口”。
|
|
170
|
+
* 设计目标:调用方一眼能看出自己传的是什么格式,而不是依赖 auto 推断。
|
|
171
|
+
*/
|
|
172
|
+
type HistoryInput = {
|
|
173
|
+
format: 'gemini';
|
|
174
|
+
messages: GeminiContent[];
|
|
175
|
+
} | {
|
|
176
|
+
format: 'openai';
|
|
177
|
+
messages: OpenAIMessage[];
|
|
178
|
+
} | {
|
|
179
|
+
format: 'simple';
|
|
180
|
+
messages: SimpleMessage[];
|
|
181
|
+
} | {
|
|
182
|
+
format: 'tagged';
|
|
183
|
+
messages: TaggedContent[];
|
|
184
|
+
} | {
|
|
185
|
+
format: 'text';
|
|
186
|
+
text: string | string[];
|
|
187
|
+
} | {
|
|
188
|
+
format: 'auto';
|
|
189
|
+
input: MessageInput;
|
|
190
|
+
};
|
|
191
|
+
interface PromptStages<T> {
|
|
192
|
+
/** 原始视图:仅完成组装,尚未进入正则/宏管道 */
|
|
193
|
+
raw: T;
|
|
194
|
+
/** 宏前正则完视图:已执行 placement=before_macro 的正则 */
|
|
195
|
+
afterPreRegex: T;
|
|
196
|
+
/** 宏执行完视图:已完成宏替换(位于两段正则之间) */
|
|
197
|
+
afterMacro: T;
|
|
198
|
+
/** 宏后正则完视图(最终视图):已执行 placement=after_macro 的正则 */
|
|
199
|
+
afterPostRegex: T;
|
|
200
|
+
}
|
|
201
|
+
interface PerItemStages {
|
|
202
|
+
tag: string;
|
|
203
|
+
role: Role;
|
|
204
|
+
target: Target;
|
|
205
|
+
raw: string;
|
|
206
|
+
afterPreRegex: string;
|
|
207
|
+
afterMacro: string;
|
|
208
|
+
afterPostRegex: string;
|
|
209
|
+
}
|
|
210
|
+
interface BuildPromptParams {
|
|
211
|
+
preset: PresetConfig;
|
|
212
|
+
character?: CharacterCard;
|
|
213
|
+
globals?: {
|
|
214
|
+
/**
|
|
215
|
+
* 全局世界书(可选)。
|
|
216
|
+
* 允许一次性传入多个世界书 JSON(多文件),内部会拼接 entries 后使用。
|
|
217
|
+
*/
|
|
218
|
+
worldbooks?: WorldbooksInput;
|
|
219
|
+
/**
|
|
220
|
+
* 全局正则(可选)。
|
|
221
|
+
* 允许一次性传入多个正则 JSON(多文件),内部会拼接 rules 后使用。
|
|
222
|
+
*/
|
|
223
|
+
regexes?: RegexesInput;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* 聊天记录入口(推荐传 HistoryInput,使格式明确)。
|
|
227
|
+
* 兼容:你也可以直接传 MessageInput + historyFormat。
|
|
228
|
+
*/
|
|
229
|
+
history: HistoryInput | MessageInput;
|
|
230
|
+
/** 当 history 直接传 MessageInput 时,用该字段声明格式;默认 auto */
|
|
231
|
+
historyFormat?: MessageFormat;
|
|
232
|
+
/** 输出格式;默认:跟随输入(若输入为 auto,则跟随检测到的格式) */
|
|
233
|
+
outputFormat?: Exclude<MessageFormat, 'auto'> | 'tagged';
|
|
234
|
+
/**
|
|
235
|
+
* system 角色输出策略(仅影响最终 output / stages.output)。
|
|
236
|
+
* - keep: 保留 system
|
|
237
|
+
* - to_user: 将 system 降级为 user(用于下游不接受 system 的渠道)
|
|
238
|
+
*/
|
|
239
|
+
systemRolePolicy?: 'keep' | 'to_user';
|
|
240
|
+
/** 用于宏替换,例如 { char: 'Alice', user: 'Bob' } */
|
|
241
|
+
macros: Record<string, string>;
|
|
242
|
+
/** 选择正则视图 */
|
|
243
|
+
view: View;
|
|
244
|
+
options?: {
|
|
245
|
+
/** 世界书匹配上下文使用最近几条聊天历史;默认 5 */
|
|
246
|
+
recentHistoryForWorldbook?: number;
|
|
247
|
+
/**
|
|
248
|
+
* 世界书 position 到 preset block.identifier 的映射。
|
|
249
|
+
* - before_char / after_char 属于插槽条目
|
|
250
|
+
* - fixed 不参与映射(它是注入到 chatHistory 的)
|
|
251
|
+
*/
|
|
252
|
+
positionMap?: Partial<Record<'before_char' | 'after_char', string>>;
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
interface BuildPromptResult {
|
|
256
|
+
detectedHistoryFormat: Exclude<MessageFormat, 'auto'>;
|
|
257
|
+
outputFormat: Exclude<MessageFormat, 'auto'> | 'tagged';
|
|
258
|
+
systemRolePolicy: 'keep' | 'to_user';
|
|
259
|
+
/** 世界书激活结果 */
|
|
260
|
+
activeWorldbookEntries: WorldbookEntry[];
|
|
261
|
+
/** 合并后的正则规则(global + preset + character) */
|
|
262
|
+
mergedRegexRules: RegexRule[];
|
|
263
|
+
/**
|
|
264
|
+
* 不同处理阶段的提示词(用于调试/预览)。
|
|
265
|
+
* 约定阶段:
|
|
266
|
+
* - raw:原始视图
|
|
267
|
+
* - afterPreRegex:宏前正则完视图
|
|
268
|
+
* - afterMacro:宏执行完视图
|
|
269
|
+
* - afterPostRegex:宏后正则完视图(最终视图)
|
|
270
|
+
*/
|
|
271
|
+
stages: {
|
|
272
|
+
/** 每个片段都带 tag/target,最适合用于 UI 展示 */
|
|
273
|
+
tagged: PromptStages<TaggedContent[]>;
|
|
274
|
+
/** 内部统一后的“类 Gemini”格式(role: system/user/model) */
|
|
275
|
+
internal: PromptStages<GeminiContent[]>;
|
|
276
|
+
/** 按 outputFormat 转换后的输出 */
|
|
277
|
+
output: PromptStages<GeminiContent[] | OpenAIMessage[] | SimpleMessage[] | TaggedContent[] | string>;
|
|
278
|
+
/** 单条文本的阶段明细(更细粒度,便于定位某条规则/宏造成的变化) */
|
|
279
|
+
perItem: PerItemStages[];
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
declare function detectMessageFormat(input: MessageInput): Exclude<MessageFormat, 'auto'>;
|
|
284
|
+
|
|
285
|
+
declare function isTextInput(v: unknown): v is string | string[];
|
|
286
|
+
declare function toInternalFromText(input: string | string[]): GeminiContent[];
|
|
287
|
+
declare function fromInternalToText(internal: GeminiContent[]): string;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* 将任意输入历史统一转换为 GeminiContent[](role 只保留 user/model)。
|
|
291
|
+
* - openai: system/user -> user, assistant -> model
|
|
292
|
+
* - simple: system/user -> user, assistant/model -> model
|
|
293
|
+
*/
|
|
294
|
+
declare function convertMessagesIn(input: MessageInput, format?: MessageFormat): {
|
|
295
|
+
detected: Exclude<MessageFormat, 'auto'>;
|
|
296
|
+
internal: GeminiContent[];
|
|
297
|
+
};
|
|
298
|
+
declare function convertMessagesOut(internal: GeminiContent[], format: Exclude<MessageFormat, 'auto'>): GeminiContent[] | OpenAIMessage[] | SimpleMessage[] | string;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* 帮助你创建“明确格式”的 history 入参,避免依赖 auto 推断。
|
|
302
|
+
*/
|
|
303
|
+
declare const History: {
|
|
304
|
+
readonly gemini: (messages: Extract<HistoryInput, {
|
|
305
|
+
format: "gemini";
|
|
306
|
+
}>["messages"]) => HistoryInput;
|
|
307
|
+
readonly openai: (messages: Extract<HistoryInput, {
|
|
308
|
+
format: "openai";
|
|
309
|
+
}>["messages"]) => HistoryInput;
|
|
310
|
+
readonly simple: (messages: Extract<HistoryInput, {
|
|
311
|
+
format: "simple";
|
|
312
|
+
}>["messages"]) => HistoryInput;
|
|
313
|
+
readonly tagged: (messages: Extract<HistoryInput, {
|
|
314
|
+
format: "tagged";
|
|
315
|
+
}>["messages"]) => HistoryInput;
|
|
316
|
+
readonly text: (text: Extract<HistoryInput, {
|
|
317
|
+
format: "text";
|
|
318
|
+
}>["text"]) => HistoryInput;
|
|
319
|
+
readonly auto: (input: MessageInput) => HistoryInput;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
declare function isHistoryInput(v: unknown): v is HistoryInput;
|
|
323
|
+
/**
|
|
324
|
+
* 用于兼容:当调用方没有使用 HistoryInput,而是直接传了 MessageInput 时,
|
|
325
|
+
* 可通过该函数统一推断/声明其格式。
|
|
326
|
+
*/
|
|
327
|
+
declare function normalizeHistoryFormat(format?: MessageFormat): MessageFormat;
|
|
328
|
+
|
|
329
|
+
declare function testCondition(condition: string | undefined, text: string): boolean;
|
|
330
|
+
|
|
331
|
+
declare function getActiveEntries(params: {
|
|
332
|
+
contextText?: string;
|
|
333
|
+
/** 已归一化后的全局世界书 entries */
|
|
334
|
+
globalEntries?: WorldbookEntry[];
|
|
335
|
+
presetWorldbook?: Worldbook;
|
|
336
|
+
characterWorldbook?: Worldbook;
|
|
337
|
+
}): WorldbookEntry[];
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* 复刻你当前 store 里的 applyRegex 行为(含 target 映射逻辑)。
|
|
341
|
+
*/
|
|
342
|
+
declare function applyRegex(text: string, params: {
|
|
343
|
+
rules: RegexRule[];
|
|
344
|
+
target: Target;
|
|
345
|
+
view: View;
|
|
346
|
+
placement?: 'before_macro' | 'after_macro';
|
|
347
|
+
}): string;
|
|
348
|
+
|
|
349
|
+
declare function mergeRegexRules(params: {
|
|
350
|
+
/** 全局正则规则(可选) */
|
|
351
|
+
globalRules?: RegexRule[];
|
|
352
|
+
/** 预设内嵌正则 */
|
|
353
|
+
presetRules?: RegexRule[];
|
|
354
|
+
/** 角色卡内嵌正则 */
|
|
355
|
+
characterRules?: RegexRule[];
|
|
356
|
+
}): RegexRule[];
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* 简单宏替换。
|
|
360
|
+
* 兼容:{{char}} {{user}} <<user>>
|
|
361
|
+
* 同时支持传入任意 key:{{key}}
|
|
362
|
+
*/
|
|
363
|
+
declare function replaceMacros(text: string, macros: Record<string, string>): string;
|
|
364
|
+
|
|
365
|
+
declare function assembleTaggedPromptList(params: {
|
|
366
|
+
presetBlocks: PromptBlock[];
|
|
367
|
+
activeEntries: WorldbookEntry[];
|
|
368
|
+
/** 线性聊天历史(允许包含 system) */
|
|
369
|
+
chatHistory: Array<{
|
|
370
|
+
role: Role;
|
|
371
|
+
text: string;
|
|
372
|
+
}>;
|
|
373
|
+
positionMap?: Partial<Record<'before_char' | 'after_char', string>>;
|
|
374
|
+
}): TaggedContent[];
|
|
375
|
+
|
|
376
|
+
declare function processContentStages(text: string, params: {
|
|
377
|
+
target: Target;
|
|
378
|
+
view: View;
|
|
379
|
+
rules: RegexRule[];
|
|
380
|
+
macros: Record<string, string>;
|
|
381
|
+
}): Pick<PerItemStages, 'raw' | 'afterPreRegex' | 'afterMacro' | 'afterPostRegex'>;
|
|
382
|
+
|
|
383
|
+
declare function compileTaggedStages(tagged: TaggedContent[], params: {
|
|
384
|
+
view: View;
|
|
385
|
+
rules: RegexRule[];
|
|
386
|
+
macros: Record<string, string>;
|
|
387
|
+
}): {
|
|
388
|
+
stages: PromptStages<TaggedContent[]>;
|
|
389
|
+
perItem: PerItemStages[];
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* 兼容用户一次性传入多个“正则 JSON 文件”的情况。
|
|
394
|
+
* 支持格式:
|
|
395
|
+
* - RegexRule[]
|
|
396
|
+
* - { regex_rules: RegexRule[] }
|
|
397
|
+
* - { rules: RegexRule[] }
|
|
398
|
+
* - RegexRule
|
|
399
|
+
* - 以上任意形式的数组(多文件)
|
|
400
|
+
*/
|
|
401
|
+
declare function normalizeRegexes(input?: RegexesInput): RegexRule[];
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* 兼容用户一次性传入多个“世界书 JSON 文件”的情况。
|
|
405
|
+
* 支持格式:
|
|
406
|
+
* - Worldbook({ name, entries })
|
|
407
|
+
* - WorldbookEntryInput[]
|
|
408
|
+
* - 以上任意形式的数组(多文件)
|
|
409
|
+
*/
|
|
410
|
+
declare function normalizeWorldbooks(input?: WorldbooksInput): WorldbookEntry[];
|
|
411
|
+
|
|
412
|
+
declare function buildPrompt(params: BuildPromptParams): BuildPromptResult;
|
|
413
|
+
|
|
414
|
+
declare function isGeminiContents(v: unknown): v is GeminiContent[];
|
|
415
|
+
declare function toInternalFromGemini(input: GeminiContent[]): GeminiContent[];
|
|
416
|
+
declare function fromInternalToGemini(internal: GeminiContent[]): GeminiContent[];
|
|
417
|
+
|
|
418
|
+
declare function isOpenAIMessages(v: unknown): v is OpenAIMessage[];
|
|
419
|
+
/**
|
|
420
|
+
* openai: system/user/assistant 都保留。
|
|
421
|
+
* - assistant -> model(内部)
|
|
422
|
+
*/
|
|
423
|
+
declare function toInternalFromOpenAI(input: OpenAIMessage[]): GeminiContent[];
|
|
424
|
+
declare function fromInternalToOpenAI(internal: GeminiContent[]): OpenAIMessage[];
|
|
425
|
+
|
|
426
|
+
declare function isSimpleMessages(v: unknown): v is SimpleMessage[];
|
|
427
|
+
/**
|
|
428
|
+
* simple: 保留 system/user;assistant/model -> model(内部)。
|
|
429
|
+
*/
|
|
430
|
+
declare function toInternalFromSimple(input: SimpleMessage[]): GeminiContent[];
|
|
431
|
+
declare function fromInternalToSimple(internal: GeminiContent[]): SimpleMessage[];
|
|
432
|
+
|
|
433
|
+
declare function isTaggedContents(v: unknown): v is TaggedContent[];
|
|
434
|
+
declare function toInternalFromTagged(input: TaggedContent[]): GeminiContent[];
|
|
435
|
+
/**
|
|
436
|
+
* 注意:tagged 的“反向转换”没有足够信息恢复 tag/target。
|
|
437
|
+
* 所以 fromInternal 只能退化成 simple 或文本。
|
|
438
|
+
* buildPrompt() 会在 outputFormat='tagged' 时直接返回 taggedStages,而不是走 convertMessagesOut。
|
|
439
|
+
*/
|
|
440
|
+
declare function fromInternalToTagged(_internal: GeminiContent[]): TaggedContent[];
|
|
441
|
+
|
|
442
|
+
declare const index_detectMessageFormat: typeof detectMessageFormat;
|
|
443
|
+
declare const index_fromInternalToGemini: typeof fromInternalToGemini;
|
|
444
|
+
declare const index_fromInternalToOpenAI: typeof fromInternalToOpenAI;
|
|
445
|
+
declare const index_fromInternalToSimple: typeof fromInternalToSimple;
|
|
446
|
+
declare const index_fromInternalToTagged: typeof fromInternalToTagged;
|
|
447
|
+
declare const index_fromInternalToText: typeof fromInternalToText;
|
|
448
|
+
declare const index_isGeminiContents: typeof isGeminiContents;
|
|
449
|
+
declare const index_isOpenAIMessages: typeof isOpenAIMessages;
|
|
450
|
+
declare const index_isSimpleMessages: typeof isSimpleMessages;
|
|
451
|
+
declare const index_isTaggedContents: typeof isTaggedContents;
|
|
452
|
+
declare const index_isTextInput: typeof isTextInput;
|
|
453
|
+
declare const index_toInternalFromGemini: typeof toInternalFromGemini;
|
|
454
|
+
declare const index_toInternalFromOpenAI: typeof toInternalFromOpenAI;
|
|
455
|
+
declare const index_toInternalFromSimple: typeof toInternalFromSimple;
|
|
456
|
+
declare const index_toInternalFromTagged: typeof toInternalFromTagged;
|
|
457
|
+
declare const index_toInternalFromText: typeof toInternalFromText;
|
|
458
|
+
declare namespace index {
|
|
459
|
+
export { index_detectMessageFormat as detectMessageFormat, index_fromInternalToGemini as fromInternalToGemini, index_fromInternalToOpenAI as fromInternalToOpenAI, index_fromInternalToSimple as fromInternalToSimple, index_fromInternalToTagged as fromInternalToTagged, index_fromInternalToText as fromInternalToText, index_isGeminiContents as isGeminiContents, index_isOpenAIMessages as isOpenAIMessages, index_isSimpleMessages as isSimpleMessages, index_isTaggedContents as isTaggedContents, index_isTextInput as isTextInput, index_toInternalFromGemini as toInternalFromGemini, index_toInternalFromOpenAI as toInternalFromOpenAI, index_toInternalFromSimple as toInternalFromSimple, index_toInternalFromTagged as toInternalFromTagged, index_toInternalFromText as toInternalFromText };
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
export { type BuildPromptParams, type BuildPromptResult, index as Channels, type CharacterCard, type GeminiContent, type GeminiPart, History, type HistoryInput, type MessageFormat, type MessageInput, type OpenAIMessage, type PerItemStages, type PresetConfig, type PromptBlock, type PromptStages, type RegexRule, type RegexesFileInput, type RegexesInput, type Role, type SimpleMessage, type TaggedContent, type Target, type View, type Worldbook, type WorldbookEntry, type WorldbookEntryInput, type WorldbookInput, type WorldbookPosition, type WorldbooksInput, applyRegex, assembleTaggedPromptList, buildPrompt, compileTaggedStages, convertMessagesIn, convertMessagesOut, detectMessageFormat, getActiveEntries, isHistoryInput, isTextInput, mergeRegexRules, normalizeHistoryFormat, normalizeRegexes, normalizeWorldbooks, processContentStages, replaceMacros, testCondition };
|