File tree Expand file tree Collapse file tree 3 files changed +42
-12
lines changed
Expand file tree Collapse file tree 3 files changed +42
-12
lines changed Original file line number Diff line number Diff line change 1- from .gepa_trainer import GEPATrainer
2- from .gepa_utils import (
3- DSPyModuleType ,
4- DSPyModuleFactory ,
5- create_single_turn_program ,
6- create_signature ,
7- build_reflection_lm ,
8- )
1+ from typing import TYPE_CHECKING
2+
3+ # GEPA/DSPy-related imports are optional - only available when dspy extra is installed
4+ # Use: pip install eval-protocol[dspy]
5+ _DSPY_AVAILABLE = False
6+ try :
7+ import dspy # noqa: F401
8+
9+ _DSPY_AVAILABLE = True
10+ except ImportError :
11+ pass
12+
13+
14+ def _raise_dspy_import_error (name : str ):
15+ """Raise a helpful error when dspy is not installed."""
16+ raise ImportError (f"'{ name } ' requires the 'dspy' extra. Install it with: pip install eval-protocol[dspy]" )
17+
18+
19+ if TYPE_CHECKING or _DSPY_AVAILABLE :
20+ from .gepa_trainer import GEPATrainer
21+ from .gepa_utils import (
22+ DSPyModuleType ,
23+ DSPyModuleFactory ,
24+ create_single_turn_program ,
25+ create_signature ,
26+ build_reflection_lm ,
27+ )
928
1029__all__ = [
1130 "GEPATrainer" ,
1736 # Reflection LM helpers
1837 "build_reflection_lm" ,
1938]
39+
40+
41+ def __getattr__ (name : str ):
42+ """Lazy loading for dspy-dependent exports."""
43+ if name in __all__ and not _DSPY_AVAILABLE :
44+ _raise_dspy_import_error (name )
45+ raise AttributeError (f"module { __name__ !r} has no attribute { name !r} " )
Original file line number Diff line number Diff line change @@ -48,7 +48,6 @@ dependencies = [
4848 " deepdiff>=6.0.0" ,
4949 " websockets>=15.0.1" ,
5050 " fastapi>=0.116.1" ,
51- " dspy>=3.0.0" ,
5251 " fireworks-ai==1.0.0a18" ,
5352]
5453
@@ -133,6 +132,9 @@ braintrust = [
133132openenv = [
134133 " openenv-core" ,
135134]
135+ dspy = [
136+ " dspy>=3.0.0" ,
137+ ]
136138
137139# Optional deps for LangGraph example/tests
138140langgraph = [
You can’t perform that action at this time.
0 commit comments