repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
DeepTutor | deeptutor/services/llm/provider_core/openai_responses/converters.py | .py | """Convert Chat Completions messages/tools to Responses API format."""
from __future__ import annotations
from collections.abc import Mapping
import json
from typing import Any
_CHAT_TOKEN_LIMIT_ALIASES = ("max_completion_tokens", "max_tokens")
def convert_messages(messages: list[dict[str, Any]]) -> tuple[str, lis... | 144 | 5,454 |
DeepTutor | deeptutor/services/llm/providers/open_ai.py | .py | """OpenAI provider implementation using shared HTTP client."""
from __future__ import annotations
from collections.abc import AsyncIterator
import logging
import os
from typing import Callable, Protocol, TypeVar, cast
import httpx
import openai
from deeptutor.services.config import load_system_settings
from ..conf... | 171 | 6,243 |
DeepTutor | deeptutor/services/llm/providers/base_provider.py | .py | """Base LLM provider with unified configuration and retries."""
from abc import ABC
from collections.abc import Awaitable, Callable
import logging
from typing import TypeVar
import tenacity
from tenacity import AsyncRetrying, retry_if_exception, stop_after_attempt
from deeptutor.utils.error_rate_tracker import recor... | 205 | 7,490 |
DeepTutor | deeptutor/services/llm/providers/anthropic.py | .py | """
Anthropic LLM provider implementation.
"""
import asyncio
from collections.abc import AsyncIterator
from typing import Callable, Protocol, TypeVar, cast
import anthropic
from ..config import LLMConfig
from ..http_client import get_shared_http_client
from ..registry import register_provider
from ..telemetry impor... | 259 | 7,834 |
DeepTutor | deeptutor/services/llm/providers/routing.py | .py | """Routing provider bridging legacy provider functions.
This provider delegates to the existing function-based providers
(`cloud_provider` / `local_provider`) while inheriting the hardened
execution pipeline from `BaseLLMProvider` (traffic control, circuit
breaker, and exception mapping).
It exists to keep the public... | 265 | 9,781 |
DeepTutor | deeptutor/services/rag/smart_retriever.py | .py | """Higher-level multi-query retrieval helpers built on top of RAGService."""
from __future__ import annotations
import asyncio
from collections.abc import Awaitable, Callable
from typing import Any, Dict, List, Optional
SearchFunc = Callable[..., Awaitable[Dict[str, Any]]]
class SmartRetriever:
"""Generate que... | 82 | 2,976 |
DeepTutor | deeptutor/services/rag/provider_binding.py | .py | """Resolve a knowledge base's bound RAG provider.
DeepTutor owns the knowledge-base lifecycle and stores the authoritative
provider binding in ``kb_config.json``. Older KBs may only have
``metadata.json``, so metadata remains a legacy fallback. Retrieval and
incremental indexing should use this helper instead of hand-... | 71 | 2,336 |
DeepTutor | deeptutor/services/rag/kb_paths.py | .py | """Resolve the on-disk directory backing a knowledge base.
Ordinary KBs live at ``<kb_base_dir>/<kb_name>``. A *linked* KB is a pointer to
an engine index the user already built elsewhere: its ``kb_config.json`` entry
carries an ``external_path`` we resolve to instead, so retrieval reads that
folder in place — no copy... | 51 | 1,655 |
DeepTutor | deeptutor/services/rag/index_versioning.py | .py | """Flat per-embedding index versions for knowledge bases.
New layout::
data/knowledge_bases/<kb_name>/
raw/ # source files (untouched)
version-1/ # LlamaIndex storage files live directly here
docstore.json
index_store.json
... | 327 | 11,430 |
DeepTutor | deeptutor/services/rag/index_probe.py | .py | """Provider-owned index readiness probes.
DeepTutor owns KB lifecycle/status, but each RAG provider owns the shape of its
persisted index. This module is the narrow read-only seam between those worlds:
callers ask "is this provider index really queryable?" and get a structured
answer without knowing provider-specific ... | 274 | 8,782 |
DeepTutor | deeptutor/services/rag/preflight.py | .py | """Per-engine environment preflight checks.
Powers the "check whether this engine can run right now" affordance on each
engine's detail page. Every check is best-effort and never raises — a failed
import or missing config becomes a failed/optional check, not an exception.
A check is ``{key, label, ok, detail, optiona... | 201 | 6,202 |
DeepTutor | deeptutor/services/rag/__init__.py | .py | """RAG service exports."""
from .factory import (
DEFAULT_PROVIDER,
get_pipeline,
list_pipelines,
normalize_provider_name,
)
from .file_routing import DocumentType, FileClassification, FileTypeRouter
from .service import RAGService
__all__ = [
"RAGService",
"FileTypeRouter",
"FileClassific... | 22 | 447 |
DeepTutor | deeptutor/services/rag/linked_kb.py | .py | """Probe an external folder before mounting it as a *linked* knowledge base.
Linking reuses a self-contained index a user already built — no copy, no
re-index (see :data:`deeptutor.knowledge.kb_types.LINKED_KB_TYPE`). Before we
register a pointer we must answer two questions for the user:
1. **Does this folder actual... | 238 | 8,709 |
DeepTutor | deeptutor/services/rag/factory.py | .py | """RAG pipeline factory.
Selects a KB's index/retrieve engine by provider name. Three pipelines ship
today:
* ``llamaindex`` (default) — local vector retrieval with hybrid BM25 fusion.
* ``pageindex`` — hosted, vectorless reasoning retrieval (needs an
API key configured under Kno... | 295 | 11,448 |
DeepTutor | deeptutor/services/rag/file_routing.py | .py | """
File Type Router
================
Centralized file type classification and routing for the RAG pipeline.
Determines the appropriate processing method for each document type.
"""
from dataclasses import dataclass
from enum import Enum
import logging
from pathlib import Path
from typing import List
logger = loggin... | 340 | 9,154 |
DeepTutor | deeptutor/services/rag/service.py | .py | """Unified RAG service entry point."""
from __future__ import annotations
import asyncio
import contextlib
import importlib
import inspect
import logging
import os
from pathlib import Path
import shutil
from typing import Any, Dict, List, Optional
from deeptutor.runtime.home import get_runtime_data_root
from .facto... | 324 | 12,244 |
DeepTutor | deeptutor/services/rag/embedding_signature.py | .py | """Embedding-signature helpers for RAG index version selection."""
from __future__ import annotations
import logging
from typing import Any
from deeptutor.services.rag.index_versioning import EmbeddingSignature
logger = logging.getLogger(__name__)
def signature_from_config(config: Any) -> EmbeddingSignature:
... | 57 | 2,085 |
DeepTutor | deeptutor/services/rag/pipelines/modes.py | .py | """Shared retrieval-mode resolution for mode-aware pipelines (LightRAG, GraphRAG).
Resolution order, first valid wins:
1. an explicit ``mode`` kwarg (a one-off override on the search call),
2. the KB's own ``search_mode`` (``kb_config.json`` → ``knowledge_bases[kb]``),
3. the engine's global default mode set from the... | 49 | 1,532 |
DeepTutor | deeptutor/services/rag/pipelines/__init__.py | .py | """Pre-configured RAG pipelines.
DeepTutor currently ships with a single built-in provider (`llamaindex`).
Additional providers can still be registered dynamically via the factory layer.
"""
__all__: list[str] = []
| 8 | 217 |
DeepTutor | deeptutor/services/rag/pipelines/base.py | .py | """Structural contract every RAG pipeline implements.
The RAG service and factory have always relied on duck typing across pipelines
(``initialize`` / ``add_documents`` / ``search`` / ``delete``). This Protocol
makes that contract explicit so a new engine — e.g. the PageIndex cloud
pipeline — can be type-checked again... | 42 | 1,591 |
DeepTutor | deeptutor/services/rag/pipelines/pageindex/pipeline.py | .py | """PageIndex cloud-backed RAG pipeline orchestration.
Implements the same contract as :class:`LlamaIndexPipeline` (see
``..base.RAGPipeline``) but delegates indexing to the hosted PageIndex
service (tree building, no embeddings). PageIndex's REST retrieval endpoint
is deprecated: deep retrieval is agentic — the chat a... | 328 | 12,662 |
DeepTutor | deeptutor/services/rag/pipelines/pageindex/storage.py | .py | """On-disk manifest for a PageIndex-backed knowledge base.
PageIndex has no embeddings, so there is nothing to vectorise locally. The only
local state is a lightweight manifest mapping each ingested file to its hosted
``doc_id``. It is written into the KB's flat ``version-N`` directory (reusing
``index_versioning`` wi... | 115 | 3,282 |
DeepTutor | deeptutor/services/rag/pipelines/pageindex/__init__.py | .py | """PageIndex cloud-backed RAG pipeline.
A KB indexed with the ``pageindex`` provider ships its documents to the hosted
PageIndex service (https://pageindex.ai), which builds a hierarchical tree per
document and serves reasoning-based, vectorless retrieval. DeepTutor's own chat
LLM still writes the final answer — only ... | 15 | 541 |
DeepTutor | deeptutor/services/rag/pipelines/pageindex/client.py | .py | """Thin async HTTP client for the hosted PageIndex REST API.
Upload and lifecycle only — retrieval happens agent-side through the PageIndex
MCP server:
* ``POST /doc/`` — submit a document for processing → ``doc_id``
* ``GET /doc/{doc_id}/`` — poll processing status
* ``DELETE /doc/{doc_id}/`` ... | 133 | 4,847 |
DeepTutor | deeptutor/services/rag/pipelines/pageindex/config.py | .py | """Resolve the PageIndex credential from runtime settings.
The key + base URL live in ``data/.../settings/pageindex.json`` (managed by
``RuntimeSettingsService``), surfaced to users under Knowledge → RAG pipeline
settings. A single account key is shared by every ``pageindex`` KB.
"""
from __future__ import annotation... | 60 | 1,971 |
DeepTutor | deeptutor/services/rag/pipelines/lightrag_server/pipeline.py | .py | """Retrieval-only pipeline backed by an external LightRAG server.
Implements the same contract as the other pipelines (see ``..base.RAGPipeline``)
but owns no index: a ``lightrag-server`` KB is a connection pointer (``type:
lightrag_server`` in ``kb_config.json``) to a standalone LightRAG server the user
runs and inde... | 121 | 4,651 |
DeepTutor | deeptutor/services/rag/pipelines/lightrag_server/__init__.py | .py | """Retrieval-only RAG pipeline backed by an external LightRAG server.
A KB bound to the ``lightrag-server`` provider is a connection pointer to a
standalone LightRAG server the user runs and indexed themselves. DeepTutor never
indexes or stores anything locally: retrieval is offloaded to the server's
``/query`` endpoi... | 16 | 628 |
DeepTutor | deeptutor/services/rag/pipelines/lightrag_server/client.py | .py | """Thin async HTTP client for an external LightRAG server's REST API.
We talk to the documented endpoints directly (``httpx`` only) — the calls map
1:1 onto our retrieval-only contract:
* ``POST /query`` with ``only_need_context=True`` — return the grounded context
the server retrieved, WITHOUT its own generation. ... | 150 | 5,738 |
DeepTutor | deeptutor/services/rag/pipelines/lightrag_server/probe.py | .py | """Probe an external LightRAG server before connecting a KB to it.
Connecting is cheap and reversible, but a typo'd URL or a wrong API key should
fail loudly at connect time rather than silently at every later query. This
module answers, in one round-trip pair, the questions the UI needs to confirm:
1. **Reachable, a... | 111 | 3,787 |
DeepTutor | deeptutor/services/rag/pipelines/lightrag_server/config.py | .py | """Per-KB connection config and retrieval modes for the LightRAG Server engine.
Unlike the hosted PageIndex engine (one global account key shared by every KB),
each LightRAG Server KB points at its OWN server instance — a standalone LightRAG
server's ``--workspace`` is fixed at startup, so one server instance = one
wo... | 69 | 2,569 |
DeepTutor | deeptutor/services/rag/pipelines/ima/pipeline.py | .py | """Retrieval-only pipeline backed by a Tencent IMA knowledge base.
Implements the same contract as the other pipelines (see ``..base.RAGPipeline``)
but owns no index: an ``ima`` KB is a connection pointer (``type: ima`` in
``kb_config.json``) to a library the user keeps in IMA and curates there. Only
:meth:`search` do... | 148 | 5,678 |
DeepTutor | deeptutor/services/rag/pipelines/ima/__init__.py | .py | """Retrieval-only RAG pipeline backed by a Tencent IMA knowledge base.
A KB bound to the ``ima`` provider is a connection pointer to a library the user
keeps in IMA (https://ima.qq.com) and curates there. DeepTutor never indexes or
stores anything locally: retrieval calls IMA's ``search_knowledge`` OpenAPI
(passages o... | 16 | 620 |
DeepTutor | deeptutor/services/rag/pipelines/ima/client.py | .py | """Thin async HTTP client for Tencent IMA's knowledge-base OpenAPI.
Every IMA call is ``POST https://ima.qq.com/openapi/wiki/v1/<method>`` with a
JSON body, authenticated by two headers, and answers with a
``{"code", "msg", "data"}`` envelope where ``code == 0`` means success. Only the
two read-only calls DeepTutor ne... | 162 | 5,951 |
DeepTutor | deeptutor/services/rag/pipelines/ima/probe.py | .py | """Probe a Tencent IMA knowledge base before connecting a KB to it.
Connecting is cheap and reversible, but wrong credentials or a mistyped
knowledge base id should fail loudly at connect time rather than silently at
every later query. One ``get_knowledge_base`` round-trip answers both questions
the UI needs to confir... | 103 | 3,119 |
DeepTutor | deeptutor/services/rag/pipelines/ima/config.py | .py | """Per-KB connection config for the Tencent IMA engine.
IMA credentials (``client_id`` + ``api_key``, issued at
https://ima.qq.com/agent-interface) identify a *person*, and a knowledge base id
identifies one of that person's libraries. Both are stored per-KB in
``kb_config.json`` — the same place a ``lightrag-server``... | 83 | 2,712 |
DeepTutor | deeptutor/services/rag/pipelines/llamaindex/embedding_adapter.py | .py | """LlamaIndex embedding adapter backed by DeepTutor's embedding service."""
from __future__ import annotations
import asyncio
import logging
from typing import Any, List
from llama_index.core import Settings
from llama_index.core.base.embeddings.base import BaseEmbedding
from llama_index.core.bridge.pydantic import ... | 191 | 7,341 |
DeepTutor | deeptutor/services/rag/pipelines/llamaindex/pipeline.py | .py | """LlamaIndex-backed RAG pipeline orchestration."""
from __future__ import annotations
import asyncio
import json
import logging
from pathlib import Path
import traceback
from typing import Any, Callable, Dict, List, Optional
from deeptutor.runtime.home import get_runtime_data_root
from deeptutor.services.embedding ... | 287 | 11,368 |
DeepTutor | deeptutor/services/rag/pipelines/llamaindex/errors.py | .py | """Error normalization for LlamaIndex-backed RAG retrieval."""
from __future__ import annotations
from typing import Any, Dict
def search_error_result(query: str, exc: Exception) -> Dict[str, Any]:
"""Convert retrieval failures into actionable tool output."""
message = str(exc)
lower = message.lower()
... | 60 | 2,164 |
DeepTutor | deeptutor/services/rag/pipelines/llamaindex/document_loader.py | .py | """Document loading for the LlamaIndex RAG pipeline.
Parser-backed files (PDF / Office / e-book) are converted through the shared
document-parse bridge (``deeptutor/services/parsing``), so the engine the user
picked in Settings → Document Parsing (text-only, MinerU, Docling, markitdown,
PyMuPDF4LLM) owns extraction. T... | 279 | 11,668 |
DeepTutor | deeptutor/services/rag/pipelines/llamaindex/storage.py | .py | """Storage operations for the LlamaIndex RAG pipeline."""
from __future__ import annotations
from collections import OrderedDict
from dataclasses import dataclass
import json
from pathlib import Path
import shutil
import threading
import time
from typing import Any
from deeptutor.services.embedding.validation import... | 293 | 10,646 |
DeepTutor | deeptutor/services/rag/pipelines/llamaindex/__init__.py | .py | """LlamaIndex RAG pipeline implementation package."""
__all__: list[str] = []
| 4 | 79 |
DeepTutor | deeptutor/services/rag/pipelines/llamaindex/ingestion.py | .py | """LlamaIndex ingestion helpers.
This module keeps DeepTutor's indexing path thin by delegating parsing
transformations and embedding to LlamaIndex's official IngestionPipeline.
"""
from __future__ import annotations
from pathlib import Path
from typing import Any
from llama_index.core import Document, Settings, Ve... | 114 | 4,028 |
DeepTutor | deeptutor/services/rag/pipelines/llamaindex/vector_store.py | .py | """Vector-store backend selection for the LlamaIndex RAG pipeline.
This module is the single seam between DeepTutor's LlamaIndex pipeline and the
concrete vector store implementation. It exists so the rest of the pipeline
(ingestion, storage, retrieval) never has to know *how* vectors are stored.
Why it exists
------... | 265 | 10,647 |
DeepTutor | deeptutor/services/rag/pipelines/llamaindex/config.py | .py | """Configuration helpers for DeepTutor's LlamaIndex RAG pipeline."""
from __future__ import annotations
from dataclasses import dataclass
import os
VECTOR_PROFILE = "vector"
HYBRID_PROFILE = "hybrid"
SUPPORTED_RETRIEVAL_PROFILES = {VECTOR_PROFILE, HYBRID_PROFILE}
@dataclass(frozen=True)
class RetrievalConfig:
... | 109 | 3,518 |
DeepTutor | deeptutor/services/rag/pipelines/llamaindex/retrievers.py | .py | """Retriever composition for the LlamaIndex RAG pipeline."""
from __future__ import annotations
import logging
from pathlib import Path
import shutil
from typing import Any
from llama_index.core.llms.mock import MockLLM
from llama_index.core.retrievers import QueryFusionRetriever
from llama_index.core.retrievers.fus... | 160 | 5,227 |
DeepTutor | deeptutor/services/rag/pipelines/lightrag/pipeline.py | .py | """LightRAG-backed RAG pipeline orchestration.
Implements the same contract as :class:`LlamaIndexPipeline` (see
``..base.RAGPipeline``) but delegates indexing/retrieval to RAG-Anything /
LightRAG. Each KB owns a self-contained LightRAG store under its ``version-N``
directory (see ``storage``).
Documents are turned in... | 302 | 11,900 |
DeepTutor | deeptutor/services/rag/pipelines/lightrag/storage.py | .py | """On-disk layout for a LightRAG-backed knowledge base.
Like the GraphRAG/PageIndex pipelines, a LightRAG KB keeps a self-contained
store inside the KB's flat ``version-N`` directory (reused from
``index_versioning`` with a ``None`` signature). That dir is LightRAG's
``working_dir``: LightRAG writes its KV stores, vec... | 177 | 5,679 |
DeepTutor | deeptutor/services/rag/pipelines/lightrag/__init__.py | .py | """LightRAG / RAG-Anything knowledge-base engine.
A graph-based RAG provider built on HKUDS/LightRAG (multimodal via
HKUDS/RAG-Anything). It consumes DeepTutor's shared parse layer for document
parsing and exposes LightRAG's native query modes (naive/local/global/hybrid/mix)
through the per-KB ``search_mode``.
Module... | 15 | 640 |
DeepTutor | deeptutor/services/rag/pipelines/lightrag/worker.py | .py | """Event-loop isolation helpers for local LightRAG indexing.
RAG-Anything's local storage backends perform synchronous graph merging and
JSON serialization from inside async methods. Running those methods on the
service event loop therefore stalls unrelated API and LLM work. This module
provides one narrow boundary:... | 138 | 4,882 |
DeepTutor | deeptutor/services/rag/pipelines/lightrag/engine.py | .py | """Thin adapter over the RAG-Anything / LightRAG Python API.
This is the ONLY module that imports ``raganything`` / ``lightrag``. Everything
version-sensitive lives here, so an API shift between releases is a one-file
fix. All imports are lazy so DeepTutor runs fine without the optional dependency
installed.
A RAG-An... | 109 | 4,255 |
DeepTutor | deeptutor/services/rag/pipelines/lightrag/config.py | .py | """Bridge DeepTutor's runtime config into LightRAG / RAG-Anything.
LightRAG (HKUDS/LightRAG) is a text knowledge-graph RAG engine; its multimodal
story is RAG-Anything (HKUDS/RAG-Anything), built on top of LightRAG. The
``lightrag`` provider uses RAG-Anything so multimodal content (the parse layer's
``content_list``) ... | 197 | 6,754 |
DeepTutor | deeptutor/services/rag/pipelines/graphrag/pipeline.py | .py | """GraphRAG-backed RAG pipeline orchestration.
Implements the same contract as :class:`LlamaIndexPipeline` (see
``..base.RAGPipeline``) but delegates indexing and retrieval to a local
microsoft/graphrag project. Each KB owns a self-contained GraphRAG project under
its ``version-N`` directory (see ``storage``); documen... | 227 | 8,940 |
DeepTutor | deeptutor/services/rag/pipelines/graphrag/storage.py | .py | """On-disk layout for a GraphRAG-backed knowledge base.
A GraphRAG KB keeps a self-contained project inside the KB's flat ``version-N``
directory (reused from ``index_versioning`` with a ``None`` signature, exactly
like the PageIndex pipeline). The version dir doubles as GraphRAG's project
root::
<kb_dir>/version... | 99 | 3,014 |
DeepTutor | deeptutor/services/rag/pipelines/graphrag/__init__.py | .py | """GraphRAG (microsoft/graphrag) local RAG pipeline.
A KB indexed with the ``graphrag`` provider builds a local knowledge graph
(entities, relationships, communities, community reports) from text and serves
GraphRAG's global/local/drift/basic retrieval. DeepTutor parses documents to
text first and bridges its own LLM/... | 19 | 738 |
DeepTutor | deeptutor/services/rag/pipelines/graphrag/engine.py | .py | """Thin adapter over the GraphRAG (microsoft/graphrag) Python API.
This is the ONLY module that imports ``graphrag``. Everything GraphRAG-version
sensitive lives here, so a schema/API shift between releases is a one-file fix.
Pinned to the 3.x line (``graphrag>=3,<4``); the indexing/query surface mirrors
``graphrag.cl... | 199 | 7,641 |
DeepTutor | deeptutor/services/rag/pipelines/graphrag/ingestion.py | .py | """Turn raw KB files into plain-text input for GraphRAG.
GraphRAG's graph engine is text-only — it has no document parser of its own
(its optional ``markitdown`` reader is just a converter). So DeepTutor owns the
"document → text" step and hands GraphRAG ready ``.txt`` files. We deliberately
reuse DeepTutor's existing... | 113 | 4,117 |
DeepTutor | deeptutor/services/rag/pipelines/graphrag/config.py | .py | """Bridge DeepTutor's runtime config into a GraphRAG ``settings.yaml``.
GraphRAG (microsoft/graphrag, 3.x) is a config-file-driven engine: it reads a
``settings.[yaml|json]`` from a project root and wires its own LiteLLM-backed
model clients from it. Rather than hand-build the deeply nested
``GraphRagConfig`` pydantic... | 223 | 8,883 |
DeepTutor | deeptutor/services/search/types.py | .py | """
Web Search Types - Shared dataclasses and type definitions
This module defines the standardized types used across all search providers.
"""
from dataclasses import dataclass, field
from datetime import datetime
from typing import Any
@dataclass
class Citation:
"""Standardized citation from search results"""... | 115 | 3,678 |
DeepTutor | deeptutor/services/search/__init__.py | .py | """Web Search Service with TutorBot-style provider selection."""
from __future__ import annotations
from datetime import datetime
import json
import logging
from pathlib import Path
from typing import Any
from deeptutor.services.config import (
DEPRECATED_SEARCH_PROVIDERS,
PROJECT_ROOT,
SEARCH_FALLBACK_P... | 262 | 9,761 |
DeepTutor | deeptutor/services/search/consolidation.py | .py | """
Answer Consolidation - Generate answers from raw search results
Strategies (chosen automatically):
- Provider-specific Jinja2 template when available (serper, jina, serper_scholar)
- Generic fallback template for all other raw-SERP providers
- Optional LLM synthesis when ``use_llm=True``
"""
import logging
from t... | 372 | 13,708 |
DeepTutor | deeptutor/services/search/base.py | .py | """
Web Search Base Provider - Abstract base class for all search providers
This module defines the BaseSearchProvider class that all search providers must inherit from.
Providers read credentials from data/user/settings/model_catalog.json.
"""
from abc import ABC, abstractmethod
import logging
from typing import Any... | 90 | 2,919 |
DeepTutor | deeptutor/services/search/providers/serper.py | .py | """
Serper Google SERP Provider
API: https://serper.dev
Endpoint: https://google.serper.dev/{mode}
Features:
- Real-time Google search results (1-2 seconds)
- Modes: search, scholar
- Knowledge graph extraction
- People Also Ask extraction
- Related searches
- Very cheap: $1/1000 queries at scale
"""
from datetime i... | 216 | 7,351 |
DeepTutor | deeptutor/services/search/providers/qianfan.py | .py | """Baidu Qianfan (百度千帆) AI search provider.
API: https://qianfan.baidubce.com/v2/ai_search/web_search
Registered as ``qianfan`` rather than ``baidu``: the retired ``baidu`` provider
sits in ``DEPRECATED_SEARCH_PROVIDERS``, and reusing that key would keep this
one out of the registry. The name is also the accurate one... | 150 | 5,985 |
DeepTutor | deeptutor/services/search/providers/perplexity.py | .py | """
Perplexity AI Search Provider
API: Uses perplexity Python package
Model: sonar (default)
Features:
- AI-powered search with LLM-generated answers
- Automatic citation extraction
- Usage tracking with cost information
"""
from datetime import datetime
from typing import Any
from ..base import BaseSearchProvider
... | 152 | 5,479 |
DeepTutor | deeptutor/services/search/providers/__init__.py | .py | """
Web Search Provider Registry
This module manages the registration and retrieval of search providers.
"""
from typing import Type
from deeptutor.services.config import (
DEPRECATED_SEARCH_PROVIDERS,
SEARCH_FALLBACK_PROVIDER,
search_missing_credential,
search_provider_credentials,
search_provid... | 216 | 6,045 |
DeepTutor | deeptutor/services/search/providers/tavily.py | .py | """
Tavily Search Provider
API Docs: https://docs.tavily.com/documentation/api-reference/endpoint/search
Features:
- Research-focused search with relevance scoring
- Optional LLM-generated answers (include_answer=true)
- Full raw content extraction (include_raw_content=true)
- Topic filtering (general, news, finance)... | 163 | 5,788 |
DeepTutor | deeptutor/services/search/providers/zhipu.py | .py | """Zhipu (智谱 GLM) web search provider.
API: https://open.bigmodel.cn/api/paas/v4/web_search
This is Zhipu's standalone search endpoint, not the ``web_search`` tool bolted
onto chat completions -- it returns ranked rows and never a model-written
answer, so consolidation supplies the answer.
"""
from __future__ import... | 143 | 5,354 |
DeepTutor | deeptutor/services/search/providers/brave.py | .py | """Brave search provider."""
from __future__ import annotations
from datetime import datetime
from typing import Any
import requests
from ..base import BaseSearchProvider
from ..types import Citation, SearchResult, WebSearchResponse
from . import register_provider
@register_provider("brave")
class BraveProvider(B... | 78 | 2,543 |
DeepTutor | deeptutor/services/search/providers/bocha.py | .py | """Bocha (博查) search provider.
API: https://api.bochaai.com/v1/web-search
Bocha is a China-hosted search engine built for AI applications. Unlike the
``/v1/ai-search`` sibling endpoint, ``/v1/web-search`` returns plain SERP rows
with no model-written answer, so consolidation still supplies the answer.
"""
from __fut... | 133 | 4,993 |
DeepTutor | deeptutor/services/search/providers/jina.py | .py | """
Jina Reader Search Provider
API Docs: https://jina.ai/reader
Search Endpoint: https://s.jina.ai/{query}
Reader Endpoint: https://r.jina.ai/{url}
Features:
- Web search with SERP results (s.jina.ai)
- URL to clean content conversion (r.jina.ai)
- Returns clean, LLM-friendly text
- Automatic content extraction
- Im... | 171 | 5,908 |
DeepTutor | deeptutor/services/search/providers/firecrawl.py | .py | """Firecrawl search provider.
API: https://api.firecrawl.dev/v2/search
Firecrawl searches and scrapes in one call: with ``scrapeOptions`` it returns
each hit's page body as markdown, so results carry real content rather than a
SERP blurb. That makes it the expensive-but-rich option next to plain SERP
providers, and i... | 137 | 5,126 |
DeepTutor | deeptutor/services/search/providers/duckduckgo.py | .py | """DuckDuckGo search provider (zero config)."""
from __future__ import annotations
from datetime import datetime
from typing import Any
from ..base import BaseSearchProvider
from ..types import Citation, SearchResult, WebSearchResponse
from . import register_provider
@register_provider("duckduckgo")
class DuckDuck... | 66 | 1,976 |
DeepTutor | deeptutor/services/search/providers/aliyun_iqs.py | .py | """Aliyun IQS (信息查询服务) search provider.
API: https://cloud-iqs.aliyuncs.com/search/genericSearch
The unified HTTP entry point, which authenticates with a plain ``X-API-Key``
header -- the OpenAPI-style host (``iqs.cn-zhangjiakou.aliyuncs.com``) wants
AK/SK request signing and would drag in the Aliyun SDK for no gain.... | 164 | 6,533 |
DeepTutor | deeptutor/services/search/providers/doubao.py | .py | """Doubao (豆包 / Volcengine Ark) search provider.
API: https://ark.cn-beijing.volces.com/api/v3/responses
Ark has no standalone search endpoint -- web search exists only as a built-in
``web_search`` tool on the Responses API. So a query here runs through a Doubao
model that searches, reads, and writes the answer itsel... | 167 | 6,581 |
DeepTutor | deeptutor/services/search/providers/searxng.py | .py | """SearXNG search provider."""
from __future__ import annotations
from datetime import datetime
from typing import Any
from urllib.parse import urlparse
import requests
from ..base import BaseSearchProvider
from ..types import Citation, SearchResult, WebSearchResponse
from . import register_provider
def _validate... | 90 | 2,954 |
DeepTutor | deeptutor/services/persona/__init__.py | .py | """Persona service — behaviour/voice presets for chat (see service.py)."""
from .service import (
LEGACY_PERSONA_SKILLS,
PERSONA_FILE,
InvalidPersonaNameError,
PersonaDetail,
PersonaExistsError,
PersonaInfo,
PersonaNotFoundError,
PersonaService,
get_persona_service,
)
__all__ = [
... | 26 | 546 |
DeepTutor | deeptutor/services/persona/service.py | .py | """
PersonaService
==============
Loads user-authored PERSONA.md files from ``data/user/workspace/personas/``.
A persona is a behaviour/voice preset ("teacher", "peer", …) the user picks
for a conversation. Unlike capability skills (see
:mod:`deeptutor.services.skill`), a persona must shape the model's voice from
the... | 366 | 13,388 |
DeepTutor | deeptutor/services/prompt/manager.py | .py | #!/usr/bin/env python
"""
Unified Prompt Manager - Single source of truth for all prompt loading.
Supports multi-language, caching, and language fallbacks.
"""
from pathlib import Path
from typing import Any
import yaml
from deeptutor.runtime.home import PACKAGE_ROOT
from deeptutor.services.config import parse_langu... | 255 | 8,220 |
DeepTutor | deeptutor/services/prompt/language.py | .py | """Shared language directives for prompt-driven LLM calls.
This helper centralizes the "stay in the requested language" instruction so
different modules can share the same behavior without depending on book-only
utilities.
"""
from __future__ import annotations
_LANGUAGE_LABELS: dict[str, str] = {
"zh": "中文(简体)"... | 82 | 2,934 |
DeepTutor | deeptutor/services/prompt/__init__.py | .py | """
Prompt Service
==============
Unified prompt management for all DeepTutor modules.
Usage:
from deeptutor.services.prompt import get_prompt_manager, PromptManager
# Get singleton manager
pm = get_prompt_manager()
# Load prompts for an agent
prompts = pm.load_prompts("solve", "solve_agent", la... | 36 | 775 |
DeepTutor | deeptutor/services/config/provider_runtime.py | .py | """Nanobot-style normalized runtime configuration for DeepTutor."""
from __future__ import annotations
from dataclasses import dataclass, field
import json
from typing import Any
from urllib.parse import urlparse
from deeptutor.services.imagegen.config import ImagegenConfig
from deeptutor.services.model_selection im... | 1,360 | 49,147 |
DeepTutor | deeptutor/services/config/__init__.py | .py | """Configuration helpers backed by runtime files under data/user/settings."""
import importlib
from .knowledge_base_config import (
KnowledgeBaseConfigService,
get_kb_config_service,
)
from .launch_settings import LaunchSettings, load_launch_settings
from .loader import (
DEFAULT_CHAT_PARAMS,
PROJECT_... | 130 | 4,002 |
DeepTutor | deeptutor/services/config/test_runner.py | .py | from __future__ import annotations
import asyncio
from dataclasses import dataclass, field
import json
import threading
from threading import Lock
import time
from typing import Any
from uuid import uuid4
from .context_window_detection import detect_context_window
from .embedding_endpoint import redact_embedding_endp... | 579 | 23,866 |
DeepTutor | deeptutor/services/config/capabilities_settings.py | .py | """Read/write the per-capability tunables surfaced by the Settings UI.
This is the source of truth for the ``/api/v1/capabilities/settings``
endpoint. It bridges two on-disk files:
* ``data/user/settings/agents.yaml`` — per-capability LLM params
(``temperature``, stage ``max_tokens``). Owned by
:func:`get_chat_pa... | 456 | 17,471 |
DeepTutor | deeptutor/services/config/launch_settings.py | .py | from __future__ import annotations
from dataclasses import dataclass
import json
import os
from pathlib import Path
from typing import Any
from deeptutor.runtime.home import get_runtime_home
from .runtime_settings import RuntimeSettingsService
PROJECT_ROOT = get_runtime_home()
DEFAULT_BACKEND_PORT = 8001
DEFAULT_FR... | 124 | 4,122 |
DeepTutor | deeptutor/services/config/origins.py | .py | from __future__ import annotations
import re
from typing import Any, Iterable
from urllib.parse import urlparse
_ORIGIN_SEPARATORS = re.compile(r"[,;\n]+")
def _raw_origin_items(value: Any) -> Iterable[str]:
if value is None:
return []
if isinstance(value, (list, tuple, set)):
items: list[st... | 56 | 1,628 |
DeepTutor | deeptutor/services/config/model_catalog.py | .py | from __future__ import annotations
from collections.abc import Callable
from copy import deepcopy
import json
import os
from pathlib import Path
import tempfile
import threading
from typing import Any
from uuid import uuid4
from deeptutor.services.path_service import get_path_service
from .embedding_endpoint import ... | 253 | 10,860 |
DeepTutor | deeptutor/services/config/runtime_settings.py | .py | from __future__ import annotations
from copy import deepcopy
from dataclasses import dataclass
import json
import os
from pathlib import Path
from typing import Any, Callable
from deeptutor.services.file_io import atomic_write_json as _atomic_write_json
from deeptutor.services.path_service import get_path_service
fr... | 1,136 | 50,336 |
DeepTutor | deeptutor/services/config/embedding_endpoint.py | .py | """Embedding endpoint URL helpers.
Embedding adapters post to the configured URL exactly. These helpers keep the
user-visible Settings value aligned with provider-specific endpoint paths.
"""
from __future__ import annotations
from urllib.parse import parse_qsl, quote, urlencode, urlparse
GEMINI_DEFAULT_EMBEDDING_M... | 271 | 11,105 |
DeepTutor | deeptutor/services/config/loader.py | .py | #!/usr/bin/env python
"""
Configuration Loader
====================
Unified configuration loading for all DeepTutor modules.
Provides YAML configuration loading, path resolution, and language parsing.
"""
import asyncio
from pathlib import Path
from typing import Any
import yaml
from deeptutor.runtime.home import g... | 326 | 11,570 |
DeepTutor | deeptutor/services/config/context_window_detection.py | .py | """Detect or suggest a model context window during settings diagnostics."""
from __future__ import annotations
from collections.abc import Callable, Iterable, Mapping
from dataclasses import dataclass
from datetime import datetime, timezone
import logging
from typing import Any
import aiohttp
from deeptutor.service... | 220 | 7,008 |
DeepTutor | deeptutor/services/config/knowledge_base_config.py | .py | from __future__ import annotations
import json
import logging
from pathlib import Path
from typing import Any
from deeptutor.services.path_service import get_path_service
from deeptutor.services.rag.factory import (
DEFAULT_PROVIDER,
KNOWN_PROVIDERS,
has_ready_provider_index,
normalize_provider_name,
... | 240 | 9,722 |
DeepTutor | deeptutor/services/voice/__init__.py | .py | """Voice services — text-to-speech and speech-to-text.
Public facade used by the API router and the config test runner. Config is
resolved from the model catalog (``services.tts`` / ``services.stt``) exactly
like embedding/LLM, so voice providers are configured through the same
Settings catalog UI.
"""
from __future_... | 75 | 2,428 |
DeepTutor | deeptutor/services/voice/config.py | .py | """Resolved runtime configuration for voice (TTS / STT) providers.
These dataclasses are the read-side adapter between the model catalog
(``services.tts`` / ``services.stt``) and the HTTP adapters. They mirror the
shape of :class:`ResolvedEmbeddingConfig` so a single OpenAI-compatible
adapter can cover OpenAI, Groq, S... | 73 | 2,346 |
DeepTutor | deeptutor/services/voice/base.py | .py | """Base abstractions and shared helpers for voice providers."""
from __future__ import annotations
from abc import ABC, abstractmethod
import logging
import re
from deeptutor.services.voice.config import (
AUTH_API_KEY_HEADER,
AUTH_TOKEN,
STTConfig,
TTSConfig,
)
logger = logging.getLogger(__name__)
... | 145 | 4,731 |
DeepTutor | deeptutor/services/voice/adapters/__init__.py | .py | """Voice adapter registry.
Adapters are stateless singletons keyed by the ``adapter`` field on the
resolved config. The OpenAI-compatible pair covers OpenAI, Groq, SiliconFlow,
OpenRouter, Azure OpenAI and local vLLM/LM Studio; add bespoke providers
(DashScope native, ElevenLabs, Gemini, Deepgram) by registering new k... | 48 | 1,390 |
DeepTutor | deeptutor/services/voice/adapters/openai_compat.py | .py | """OpenAI-compatible HTTP adapters for TTS and STT.
A single pair of adapters covers the whole OpenAI-`/v1/audio/*` cluster —
OpenAI, Groq, SiliconFlow, OpenRouter, Azure OpenAI and local vLLM/LM Studio —
by varying ``base_url`` / ``api_key`` / ``model`` and a couple of config flags
(``auth_style``, ``api_version``, `... | 379 | 14,062 |
DeepTutor | deeptutor/services/model_selection/runtime.py | .py | """Runtime helpers for request-scoped model selection."""
from __future__ import annotations
from contextvars import Token
from typing import Any
from deeptutor.services.config.provider_runtime import ResolvedLLMConfig, resolve_llm_runtime_config
from deeptutor.services.llm import config as llm_config_module
from de... | 55 | 1,927 |
DeepTutor | deeptutor/services/model_selection/__init__.py | .py | """Model selection services for request-scoped runtime switching."""
from .llm import LLMSelection, apply_llm_selection_to_catalog, list_llm_options
__all__ = ["LLMSelection", "apply_llm_selection_to_catalog", "list_llm_options"]
| 6 | 232 |
DeepTutor | deeptutor/services/model_selection/llm.py | .py | """Helpers for selecting configured LLM models without mutating settings."""
from __future__ import annotations
from copy import deepcopy
from dataclasses import dataclass
from typing import Any
from deeptutor.services.provider_registry import find_by_name
@dataclass(frozen=True, slots=True)
class LLMSelection:
... | 139 | 5,178 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.