You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: vector similarity tool filtering via Gemini embeddings
At startup, embeddings are computed for all MCP tools using
gemini-embedding-001 and cached in memory. Each request embeds
the user query and selects top-K most relevant tools via cosine
similarity, reducing LLM context size without keyword maintenance.
Falls back to all tools if embeddings unavailable or top_k=0.
Configured via models.embedding and tool_filter.top_k in config.yaml.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,7 @@ flowchart LR
52
52
- Connects on startup (`initialize` → `tools/list`). Supports JSON and SSE responses.
53
53
- Per-server tool filtering: `allowTools` (allowlist) checked after `denyTools` (blocklist)
54
54
- Auth via generic `headers` map (Claude Desktop format)
55
+
-**Vector tool filtering**: `EnableEmbeddings(apiKey, model, topK)` + `EmbedTools(ctx)` at startup computes Gemini embeddings for all tools; `LLMToolsForQuery(ctx, query)` returns top-K most relevant tools per request via cosine similarity. Falls back to all tools if embeddings unavailable or query is empty.
55
56
56
57
**`internal/agent`** — agentic loop.
57
58
-`Process(ctx, chatID, llm.Message, onToolCall)` — prepends `"Current date and time: ..."` to the system prompt on every call using `time.Now()` (respects `TZ` env var set in Docker)
@@ -68,7 +69,7 @@ flowchart LR
68
69
| File | Purpose |
69
70
|---|---|
70
71
|`.env`| Secrets: `TELEGRAM_BOT_TOKEN`, `DEEPSEEK_API_KEY`, `GEMINI_API_KEY`, `TELEGRAM_OWNER_CHAT_ID`, `TZ` (default `Europe/Belgrade`) — auto-loaded by Docker Compose from project root |
Copy file name to clipboardExpand all lines: README.md
+18-3Lines changed: 18 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ A lightweight Telegram bot that acts as a personal AI assistant. Written in Go
8
8
-**Image support** — send a photo (with or without caption) and it's routed automatically to the vision model
9
9
-**Forwarded messages** — forward any message (text, photo, link) to the bot, then ask your question; messages arriving within 2 s are batched automatically
10
10
-**Link extraction** — hidden hyperlinks (`text_link` entities) in forwarded messages are surfaced as plain URLs for the LLM
11
-
-**MCP tool support** — connects to any MCP-compatible server (HTTP/SSE), same `mcp.json` format as Claude Desktop; per-server `allowTools`/`denyTools` filtering
11
+
-**MCP tool support** — connects to any MCP-compatible server (HTTP/SSE), same `mcp.json` format as Claude Desktop; per-server `allowTools`/`denyTools` filtering; vector similarity filtering selects only the most relevant tools per request
12
12
-**Persistent memory** — SQLite-backed conversation history with automatic session management
13
13
-**Context compaction** — auto-summarises old history to stay within token limits
14
14
-**Rich formatting** — Markdown converted to Telegram HTML; responses ≥ 4096 chars sent as `response.md`
@@ -20,7 +20,7 @@ A lightweight Telegram bot that acts as a personal AI assistant. Written in Go
20
20
- Go 1.24+ (or Docker)
21
21
-[Telegram Bot Token](https://t.me/BotFather)
22
22
-[DeepSeek API key](https://platform.deepseek.com)
23
-
- Gemini API key (optional — for fallback and image support)
23
+
- Gemini API key (optional — for fallback, image support, and tool filtering)
0 commit comments