用 $.model.complete(Haiku)判斷回應的功能標籤,從角色索引取同標籤對白, 以只增不改的訊息附在使用者訊息之前;失敗一律退回不注入。 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
14 lines
630 B
TypeScript
14 lines
630 B
TypeScript
import type { IndexEntry } from './retrieval'
|
|
|
|
export const MAX_LINE = 80
|
|
|
|
// 注入對話的語氣參考。明說只學語氣,不照抄,也不要提到這份參考。
|
|
export function formatExamples(name: string, entries: readonly IndexEntry[]): string | null {
|
|
if (entries.length === 0) return null
|
|
const lines = entries.map(e => `- 「${e.text.length > MAX_LINE ? e.text.slice(0, MAX_LINE) + '…' : e.text}」`)
|
|
return [
|
|
`以下是「${name}」在類似情境說過的話,只用來掌握她的語氣、用字與節奏。不要照抄,也不要向使用者提到這份參考。`,
|
|
...lines,
|
|
].join('\n')
|
|
}
|