Skip to content

Commit

Permalink
Move score tracing into sdk framework.
Browse files Browse the repository at this point in the history
  • Loading branch information
manugoyal committed Oct 16, 2023
1 parent 9f160ac commit 0ddfa62
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions py/autoevals/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,10 @@ def __post_init__(self):

class Scorer(ABC):
async def eval_async(self, output, expected=None, **kwargs):
with current_span().start_span(
name=self._name(), input={"output": output, "expected": expected, **kwargs}
) as span:
try:
result = await self._run_eval_async(output, expected, **kwargs)
except Exception as e:
result = Score(name=self._name(), score=0, error=e)

score_output = result.as_dict()
score_metadata = score_output.pop("metadata", {})
span.log(output=score_output, metadata=score_metadata)
return result
try:
return await self._run_eval_async(output, expected, **kwargs)
except Exception as e:
return Score(name=self._name(), score=0, error=e)

def eval(self, output, expected=None, **kwargs):
try:
Expand Down

0 comments on commit 0ddfa62

Please sign in to comment.