Skip to content

Commit

Permalink
remove blanket try/except
Browse files Browse the repository at this point in the history
  • Loading branch information
agola11 committed Dec 10, 2024
1 parent e043a7d commit d77bd0e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions python/langsmith/evaluation/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1929,17 +1929,14 @@ def _evaluators_include_attachments(
return False

def evaluator_has_attachments(evaluator: Any) -> bool:
try:
sig = inspect.signature(evaluator)
params = list(sig.parameters.values())
positional_params = [
p
for p in params
if p.kind in (p.POSITIONAL_ONLY, p.POSITIONAL_OR_KEYWORD)
]
return any(p.name == "attachments" for p in positional_params)
except Exception:
if not callable(evaluator):
return False
sig = inspect.signature(evaluator)
params = list(sig.parameters.values())
positional_params = [
p for p in params if p.kind in (p.POSITIONAL_ONLY, p.POSITIONAL_OR_KEYWORD)
]
return any(p.name == "attachments" for p in positional_params)

return any(evaluator_has_attachments(e) for e in evaluators)

Expand Down

0 comments on commit d77bd0e

Please sign in to comment.