in experiments/arena/prompts/utils.py [0:0]
def _load_prompts(self):
"""Loads prompts from the GCS blob into memory. Falls back to default prompt list."""
self.prompts = {"prompts": []} #initialize to empty list to avoid errors.
try:
if self.prompts_location.startswith("gs://"):
prompt_file = download_gcs_blob(gs_uri=self.prompts_location)
prompt_file = prompt_file.decode("utf-8")
self.prompts = json.loads(prompt_file)
else:
with open(config.DEFAULT_PROMPTS, "r") as f:
self.prompts = json.load(f)
except gapic_exceptions.NotFound:
print("Error: Requested blob not found, loading the default prompt list.")
self.prompts_location = config.DEFAULT_PROMPTS
except gapic_exceptions.Unauthorized:
print("Error: Unauthorized to access requested blob.")
except json.JSONDecodeError as e:
print("Error: Requested blob is not a valid JSON. ", e)
except UnicodeDecodeError as e:
print("Error: Failed to decode requested blob. ", e)
except FileNotFoundError:
print("Error: imagen_prompts.json not found.")