mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 12:09:42 +08:00
* TutorBot Channels tab is now schema-driven across every built-in & plugin channel (GET /api/v1/tutorbot/channels/schema), with per-field secret reveal toggles. * Channel secrets are masked end-to-end; raw values only surface via the explicit ?include_secrets=true edit-form route. PATCH validates ChannelsConfig at the API boundary and returns 422 on bad payloads. reload_channels is serialised by an asyncio.Lock and records last_reload_error for the UI. * Collapsed services/rag/ to a single LlamaIndex pipeline: removed ~2.6k lines of unused components/* + pipeline.py + types.py + utils/ + parsers/. rag_provider is now a stub; legacy values silently coerce to llamaindex. * Centralised file routing into services/rag/file_routing.py (FileTypeRouter / DocumentType / FileClassification); dropped per-provider extension helpers. * Defensive RAG/KB consistency: deep_solve / deep_research strip rag/kb when no KB is attached; SolveToolRuntime + ResearchPipeline + DecomposeAgent short-circuit instead of falling back to non-existent default KBs (DE-all, ai_textbook). * Externalised AgenticChatPipeline prompts into agentic_chat.yaml (zh + en). * Added Thai README (#337). * New test modules: file_routing, knowledge_base_config, channel_schema, channel_secrets, rag_consistency, research_pipeline_rag. Full notes: assets/releases/ver1-1-2.md Made-with: Cursor
68 lines
1.9 KiB
Python
68 lines
1.9 KiB
Python
"""RAG pipeline factory.
|
|
|
|
The project ships with a single LlamaIndex-backed pipeline. The helpers
|
|
below remain because several call-sites import them; they have all been
|
|
collapsed to operate on the single supported pipeline.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
DEFAULT_PROVIDER = "llamaindex"
|
|
|
|
# Cached pipeline instances keyed by kb_base_dir.
|
|
_PIPELINE_CACHE: Dict[Optional[str], Any] = {}
|
|
|
|
|
|
def normalize_provider_name(_name: Optional[str] = None) -> str:
|
|
"""Always return the canonical provider name.
|
|
|
|
Older configs/migrations may carry legacy provider strings (e.g.
|
|
``lightrag``); they are all treated as the only supported pipeline.
|
|
"""
|
|
return DEFAULT_PROVIDER
|
|
|
|
|
|
def get_pipeline(
|
|
name: str = DEFAULT_PROVIDER,
|
|
kb_base_dir: Optional[str] = None,
|
|
**kwargs: Any,
|
|
):
|
|
"""Return the (cached) LlamaIndex pipeline instance.
|
|
|
|
The ``name`` argument is accepted for backward compatibility but is
|
|
ignored — only the LlamaIndex pipeline is supported.
|
|
"""
|
|
from .pipelines.llamaindex import LlamaIndexPipeline
|
|
|
|
if kwargs:
|
|
# When custom kwargs are provided, build a fresh instance and skip
|
|
# the cache to honour overrides.
|
|
if kb_base_dir is not None:
|
|
kwargs.setdefault("kb_base_dir", kb_base_dir)
|
|
return LlamaIndexPipeline(**kwargs)
|
|
|
|
if kb_base_dir not in _PIPELINE_CACHE:
|
|
_PIPELINE_CACHE[kb_base_dir] = LlamaIndexPipeline(kb_base_dir=kb_base_dir)
|
|
return _PIPELINE_CACHE[kb_base_dir]
|
|
|
|
|
|
def list_pipelines() -> List[Dict[str, str]]:
|
|
"""Return the single available pipeline (kept for callers that still ask)."""
|
|
return [
|
|
{
|
|
"id": DEFAULT_PROVIDER,
|
|
"name": "LlamaIndex",
|
|
"description": "Pure vector retrieval, fastest processing speed.",
|
|
}
|
|
]
|
|
|
|
|
|
__all__ = [
|
|
"DEFAULT_PROVIDER",
|
|
"get_pipeline",
|
|
"list_pipelines",
|
|
"normalize_provider_name",
|
|
]
|