慣性聚合 高效追蹤和閱讀你感興趣的部落格、新聞、科技資訊
閱讀原文 在慣性聚合中打開

推薦訂閱源

博客园 - 司徒正美
V
V2EX
T
Tailwind CSS Blog
有赞技术团队
有赞技术团队
aimingoo的专栏
aimingoo的专栏
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
A
About on SuperTechFans
月光博客
月光博客
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
V
Visual Studio Blog
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python)
我復活了我的個人AI助理 — 現在它是一個以隱私為先的Windows Telegram機器人
Sreedhara Murthy · 2026-05-24 · via DEV Community

這是一份提交給GitHub Finish-Up-A-Thon Challenge


的參賽作品 我所建立的

數位秘書是一個注重隱私的個人AI助理,可在您的Windows電腦上運行,透過Telegram與您溝通。無需雲端訂閱。無需Docker。除非您選擇,否則您的數據不會離開您的電腦。

你發送訊息 → 你的電腦處理它 → 你獲得一個智能、記憶感知的回覆。語音輸入,語音輸出。檔案、網路搜尋、提醒、OCR — 全部來自Telegram.

GitHub: github.com/sree1959git/Digital-Secretary


Demo

設定向導

互動式向導不到3分鐘:

  ____  _       _ _        _   ____                    _
 |  _ \(_) __ _(_) |_ __ _| | / ___|  ___  ___ _ __ ___| |_ __ _ _ __ _   _
 | | | | |/ _` | | __/ _` | | \___ \ / _ \/ __| '__/ _ \ __/ _` | '__| | | |
 | |_| | | (_| | | || (_| | |  ___) |  __/ (__| | |  __/ || (_| | |  | |_| |
 |____/|_|\__, |_|\__\__,_|_| |____/ \___|\___| _|  \___|  \__\__,_|_|   \__, |
          |___/                                                              |___/

  Your personal AI secretary. On Telegram. On Windows.

  Step 1: Telegram Bot Token
  Step 2: OpenRouter API Key
  Step 3: Default AI Model
  Step 4: Name Your AI Secretary
  Step 5: Personality

進入全螢幕模式 退出全螢幕模式

Bot 在行動中

You: Remind me to call the dentist tomorrow at 10am
Digital Secretary: Done! I've set a reminder for tomorrow at 10:00 AM: "Call the dentist". 
                   I'll message you here on Telegram when it's time.

You: [sends photo of whiteboard]
Digital Secretary: I can see a whiteboard with what appears to be a sprint plan. 
                   The items listed are: [extracted text from OCR + vision analysis]

You: [voice message] "What did we discuss last week about the project?"
Digital Secretary: [voice reply] Based on our previous conversations, we talked about...

進入全螢幕模式 退出全螢幕模式

架構一目了然

Telegram (Your Phone)
        │
        ▼
Digital Secretary (Windows PC)
        │
        ├── 🧠 AI: OpenRouter / Ollama / llama.cpp
        ├── 💾 Memory: SQLite FTS5 (persistent, searchable)
        ├── 🛠️ Tools: files, shell, web, OCR, MCP servers
        ├── 📅 Scheduler: APScheduler-backed reminders
        ├── 🎙️ STT: faster-whisper (local Whisper)
        └── 🔊 TTS: edge-tts (Microsoft neural voices)

進入全螢幕模式 退出全螢幕模式


复甦故事

它的起點 (之前)

大約六個月前,我開始了這個專案的第一次版本——當時稱為Antidote——作為一個週末實驗。想法很簡單:我想有一個個人AI助理,它需要:

  1. 不需要月度訂閱
  2. 能在我的Windows電腦上運行
  3. 使用Telegram(我手機上已經有了)

我三個禮拜內做出了一個可工作的原型。但接下來生活發生了事情。專案就那樣擱置著——功能正常但粗糙:

  • 配置中硬編碼的路徑 (C:/Users/Sreedhar/...)
  • 機器人能回答問題但在重啟後會忘記一切
  • 完全沒有語音支援
  • 單個Python檔案,卻變成了1,000行
  • 沒有文件說明 — 我甚至記不起來自己是如何設定它的

我在CODE_REVIEW_REPORT.md中殘酷誠實地記錄了所有這些

"設定檔有硬編碼個人路徑... 記憶僅僅在每個會話中存活... OcrImageTool已在Telegram頻道中註冊,但在主要工具註冊表中沒有註冊... 自動啟動任務名稱在wizard.py和autostart.py之間不一致..."

我所做的改變 (之後)

當我為這個挑戰再次接手這個專案時,我把它當作第一次接觸客戶的程式碼庫。這裡是改變的地方:

架構改進:

  • 將單體拆分成正確的套件結構:agent/channels/memory/providers/security/tools/
  • 新增了MemoryStore搭配SQLite FTS5 — 這個機器人現在可以在不同會話中記住你
  • 引入了ContextBuilder,它從身分檔案中組合系統提示(SOUL.mdAGENTS.mdUSER.md)
  • 建立了一個正確的ToolRegistry,具有OpenAI相容的函數定義

新增了以下功能:

  • 🎙️語音輸入輸出 — 汕聲 (本地語音辨識) + 輪廓-TTS 神經聲音 (3層聲音系統)
  • 📅 排程器 — "每天下午3點提醒我站起來伸展"
  • 🖼️ 視覺 + OCR — 輸入照片,獲取文字提取和圖像描述
  • 🔌 MCP橋接器— 插入任何 Model Context Protocol 伺服器
  • 🔒硬體限制加密— 使用 Fernet 加密並以 Windows UUID 進行鍵控的密碼

生活品質:

  • 互動式設定向導(不再需要手動編輯 JSON)
  • 透過 Windows 任務排程器自動啟動
  • 在 Ctrl+C / SIGTERM 上進行正確的優雅關機
  • 於段落邊界處分隔回應(不再有中間詞的Telegram截斷)
  • /model 命令用於會話中途切換AI模型

品牌重塑:

  • Antidote 改為 Digital Secretary — 新名稱更好地反映了它的實際功能:它是您的個人秘書,而不仅仅是「一個AI」
  • 新CLI:digital_secretarydigital_secretary setup

我與 GitHub Copilot 的經驗

GitHub Copilot (透過 Antigravity IDE) 在這次復甦中實際上無價。以下是它產生最大差異的具體時刻:

1. 聲音管道設計

三層聲音響應系統是最難的設計挑戰:

  • 第一層:"讀出來" → 播放最後一次響應的 TTS,無 LLM 呼叫
  • 第二級: "解釋這個" → LLM 以自然語音重新解釋
  • 第三級: 預設語音查詢 → LLM 將其回應總結以供語音

我以英文描述了問題,Copilot 帮助繪製狀態機,並編寫了初始的_is_readout_request() /_is_explain_request() 模式匹配。原本需要我花一個小時思考邊界情況的東西,卻在幾分鐘內草擬完成。

2. 硬體相關加密

# Copilot suggested this elegant approach for Windows-specific key derivation
def _derive_key(uuid_bytes: bytes) -> bytes:
    return hashlib.pbkdf2_hmac(
        "sha256",
        uuid_bytes,
        salt=b"digital_secretary_v1",
        iterations=480_000,
    )

進入全螢幕模式 退出全螢幕模式

它讓我意識到應該使用具高次數的 PBKDF2 而不是原始的 HMAC,並根據 OWASP 為 2024 年提供的建議,建議了具體的次數(480K)。

3. SQLite FTS5 内存搜尋

我以前沒有使用過 FTS5。Copilot 寫了模式遷移,然後MATCH查詢,並解釋了為何 rank需要為了正確的相關性排序而否定。我在過程中學到了一些新事物。

4. Windows 信号處理錯誤

# This pattern only works on Unix:
loop.add_signal_handler(signal.SIGTERM, callback)

# Copilot caught this and suggested the Windows-compatible approach:
signal.signal(signal.SIGTERM, _signal_handler)

進入全螢幕模式 退出全螢幕模式

它在代碼審查過程中發現了平台不相容問題 — 這是我只有在用戶報告後才會發現的事


使用案例

數位秘書是為那些想要個人AI的人設計的,它應該能:

情境 你的操作 它會做什麼
個人助理 "將牛奶加入我的購物清單" 儲存至記憶,當您詢問時可撥回
每日簡報 預約早上8點的訊息 發送您的提醒事項和筆記摘要
文件閱讀器 傳送PDF照片 OCR + AI摘要
程式碼輔助 貼上錯誤,請求修正 搜尋網路,閱讀檔案,建議解決方案
會議筆記 錄下關鍵點 轉錄並儲存至記憶體
家庭秘書 共用提醒 為所有家庭成員安排任務
研究助理 "尋找有關X的最新論文" 網頁搜尋 + 總結
離線 AI 本地 llama.cpp 設置 無需雲端,無需網際網路

技術架構亮點

持續記憶

# Search semantic memory with FTS5
results = await memory.search("dentist appointment", limit=5)
# Returns: [Memory(content="User mentioned dentist on Tuesday...", category="fact")]

進入全螢幕模式 退出全螢幕模式

每一個對話都會被總結並儲存。下次您問及相關問題時,相關記憶會自動注入系統提示中.

工具實際應用

當您問「明天天氣如何?」時,LLM:

  1. 決定呼叫web_search("weather tomorrow [your city]")
  2. 取得結果
  3. 呼叫fetch_webpage(url)以獲得詳細預報
  4. 合成自然語言回應

全部在Telegram交談中完成

多供應商AI

# Switch between providers transparently
provider = get_provider()  # reads config, returns right provider

# All providers implement the same interface
response = await provider.chat(messages=messages, tools=tool_defs)

進入全螢幕模式 退出全螢幕模式

與OpenRouter(100+模型)、Ollama(本地)和llama.cpp(超本地,GPU或CPU)合作


開始使用

git clone https://github.com/sree1959git/Digital-Secretary.git
cd Digital-Secretary
.\start.ps1

進入全螢幕模式 退出全螢幕模式

發射器處理所有事情 — Python 版本檢查、venv 創建、依賴安裝和向導啟動

完整安裝指南: TELEGRAM_BOT_SETUP.md


下一步

專案路線圖誠實地說明了還需要做什麼:

  • 多代理路由 — 分開/finance/health/work 具有作用範圍的記憶子代理
  • 審批工作流程 — 使用Telegram內聯按鈕審批檔案寫入和shell命令
  • 持續的對話歷史 — 持續儲存每一輪對話,而不僅僅是摘要
  • 網頁UI — 一個用於檢視記憶、管理提醒、切換模型的儀表板

這個挑戰正是我需要的,讓我不再把這個放在架子上。

如果你試了,在評論裡告訴我你怎麼想的。 👇


標籤:#devchallenge #githubchallenge #python #telegram #ai #windows #opensource