__init__.py
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
Embeddings module.
Important: keep package import lightweight.
Some callers do:
- `from embeddings import TextEmbeddingEncoder`
- `from embeddings import BgeEncoder` (deprecated alias)
- `from embeddings import CLIPImageEncoder`
But the underlying implementations may import heavy optional deps (Pillow, torch, etc).
To avoid importing those at package import time (and to allow the embedding service to boot
without importing client code), we provide small lazy factories here.
"""
class TextEmbeddingEncoder(object):
"""Lazy factory for `embeddings.text_encoder.TextEmbeddingEncoder`."""
def __new__(cls, *args, **kwargs):
from .text_encoder import TextEmbeddingEncoder as _Real
return _Real(*args, **kwargs)
class BgeEncoder(TextEmbeddingEncoder):
"""Deprecated backward-compatible alias for old class name."""
class CLIPImageEncoder(object):
"""Lazy factory for `embeddings.image_encoder.CLIPImageEncoder`."""
def __new__(cls, *args, **kwargs):
from .image_encoder import CLIPImageEncoder as _Real
return _Real(*args, **kwargs)
__all__ = ["TextEmbeddingEncoder", "BgeEncoder", "CLIPImageEncoder"]