feat(ai): configurable tool-call limit (0=unlimited) + Stop button
Replace the fixed 30-round cap with a Settings value (AiMaxToolRounds, Settings → AI Assistant). 0 = unlimited, for long automation runs left going for hours. The chat's Send button turns into Stop while the agent is running so any run — bounded or unlimited — can be aborted (via the CancellationToken; the loop also checks it each round). Docs: ARCHITECTURE gains the configurable-limit note and a generic "pair with a self-hosted gateway = hardware assistant" usage section (no private endpoints). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -502,6 +502,10 @@ AiChatView(Workspace 的一種 pane,與 SessionPage 並排;工具列 ✨ A
|
||||
- 破壞性 PDU 動作(`pdu_set_port` off / `pdu_power_cycle`)一律 **C# 端彈確認框**(`AiTools.ConfirmAsync` → GUI MessageBox,預設按鈕 No;不信 LLM 自律)。
|
||||
- 所有 AI 工具呼叫寫 **AppLogger** 留跡(`[AI tool] <name> <args>`)。
|
||||
- Serial TX 沿 Phase 9 慣例以 `[AI]` 標色 echo(`SerialBridgeEndpoint.Write`),使用者全程看得到 AI 打了什麼。
|
||||
- **工具呼叫上限可設定**(`AppSettings.AiMaxToolRounds`,Settings → AI Assistant):單次訊息最多鏈幾輪工具的保險,**0 = 無上限**(給放著跑一天的自動化腳本;每輪都燒 token,執行中聊天視窗的 **Stop** 鈕可隨時中止,經 `CancellationToken`)。預設 30。
|
||||
|
||||
**典型應用(搭配自架 OpenAI 相容 gateway = 硬體工程助理):**
|
||||
把 Provider 指向你自己的 LLM gateway(本機 Ollama / LiteLLM / 公司 gateway…),ETTerms 就變成一個能用自然語言操作實體硬體的助理:查/送 serial console 指令、依裝置回應判斷、控制 PDU power-cycle DUT、跑重複性測試序列(工具上限設 0 可長跑)。AI 的 serial TX 以 `[AI]` 顯示在終端機,與手動操作同一條 channel,所見即所得。⚠️ 端點由使用者自帶,發佈版不含任何端點(見下方 Security)。
|
||||
|
||||
**實作選型:** 手寫 `OpenAiChatClient`(HttpClient + System.Text.Json,非串流)+ 手寫 agent loop,**不引入 `Microsoft.Extensions.AI`**——依賴最小、對任意 OpenAI 相容 gateway 相容性自己掌控、無額外 NuGet 演進風險。工具 schema 為手組 JSON(OpenAI function-calling 格式)。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user