Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions eval_protocol/training/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
from .gepa_trainer import GEPATrainer
from .gepa_utils import (
DSPyModuleType,
DSPyModuleFactory,
create_single_turn_program,
create_signature,
build_reflection_lm,
)
from typing import TYPE_CHECKING

# GEPA/DSPy-related imports are optional - only available when dspy extra is installed
# Use: pip install eval-protocol[dspy]
_DSPY_AVAILABLE = False
try:
import dspy # noqa: F401

_DSPY_AVAILABLE = True
except ImportError:
pass


def _raise_dspy_import_error(name: str):
"""Raise a helpful error when dspy is not installed."""
raise ImportError(f"'{name}' requires the 'dspy' extra. Install it with: pip install eval-protocol[dspy]")


if TYPE_CHECKING or _DSPY_AVAILABLE:
from .gepa_trainer import GEPATrainer
from .gepa_utils import (
DSPyModuleType,
DSPyModuleFactory,
create_single_turn_program,
create_signature,
build_reflection_lm,
)

__all__ = [
"GEPATrainer",
Expand All @@ -17,3 +36,10 @@
# Reflection LM helpers
"build_reflection_lm",
]


def __getattr__(name: str):
"""Lazy loading for dspy-dependent exports."""
if name in __all__ and not _DSPY_AVAILABLE:
_raise_dspy_import_error(name)
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ dependencies = [
"deepdiff>=6.0.0",
"websockets>=15.0.1",
"fastapi>=0.116.1",
"dspy>=3.0.0",
"fireworks-ai==1.0.0a18",
]

Expand Down Expand Up @@ -132,6 +131,9 @@ braintrust = [
openenv = [
"openenv-core",
]
dspy = [
"dspy>=3.0.0",
]

# Optional deps for LangGraph example/tests
langgraph = [
Expand Down
8 changes: 5 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading