Niklas Hoepner commited on
Commit
2a3f461
·
1 Parent(s): 9be3985

Catch LangChain error

Browse files
Files changed (1) hide show
  1. L3Score.py +10 -5
L3Score.py CHANGED
@@ -149,12 +149,17 @@ class L3Score(evaluate.Metric):
149
  L3Score = 0
150
  count = 0
151
  for question, prediction, reference in zip(questions, predictions, references):
152
- response = llm.invoke(
153
- (
154
- "human",
155
- _PROMPT.format(question=question, gt=reference, answer=prediction),
 
 
156
  )
157
- )
 
 
 
158
  score = self._calculate_L3Score(
159
  response.response_metadata["logprobs"]["content"][0]["top_logprobs"]
160
  )
 
149
  L3Score = 0
150
  count = 0
151
  for question, prediction, reference in zip(questions, predictions, references):
152
+ try:
153
+ response = llm.invoke(
154
+ (
155
+ "human",
156
+ _PROMPT.format(question=question, gt=reference, answer=prediction),
157
+ )
158
  )
159
+ except Exception as e:
160
+ print(e)
161
+ continue
162
+
163
  score = self._calculate_L3Score(
164
  response.response_metadata["logprobs"]["content"][0]["top_logprobs"]
165
  )