Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions deepeval/benchmarks/gsm8k/gsm8k.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional, Dict
from typing import List, Optional, Dict, Union, Tuple, Any
from tqdm import tqdm

from deepeval.dataset import Golden
Expand Down Expand Up @@ -95,11 +95,19 @@ def predict(self, model: DeepEvalBaseLLM, golden: Golden) -> Dict:

# Enforced model generation
try:
res: NumberSchema = model.generate(
res: Union[NumberSchema, Tuple[Any]] = model.generate(
prompt=prompt, schema=NumberSchema
)
prediction = str(res.answer)
except TypeError:
if isinstance(res, tuple):
if len(res) == 1:
res = res[0]
else:
raise TypeError
elif isinstance(res, NumberSchema):
prediction = str(res.answer)
else:
raise TypeError # Much eaiser to just add confinement instructions
except (TypeError, AttributeError):
prompt += f"\n\n{self.confinement_instructions}"
prediction = model.generate(prompt)

Expand Down
2 changes: 1 addition & 1 deletion deepeval/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def unset_local_embeddings_env():


#############################################
# Ollama Integration ########################
# Gemini Integration ########################
#############################################


Expand Down
2 changes: 1 addition & 1 deletion deepeval/metrics/g_eval/g_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def is_successful(self) -> bool:
self.success = False
else:
try:
self.score >= self.threshold
self.success = self.score >= self.threshold
except:
self.success = False
return self.success
Expand Down
Loading