diff --git a/js/llm.ts b/js/llm.ts index 46822b3..f37c5da 100644 --- a/js/llm.ts +++ b/js/llm.ts @@ -125,8 +125,6 @@ export async function OpenAIClassifier( content: m.content && mustache.render(m.content as string, renderArgs), })); - let ret = null; - let validityScore = 1; try { const resp = await cachedChatCompletion( { @@ -145,7 +143,7 @@ export async function OpenAIClassifier( ); if (resp.choices.length > 0) { - ret = { + return { name, ...parseResponse(resp.choices[0].message!, choiceScores), }; @@ -153,15 +151,12 @@ export async function OpenAIClassifier( throw new Error("Empty response from OpenAI"); } } catch (error) { - validityScore = 0; - ret = { + return { name, score: 0, error: `${error}`, }; } - - return ret; } function parseResponse( diff --git a/py/autoevals/llm.py b/py/autoevals/llm.py index 6fa21ff..2ac8363 100644 --- a/py/autoevals/llm.py +++ b/py/autoevals/llm.py @@ -153,26 +153,18 @@ def _postprocess_response(self, resp): raise ValueError("Empty response from OpenAI") async def _run_eval_async(self, output, expected, **kwargs): - validity_score = 1 try: return self._postprocess_response( await arun_cached_request(**self._request_args(output, expected, **kwargs)) ) except Exception as e: - validity_score = 0 return Score(name=self.name, score=0, error=e) - finally: - current_span().log(scores={f"{self._name()} parsed": validity_score}) def _run_eval_sync(self, output, expected, **kwargs): - validity_score = 1 try: return self._postprocess_response(run_cached_request(**self._request_args(output, expected, **kwargs))) except Exception as e: - validity_score = 0 return Score(name=self.name, score=0, error=e) - finally: - current_span().log(scores={f"{self._name()} parsed": validity_score}) @dataclass