mirror of
https://github.com/zvx-echo6/recon.git
synced 2026-05-20 06:34:40 +02:00
13 lines
46 KiB
JSON
13 lines
46 KiB
JSON
|
|
{
|
||
|
|
"id": "recon_rag",
|
||
|
|
"user_id": "421c0f8b-6ae4-4063-b07a-7e08b36851f1",
|
||
|
|
"name": "RECON Knowledge Base",
|
||
|
|
"type": "filter",
|
||
|
|
"content": "\"\"\"\ntitle: RECON Knowledge Base\nauthor: Echo6\nversion: 4.3.0\ndescription: RAG filter that searches the RECON knowledge base and injects reference material into Aurora's context. Emits citations with PDF download links. Supports intent-based metadata filtering, FlashRank neural reranking with MMR diversity, Ollama-powered query expansion, transcript source boosting, semantic query routing with inline navigation, and address book place resolution.\n\"\"\"\n\nimport logging\nimport json\nimport math\nimport re\nimport threading\nfrom typing import Optional, Callable, Awaitable\nfrom concurrent.futures import ThreadPoolExecutor, as_completed\n\nimport requests\nfrom pydantic import BaseModel, Field\n\nlog = logging.getLogger(__name__)\n\n# Module-level source store: keyed by chat_id so inlet/outlet share state\n# even if OWI instantiates separate Filter objects per call.\n_SOURCE_STORE: dict[str, list] = {}\n\n# \u2500\u2500 Semantic Query Router (v4.3.0) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nROUTE_EXAMPLES = {\n \"nav_route\": [\n \"how do I get to Boise\",\n \"directions to Twin Falls\",\n \"how do I get from Buhl to Boise\",\n \"drive from Jerome to Sun Valley\",\n \"route from Boise to McCall\",\n \"what's the fastest way to Sun Valley\",\n \"how far is it to Twin Falls\",\n \"take me to Shoshone\",\n \"navigate to the airport\",\n \"how do I drive to Salt Lake City\",\n \"walking directions to the park\",\n \"bike route to downtown\",\n ],\n \"nav_reverse_geocode\": [\n \"what town is at 42.5, -114.7\",\n \"where am I right now\",\n \"what is at coordinates 43.6, -116.2\",\n \"what location is 42.574, -114.607\",\n \"where is this place 44.0, -114.3\",\n \"what city is near 42.7, -114.5\",\n \"reverse geocode 43.0, -115.0\",\n \"what's at this location 42.9, -114.8\",\n ],\n \"direct_answer\": [\n \"hello\",\n \"hey aurora\",\n \"good morning\",\n \"thanks\",\n \"thank you\",\n \"what's your name\",\n \"who are you\",\n \"tell me a joke\",\n \"how are you\",\n \"hi there\",\n ],\n \"rag_search\": [\n \"what does the survival manual say about water\",\n \"how to purify water in the field\",\n \"how to treat a gunshot wound\",\n \"what is the ranger handbook chapter on patrolling\",\n \"field manual water purification\",\n \"how to build a shelter in the wilderness\",\n \"tactical combat casualty care procedures\",\n \"what does FM 21-76 say about fire starting\",\n ],\n}\n\n_ROUTE_CENTROIDS: dict | None = None\n_ROUTER_LOCK = threading.Lock()\n\n\ndef _embed_batch_router(texts: list[str], tei_url: str) -> list[list[float]]:\n resp = requests.post(tei_url, json={\"inputs\": texts}, timeout=30)\n resp.raise_for_status()\n return resp.json()\n\n\ndef _compute_centroid(vectors: list[list[float]]) -> list[float]:\n n = len(vectors)\n dim = len(vectors[0])\n centroid = [0.0] * dim\n for vec in vectors:\n for i in range(dim):\n centroid[i] += vec[i]\n for i in range(dim):\n centroid[i] /= n\n return centroid\n\n\ndef _cosine_similarity(a: list[float], b: list[float]) -> float:\n dot = 0.0\n norm_a = 0.0\n norm_b = 0.0\n for i in range(len(a)):\n dot += a[i] * b[i]\n norm_a += a[i] * a[i]\n norm_b += b[i] * b[i]\n denom = math.sqrt(norm_a) * math.sqrt(norm_b)\n if denom == 0:\n return 0.0\n return dot / denom\n\n\ndef _ensure_centroids(tei_url: str) -> dict[str, list[float]]:\n global _ROUTE_CENTROIDS\n if _ROUTE_CENTROIDS is not None:\n return _ROUTE_CENTROIDS\n with _ROUTER_LOCK:\n
|
||
|
|
"meta": "{\"description\": \"RAG filter that searches the RECON knowledge base and injects reference material into Aurora's context. Emits citations with PDF download links. Supports intent-based metadata filtering, FlashRank neural reranking with MMR diversity, Ollama-powered query expansion, transcript source boosting, semantic query routing with inline navigation, and address book place resolution.\", \"manifest\": {\"title\": \"RECON Knowledge Base\", \"author\": \"Echo6\", \"version\": \"1.0.0\", \"description\": \"RAG filter with citations\"}, \"toggle\": false}",
|
||
|
|
"created_at": 1771176726,
|
||
|
|
"updated_at": 1776643065,
|
||
|
|
"valves": null,
|
||
|
|
"is_active": 1,
|
||
|
|
"is_global": 0
|
||
|
|
}
|