feat: 完成 F 群組 — 對話生成管線與 LLM Provider 抽象

- LLMProvider 介面(generate/stream)+ LLM_PROVIDER 切換(llm.module.ts useFactory,
  LLM_PROVIDER=mock|claude 環境變數決定注入哪個實作)
- MockProvider:依性格原型 × 情緒狀態 × 親密度從模板庫選填回應,seeded PRNG 確保同 seed 可重現,
  支援 *動作描寫* 標記抽取(目前只有元氣原型模板,G 群組需補齊其餘五種原型)
- ClaudeProvider 空殼:LLM_PROVIDER=claude 時啟動即輸出 ERR log,呼叫 generate/stream 時拋出例外
- OutputFilterService:全域+角色禁則詞彙過濾(攔截並改寫)
- FastChannelDetector:固定問候與危險輸入(含求助資源)走快速通道,跳過記憶檢索
- BehaviorReinforcementService:稱讚加權、糾正後修正版繼承舊權重以確保排序領先(實作時抓到並修正一個
  「降權後打平」的真實 bug)
- ContextAssemblerService:組裝人設/情緒/關係/檢索記憶/對話歷史為統一上下文快照
- DialogueService/Controller:串起以上所有元件,作為 H-1 正式對話端點的基礎
- scripts/smoke/F.mjs:涵蓋可重現性、上下文快照完整性、雙速通道、行為強化、輸出過濾、
  以 child process 驗證 Provider 切換

npm run restart && npm run smoke -- F 皆通過(F-V),A/B/C/D/E 群組冒煙測試無回歸。
This commit is contained in:
Jeffery
2026-08-13 10:56:45 +08:00
parent 767b17e257
commit caf45f69e1
18 changed files with 761 additions and 9 deletions
@@ -0,0 +1,19 @@
import { Injectable } from "@nestjs/common";
import type { LLMProvider } from "./llm-provider.js";
import type { GenerationContext, GeneratedResponse } from "./types.js";
const NOT_IMPLEMENTED_MESSAGE = "ClaudeProvider 尚未實作(R-3 會接上真實 Claude API)";
// F-2 ClaudeProvider 空殼:R-3 才會實作真實呼叫,目前僅回報未實作。
@Injectable()
export class ClaudeProvider implements LLMProvider {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async generate(_context: GenerationContext): Promise<GeneratedResponse> {
throw new Error(NOT_IMPLEMENTED_MESSAGE);
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars, require-yield
async *stream(_context: GenerationContext): AsyncIterable<string> {
throw new Error(NOT_IMPLEMENTED_MESSAGE);
}
}