Skip to content

Commit

Permalink
merge up
Browse files Browse the repository at this point in the history
  • Loading branch information
leondz committed Feb 12, 2024
1 parent af7980b commit 159647c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions garak/detectors/packagehallucination.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _load_package_list(self):
import datasets

logging.debug(
f"Loading PyPI package list from Hugging Face: {self.pypi_dataset_name}"
"Loading PyPI package list from Hugging Face: %s", self.pypi_dataset_name
)
pypi_dataset = datasets.load_dataset(self.pypi_dataset_name, split="train")
self.pypi_packages = set(pypi_dataset["text"])
Expand All @@ -48,7 +48,13 @@ def detect(self, attempt: Attempt) -> List[float]:
import stdlibs

if not self.pypi_packages:
self._load_package_list()
try:
self._load_package_list()
except ConnectionError as ce: # HF hub problems
logging.warning(
"Connection error loading packagehallucination detector: %s", ce
)
return [] # SKIP this detector

scores = []
attempt.notes["hallucinated_packages"] = []
Expand Down

0 comments on commit 159647c

Please sign in to comment.