From 9c84ec69c503b7e609442e0173614669c3be052c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Sun, 15 Nov 2026 20:00:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=9C=AC=E6=A9=9F=E6=88=96?= =?UTF-8?q?=E5=8D=80=E7=B6=B2=E7=9A=84=E6=A8=A1=E5=9E=8B=E7=9C=8B=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E5=9C=96=E6=99=82=EF=BC=8C=E5=8F=AF=E4=BB=A5=E8=AB=8B?= =?UTF-8?q?=E9=9B=B2=E7=AB=AF=E6=A8=A1=E5=9E=8B=E7=9C=8B=E6=88=AA=E5=9C=96?= =?UTF-8?q?=E5=92=8C=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 設定 › 模型 › 本機或區網的供應商(Ollama、這個網路或 Tailscale 上的伺服器)多一個 「看不到圖時,請雲端模型看截圖和附件」,預設關。關著時跟以前一樣,圖片只找本機的看圖 小幫手;打開後,那個供應商的 Bot 看不到的圖會送給帳號裡看得懂圖的雲端模型(例如 xAI Grok)描述成文字。 用哈士奇(Tailscale 上的 OpenAI 相容服務,模型不收圖)實測計算機題:沒開 59 步、225 秒還讀不到答案;打開後 7 步、118 秒答對。8 題各 4 次 32/32 成功。 也把「is not a multimodal model」認成模型不收圖的錯誤。 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun --- docs/feature-map/chat.md | 1 + docs/feature-map/settings.md | 2 +- src/app.rs | 7 ++++++ src/i18n_table.rs | 2 ++ src/model.rs | 5 ++++ src/providers.rs | 45 +++++++++++++++++++++++++++++++++--- 6 files changed, 58 insertions(+), 4 deletions(-) diff --git a/docs/feature-map/chat.md b/docs/feature-map/chat.md index 18bc280..fa71000 100644 --- a/docs/feature-map/chat.md +++ b/docs/feature-map/chat.md @@ -40,5 +40,6 @@ - 問題卡只在 AnyBot 裡出現:訊息管道(Slack、Telegram…)來的對話沒有 `ask_person`;例行任務裡等人回答(或允許)超過 15 分鐘,那次執行會被結束。密碼、卡號、驗證碼不要用問題卡問。 - 使用者不按卡片、直接在輸入框打字送出,問題卡就算沒回答,Bot 照打的字做。 - `react` 按在使用者最近一則自己寫的訊息上;例行任務、別的 Bot 叫醒的訊息不算。 +- 模型看不到圖(「看圖小幫手」):截圖和附件改請帳號裡看得懂圖的模型描述成文字。Bot 用的是本機或區網的模型(Ollama、這個網路或 Tailscale 上的伺服器)時,圖片預設不送出去,只找同樣在本機的;要送給雲端模型(例如 Grok),在 設定 › 模型 › 那個供應商 打開「看不到圖時,請雲端模型看截圖和附件」。沒有幫手時 Bot 只拿到「看不到圖片」的說明,只能用編號清單和文字做。 - `look_image` 要帳號裡有看得懂圖的模型。對話太長時 AnyBot 會先把圖片拿掉(「對話太長了,先拿掉 N 張截圖再試一次…」),拿掉的看不回來,要重新截圖或請使用者再傳。 - 生活卡片的 link 要是 http 或 https 開頭才會顯示。 diff --git a/docs/feature-map/settings.md b/docs/feature-map/settings.md index d02428f..64bc1e6 100644 --- a/docs/feature-map/settings.md +++ b/docs/feature-map/settings.md @@ -12,7 +12,7 @@ - Bot:時區,例行任務和提醒用([routines](routines.md))。 - 帳戶:「登入」或「管理帳戶」打開「手機與帳號」頁;資料放在哪。 - 「手機與帳號」頁(從 一般 › 帳戶 進去,[phone](phone.md)):「AnyBot 帳號」(登入、備份、還原)、大腦和「加一台電腦」([computers](computers.md))、「同一個網路直接連」、「手機可以做什麼」、「直接連線的裝置」、「分享給團隊」([team](team.md))、「帳號裡的電腦」。 -- 「模型」:每家 AI 供應商的 API 金鑰、服務網址、新 Bot 預設模型、「測試連線並取得模型清單」([bots](bots.md))。 +- 「模型」:每家 AI 供應商的 API 金鑰、服務網址、新 Bot 預設模型、「測試連線並取得模型清單」([bots](bots.md));本機或區網的供應商多一個「看不到圖時,請雲端模型看截圖和附件」(預設關,[chat](chat.md))。 - 「整合」,三個小分頁: - 訊息管道:Slack、Discord、Telegram、Teams…([channels](channels.md))。 - 連接器:「連接器(MCP)」清單、「可以用的工具」、「連接器市集」、「新增連接器」([connectors](connectors.md))。 diff --git a/src/app.rs b/src/app.rs index 4b162b3..d943023 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1553,6 +1553,7 @@ impl App { crate::profile::trim_tools(&b, &mut tool_specs); // 看圖小幫手: the person's models that may see pictures, for a bot whose model can't. providers::set_eyes(self.eyes()); + providers::set_cloud_eyes_for(ALL_PROVIDERS.into_iter().filter(|k| self.state.provider(*k).cloud_eyes).map(|k| providers::resolve_base(k, &self.state.provider(k).base_url)).collect()); let req = ChatRequest { kind: b.provider, base_url: providers::resolve_base(b.provider, &ps.base_url), @@ -5147,6 +5148,12 @@ impl App { changed |= ui.add(egui::TextEdit::singleline(&mut ps.base_url).hint_text(k.default_base_url()).desired_width(w)).changed(); field_label(ui, "新 Bot 預設模型", p); changed |= ui.add(egui::TextEdit::singleline(&mut ps.default_model).hint_text(k.suggested_model()).desired_width(w)).changed(); + // 看圖小幫手 for a local or LAN model: off, its pictures never leave. + if providers::is_local_model(k, &providers::resolve_base(k, &ps.base_url)) { + ui.add_space(8.0); + changed |= ui.checkbox(&mut ps.cloud_eyes, t("看不到圖時,請雲端模型看截圖和附件")).changed(); + hint(ui, "這是本機或區網的模型,圖片預設不會離開。打開後,它看不到的截圖和附件會送給你設定好的雲端模型(例如 xAI Grok)看,換成文字描述給它。", p); + } let count = ps.known_models.len(); if changed { self.dirty = true; diff --git a/src/i18n_table.rs b/src/i18n_table.rs index af19cd0..6f5123a 100644 --- a/src/i18n_table.rs +++ b/src/i18n_table.rs @@ -179,6 +179,8 @@ pub const ROWS: &[(&str, &str, &str)] = &[ ("新增", "Add", "追加"), ("新增規則", "Add rule", "ルールを追加"), ("測試連線並取得模型清單", "Test connection and fetch models", "接続をテストしてモデル一覧を取得"), + ("看不到圖時,請雲端模型看截圖和附件", "When it can't see pictures, let a cloud model look at screenshots and attachments", "画像が見られないとき、スクリーンショットと添付をクラウドのモデルに見てもらう"), + ("這是本機或區網的模型,圖片預設不會離開。打開後,它看不到的截圖和附件會送給你設定好的雲端模型(例如 xAI Grok)看,換成文字描述給它。", "This model runs on this computer or your network, so pictures stay here by default. Turned on, the screenshots and attachments it can't see go to a cloud model you've set up (such as xAI Grok), which describes them in words.", "このモデルはこのコンピュータかローカルネットワーク上にあるため、画像は既定では外に出ません。オンにすると、見られないスクリーンショットや添付は設定済みのクラウドモデル(xAI Grok など)に送られ、文章で説明されます。"), ("重新傳送", "Send again", "再送信"), ("複製", "Copy", "コピー"), ("引用", "Quote", "引用"), diff --git a/src/model.rs b/src/model.rs index cf3ba04..7dd6d51 100644 --- a/src/model.rs +++ b/src/model.rs @@ -625,6 +625,11 @@ pub struct ProviderSettings { /// Models fetched from the provider's model list. #[serde(default)] pub known_models: Vec, + /// 看圖小幫手 for a local or LAN model (Ollama, a server on this network or Tailscale): + /// pictures it can't see may go to a cloud model of the person's to be described. Off, they + /// never leave (a model of one's own is often chosen so that they don't). + #[serde(default)] + pub cloud_eyes: bool, } #[derive(Clone, Serialize, Deserialize, Debug)] diff --git a/src/providers.rs b/src/providers.rs index 68d9652..c09a117 100644 --- a/src/providers.rs +++ b/src/providers.rs @@ -796,7 +796,7 @@ fn mark_blind(req: &ChatRequest) { pub fn image_refused(msg: &str) -> bool { let l = msg.to_lowercase(); let about_images = l.contains("image") || l.contains("vision") || l.contains("multimodal") || l.contains("圖片") || l.contains("图片"); - about_images && ["at most 0", "not support", "unsupported", "doesn't support", "does not support", "no vision", "not a vision", "not multimodal", "unknown variant", "invalid type", "only text", "text-only", "不支援", "不支持"].iter().any(|k| l.contains(k)) + about_images && ["at most 0", "not support", "unsupported", "doesn't support", "does not support", "no vision", "not a vision", "not multimodal", "not a multimodal", "unknown variant", "invalid type", "only text", "text-only", "不支援", "不支持"].iter().any(|k| l.contains(k)) } /// Every tool call needs its result right after it (providers refuse the conversation @@ -869,6 +869,7 @@ pub fn vision_test_guard() -> std::sync::MutexGuard<'static, ()> { notes().lock().unwrap().clear(); failed_eyes().lock().unwrap().clear(); set_eyes(vec![]); + set_cloud_eyes_for(vec![]); g } @@ -917,6 +918,21 @@ pub(crate) fn is_local_model(kind: ProviderKind, base_url: &str) -> bool { !crate::web::is_private_browser_url(base_url).eq(&false) } +/// The local or LAN servers (their addresses) whose pictures a cloud model may describe: the +/// person turned it on for that provider (設定 › 模型, ProviderSettings::cloud_eyes). +static CLOUD_EYES_FOR: std::sync::Mutex> = std::sync::Mutex::new(Vec::new()); + +pub fn set_cloud_eyes_for(bases: Vec) { + *CLOUD_EYES_FOR.lock().unwrap() = bases; +} + +/// Pictures of a bot on this model stay with local helpers only: a local or LAN model, unless +/// the person let a cloud model look for it. +fn keeps_pictures_here(kind: ProviderKind, base_url: &str) -> bool { + let same = |a: &str| a.trim().trim_end_matches('/') == base_url.trim().trim_end_matches('/'); + is_local_model(kind, base_url) && !CLOUD_EYES_FOR.lock().unwrap().iter().any(|b| same(b)) +} + /// Ask the first helper that can see pictures to describe this one: (description, model). /// Every picture is looked at once: the note is kept by the picture's own hash, so the same /// picture in a later send costs nothing. A bot that needs more than the note gives it a fresh, @@ -945,11 +961,12 @@ pub fn describe_fresh(picture: &str, ask: &str, not: &ChatRequest, cancel: &Atom } fn ask_eyes(picture: &str, ask: &str, not: &ChatRequest, cancel: &AtomicBool) -> Option<(String, String)> { - let keep_local = is_local_model(not.kind, ¬.base_url); + let keep_local = keeps_pictures_here(not.kind, ¬.base_url); let helpers: Vec = EYES.lock().unwrap().clone(); for e in helpers { // Privacy boundary: when the bot's own model is local/private (Ollama or LAN server), - // never send its screenshots or attachments out to an external cloud provider behind the person's back. + // never send its screenshots or attachments out to an external cloud provider behind the + // person's back (only when they said so for that provider). if keep_local && !is_local_model(e.kind, &e.base_url) { continue; } @@ -1948,6 +1965,7 @@ mod tests { assert!(image_refused("錯誤 400:At most 0 image(s) may be provided in one prompt. (parameter=image)")); assert!(image_refused("This model does not support image input")); assert!(image_refused("unknown variant `image_url`, expected `text`")); + assert!(image_refused("錯誤 400:spark-x2.6-4b is not a multimodal model")); assert!(!image_refused("錯誤 400:Invalid credential")); // The first request fails like the user's model did; the retry has no picture. let l = TcpListener::bind("127.0.0.1:0").unwrap(); @@ -2093,6 +2111,27 @@ mod tests { set_eyes(vec![]); } + #[test] + fn a_local_models_pictures_stay_unless_the_person_lets_a_cloud_model_look() { + let _g = vision_test_guard(); + let lan = "http://100.82.106.34:54088/v1"; + // A server on Tailscale, Ollama, this computer: kept here; a cloud model's: may go out. + assert!(keeps_pictures_here(ProviderKind::Custom, lan)); + assert!(keeps_pictures_here(ProviderKind::Ollama, "http://localhost:11434/v1")); + assert!(!keeps_pictures_here(ProviderKind::Xai, "https://api.x.ai/v1")); + // Turned on for that server (設定 › 模型): its pictures may go to a cloud helper. + set_cloud_eyes_for(vec![format!("{lan}/")]); + assert!(!keeps_pictures_here(ProviderKind::Custom, lan)); + assert!(keeps_pictures_here(ProviderKind::Custom, "http://192.168.1.20:8000/v1"), "only the one turned on"); + set_cloud_eyes_for(vec![]); + assert!(keeps_pictures_here(ProviderKind::Custom, lan)); + // Off, a cloud helper is never asked (nothing is sent: no description comes back). + set_eyes(vec![Eyes { kind: ProviderKind::Xai, base_url: "https://api.x.ai/v1".into(), api_key: "k".into(), model: "grok-4".into() }]); + let not = ChatRequest { kind: ProviderKind::Custom, base_url: lan.into(), api_key: String::new(), model: "husky".into(), system: String::new(), history: vec![], tools: vec![], session: String::new(), effort: String::new() }; + assert!(ask_eyes("UElDVFVSRS1PTkU=", "看", ¬, &AtomicBool::new(false)).is_none()); + set_eyes(vec![]); + } + #[test] fn steps_without_results_are_closed() { let mut a = Message::assistant("", ""); From 8d24a0fb8a9483e3e2d443c147278d807fea8f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Sun, 15 Nov 2026 20:00:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?test:=20=E9=9B=BB=E8=85=A6=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E9=87=8F=E6=B8=AC=E6=AF=8F=E9=A1=8C=E6=B8=85=E6=8E=89?= =?UTF-8?q?=E7=9C=8B=E5=9C=96=E6=8F=8F=E8=BF=B0=EF=BC=8C=E4=B8=A6=E8=A8=98?= =?UTF-8?q?=E4=B8=8B=E8=AB=8B=E5=88=A5=E7=9A=84=E6=A8=A1=E5=9E=8B=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E4=BA=86=E5=B9=BE=E5=BC=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun --- bench/computer-use/run.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bench/computer-use/run.py b/bench/computer-use/run.py index a3d1e4f..ee21dfb 100644 --- a/bench/computer-use/run.py +++ b/bench/computer-use/run.py @@ -426,7 +426,9 @@ def main(): for name in ["chats", "oplog"] + (["skills"] if skills else []): shutil.rmtree(os.path.join(a.data, name), ignore_errors=True) for name in os.listdir(a.data): - if name.startswith("memory.db"): + # The 看圖小幫手's notes too (a model that can't see pictures has them described): each + # task's pictures are described anew, and counted. + if name.startswith("memory.db") or name == "image-notes.json": os.remove(os.path.join(a.data, name)) forget(skills=True) # A box of its own that doesn't exist yet: one plain question first makes it (the first task's @@ -482,6 +484,12 @@ def main(): r["check_error"] = str(e) r["skills"] = [{"name": k.get("name"), "steps": len(k.get("steps", []))} for k in st.get("skills", [])] r["replayed"] = "replay_skill" in r.get("tools", []) + # Pictures another model described for this one (it can't see them): their cost isn't in + # the meter's count, which is the bot's own model only. + try: + r["described"] = len(json.load(open(os.path.join(a.data, "image-notes.json")))) + except (OSError, ValueError): + r["described"] = 0 if meter: r["usage"] = meter.take() r.update({"id": t["id"], "name": t["name"], "expected_route": t["route"], "ok": ok, "run": run + 1, "label": a.label,