Skip to content

Commit f542d08

Browse files
committed
fix API
1 parent e3ce58c commit f542d08

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

piedomains/__init__.py

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,44 @@
1-
from .api import DomainClassifier, classify_domains
2-
from .data_collector import DataCollector
3-
from .image import ImageClassifier
4-
from .llm.config import LLMConfig
5-
from .llm_classifier import LLMClassifier
6-
from .text import TextClassifier
1+
"""
2+
Piedomains: Domain content classification library.
3+
4+
This module provides lazy imports to avoid dependency issues when
5+
optional dependencies (like playwright) are not installed.
6+
"""
7+
8+
9+
def __getattr__(name):
10+
"""Lazy import handler for piedomains modules."""
11+
if name == "DomainClassifier":
12+
from .api import DomainClassifier
13+
14+
return DomainClassifier
15+
elif name == "classify_domains":
16+
from .api import classify_domains
17+
18+
return classify_domains
19+
elif name == "DataCollector":
20+
from .data_collector import DataCollector
21+
22+
return DataCollector
23+
elif name == "TextClassifier":
24+
from .text import TextClassifier
25+
26+
return TextClassifier
27+
elif name == "ImageClassifier":
28+
from .image import ImageClassifier
29+
30+
return ImageClassifier
31+
elif name == "LLMClassifier":
32+
from .llm_classifier import LLMClassifier
33+
34+
return LLMClassifier
35+
elif name == "LLMConfig":
36+
from .llm.config import LLMConfig
37+
38+
return LLMConfig
39+
else:
40+
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
41+
742

843
__all__ = [
944
"DomainClassifier",

piedomains/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ def configure_llm(
368368
... )
369369
"""
370370
# Import LLM classes - these are required dependencies
371-
from .llm import LLMClassifier
372371
from .llm.config import LLMConfig
372+
from .llm_classifier import LLMClassifier
373373

374374
self._llm_config = LLMConfig(
375375
provider=provider,

0 commit comments

Comments
 (0)