Skip to content

Commit

Permalink
move check
Browse files Browse the repository at this point in the history
  • Loading branch information
tcapelle committed Feb 5, 2025
1 parent 14f6e17 commit 7c1ed3a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 4 additions & 6 deletions weave/scorers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
try:
from litellm import acompletion # noqa: F401
except ImportError:
raise ImportError(
"litellm is required to use the LLM-powered scorers, please install it with `pip install litellm`"
)
from weave.scorers.initialization import check_litellm_installation

# Make sure litellm is available
check_litellm_installation()

from weave.scorers.classification_scorer import (
MultiTaskBinaryClassificationF1,
Expand Down
13 changes: 13 additions & 0 deletions weave/scorers/initialization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Module to handle initialization of LLM-related dependencies."""


def check_litellm_installation():
"""Check if litellm is installed and raise an informative error if not."""
try:
from litellm import acompletion # noqa: F401

return acompletion
except ImportError:
raise ImportError(
"litellm is required to use the LLM-powered scorers, please install it with `pip install litellm`"
)

0 comments on commit 7c1ed3a

Please sign in to comment.