Skip to content

Hsi431/taiwan-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Taiwan Filter for OpenClaw

受夠中國模型不受控制的簡體字輸出了嘛?試試這個吧!

Taiwan Filter 是一個小型 OpenClaw extension,用來把助理輸出強制轉成「台灣繁體中文」與台灣常用詞彙,並在生成前提醒模型預設使用台灣語境。

它會在 prompt 組裝階段加入台灣語境指引,並在模型輸出、OpenClaw 對外送出訊息前、dispatch 前,以及 assistant 訊息寫入 transcript 前執行轉換。也就是說,就算模型本身混入簡體字,最後輸出仍會被轉成繁體。

功能

  • 強制把助理輸出的簡體中文轉成繁體中文。
  • 提醒模型預設使用台灣語境,避免無意識套用中國大陸用語、地點、制度與敘事習慣。
  • 使用 OpenCC 的 s2twp.json,偏向台灣用字與詞彙。
  • 攔截 OpenClaw 的 before_prompt_buildllm_outputmessage_sendingbefore_dispatchbefore_message_write hooks。
  • 處理常見文字欄位:textcontentoutput_textthinking

取捨

這是強制轉換版,不是單純 prompt guidance。

優點:

  • 不依賴模型自己的指令遵從度。
  • 對不穩定、容易偷跑簡體的模型比較有效。
  • 沒指定語境時,會把生成方向拉回台灣脈絡。

代價:

  • 引用文字、命令輸出、log、code block、語言樣本也可能被轉換。
  • 如果你需要保留簡體原文,這個 extension 不適合直接啟用。
  • 台灣語境指引不是禁詞系統;如果使用者明確要求中國大陸脈絡,模型仍可正常討論。

安裝

Node.js 版本需求:18+(建議 22+)

把這個 extension 目錄放到 OpenClaw extensions 路徑:

~/.openclaw/extensions/taiwan-filter

安裝 dependency:

npm install

~/.openclaw/openclaw.json 啟用:

{
  "plugins": {
    "allow": ["taiwan-filter"],
    "entries": {
      "taiwan-filter": {
        "enabled": true,
        "config": {}
      }
    }
  }
}

修改 plugin 設定後,重啟 OpenClaw Gateway。

驗證

確認 OpenClaw 有載入 extension:

openclaw plugins info taiwan-filter

預期看到的 typed hooks:

before_dispatch
before_message_write
before_prompt_build
llm_output
message_sending

開發

檢查 TypeScript 語法:

node --check index.ts  # 需要先 npm install

或使用 tsc(需要已安裝 TypeScript):

npx tsc --noEmit

檢查 hook 註冊:

node --input-type=module -e "const mod=await import('./index.ts'); const hooks={}; const api={on:(name,fn)=>hooks[name]=fn,logger:{info:()=>{}}}; mod.default.register(api); console.log(Object.keys(hooks).sort().join(','));"

預期輸出:

before_dispatch,before_message_write,before_prompt_build,llm_output,message_sending

檢查轉換效果:

node --input-type=module -e "const mod=await import('./index.ts'); const hooks={}; const api={on:(name,fn)=>hooks[name]=fn,logger:{info:()=>{}}}; mod.default.register(api); console.log(hooks.message_sending({content:'软件里面输出简体字,发现过滤没生效。'}).content);"

預期輸出:

軟體裡面輸出簡體字,發現過濾沒生效。

授權

MIT

About

Taiwan Output Filter for OpenClaw - 引導助理輸出台灣繁體中文的輕量插件

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors