feat: add local LLMWiki wiki vector index

This commit is contained in:
Administrator committed 2026-08-24 00:49:31 +08:00
1 parent 4c9f75f31e
commit 3785345353
48 files changed
+3650 -152

No files matched your search

@@ -49,6 +49,8 @@ from app.gateway.routers import (
light_apps,
llm_metrics,
llmwiki,
llmwiki_index,
external_llmwiki,
mcp,
memory,
menu_overrides,
@@ -989,6 +991,22 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
# Run Alembic migrations before anything else touches the schema.
await _run_db_migrations()
# Local Wiki mirror/index scans are opt-in and run outside request
# handling. Each knowledge base still uses a database lease, so this is
# safe when multiple Gateway workers start the same scheduler.
app.state.llmwiki_index_scheduler_task = None
local_wiki_index = app.state.config.llmwiki.local_wiki_index
if (
local_wiki_index.enabled
and local_wiki_index.sync_enabled
and getattr(app.state, "llmwiki_sync_service", None) is not None
):
from app.gateway.llmwiki_index_scheduler import local_wiki_index_scheduler_loop
app.state.llmwiki_index_scheduler_task = asyncio.create_task(
local_wiki_index_scheduler_loop(app)
)
# ?? recall_budget cache?? DB ????,? get_effective_memory_config ?????
try:
from deerflow.config.memory_config import load_recall_budget_cache
@@ -1171,6 +1189,21 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
logger.exception("Scheduled task service failed to start")
yield
llmwiki_index_scheduler_task = getattr(app.state, "llmwiki_index_scheduler_task", None)
if llmwiki_index_scheduler_task is not None:
llmwiki_index_scheduler_task.cancel()
try:
await llmwiki_index_scheduler_task
except asyncio.CancelledError:
pass
except Exception:
logger.exception("Local Wiki index scheduler shutdown error")
llmwiki_index_jobs = list(getattr(app.state, "llmwiki_index_jobs", set()))
for job in llmwiki_index_jobs:
job.cancel()
if llmwiki_index_jobs:
await asyncio.gather(*llmwiki_index_jobs, return_exceptions=True)
# ?? curator ???
curator_task = getattr(app.state, "curator_scheduler_task", None)
@@ -1457,6 +1490,8 @@ This gateway provides custom endpoints for models, MCP configuration, skills, an
# DeerFlow-native LLMWiki management/search BFF (conditionally backed by WeKnora).
app.include_router(llmwiki.router)
app.include_router(llmwiki_index.router)
app.include_router(external_llmwiki.router)
# Memory API is mounted at /api/memory
app.include_router(memory.router)
@@ -1654,9 +1689,9 @@ This gateway provides custom endpoints for models, MCP configuration, skills, an
# --- ?????????? /page/workspace/roundtable/planning?---
# ??? app/gateway/routers/{multi_agent,intent,recommend}.py?
# ??? frontend-web/docs/multi-agent-backend-dev.md
app.include_router(multi_agent.router) # Step 2?init(SSE) + run/stream(leader|special)
app.include_router(intent.router) # Step 1?/api/intent/init + /stream
app.include_router(recommend.router) # Step 1?2?/api/recommend/stream?? init?
app.include_router(multi_agent.router) # Step 2?init(SSE) + run/stream(leader|special)
app.include_router(intent.router) # Step 1?/api/intent/init + /stream
app.include_router(recommend.router) # Step 1?2?/api/recommend/stream?? init?
# Step 3 ????/?????? artifacts.router?/api/threads/{id}/artifacts?
# Health probes are always unauthenticated (see