Files
DeepTutor/deeptutor/services/embedding/adapters/__init__.py
Geonwoo Jeong 2ad3640cd1 feat(embedding): support Gemini Embedding 2 over the native API (#744)
Adds a Gemini embedding adapter that speaks the native :batchEmbedContents endpoint, so Embedding 2's retrieval-role prompt instructions and configurable output dimensionality are available, and threads a retrieval role (query vs document) from both RAG pipelines down to the client.

The role is opt-in per adapter: Jina and the OpenAI-compatible backends keep sending exactly what they sent before, because adding a task hint changes the vectors and would invalidate indexes already built. For the same reason only Embedding 2 defaults to the native endpoint — an existing gemini-embedding-001 profile stays on the OpenAI-compatible path unless its endpoint is set to the native URL explicitly.

Also redacts credential-like query parameters from endpoint values shown in errors and diagnostics.
2026-08-03 21:31:29 +08:00

41 lines
1.3 KiB
Python

"""Embedding adapter implementations and backend registry."""
from .base import (
BaseEmbeddingAdapter,
EmbeddingProviderError,
EmbeddingRequest,
EmbeddingResponse,
)
from .cohere import CohereEmbeddingAdapter
from .dashscope_native import DashScopeMultiModalEmbeddingAdapter
from .gemini import GeminiEmbeddingAdapter
from .jina import JinaEmbeddingAdapter
from .ollama import OllamaEmbeddingAdapter
from .openai_compatible import OpenAICompatibleEmbeddingAdapter
from .openai_sdk import OpenAISDKEmbeddingAdapter
ADAPTER_BACKENDS: dict[str, type[BaseEmbeddingAdapter]] = {
"openai_compat": OpenAICompatibleEmbeddingAdapter,
"openai_sdk": OpenAISDKEmbeddingAdapter,
"cohere": CohereEmbeddingAdapter,
"jina": JinaEmbeddingAdapter,
"ollama": OllamaEmbeddingAdapter,
"dashscope_native": DashScopeMultiModalEmbeddingAdapter,
"gemini": GeminiEmbeddingAdapter,
}
__all__ = [
"ADAPTER_BACKENDS",
"BaseEmbeddingAdapter",
"EmbeddingProviderError",
"EmbeddingRequest",
"EmbeddingResponse",
"OpenAICompatibleEmbeddingAdapter",
"OpenAISDKEmbeddingAdapter",
"DashScopeMultiModalEmbeddingAdapter",
"GeminiEmbeddingAdapter",
"JinaEmbeddingAdapter",
"CohereEmbeddingAdapter",
"OllamaEmbeddingAdapter",
]