From ce24857a748024b1365f01c28d2bb9961de7b0df Mon Sep 17 00:00:00 2001 From: merwanehamadi Date: Mon, 31 Jul 2023 20:18:15 -0700 Subject: [PATCH] Return none as fallback Helicone (#228) Signed-off-by: Merwane Hamadi --- agbenchmark/utils/get_data_from_helicone.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/agbenchmark/utils/get_data_from_helicone.py b/agbenchmark/utils/get_data_from_helicone.py index 87dfe0ae..07a9c11f 100644 --- a/agbenchmark/utils/get_data_from_helicone.py +++ b/agbenchmark/utils/get_data_from_helicone.py @@ -58,21 +58,21 @@ query ExampleQuery($properties: [PropertyFilter!]){ "operationName": operation_name, }, ) - response.raise_for_status() # Raises a HTTPError if the response was an unsuccessful status code data = response.json() except requests.HTTPError as http_err: print(f"HTTP error occurred: {http_err}") - raise # Re-raise the exception to stop execution + return None # Re-raise the exception to stop execution except json.JSONDecodeError: print(f"Invalid JSON response: {response.text if response else 'No response'}") - raise + return None except Exception as err: print(f"Other error occurred: {err}") - raise + return None if data is None or data.get("data") is None: - raise ValueError("Invalid response received from server: no data") + print("Invalid response received from server: no data") + return None return ( data.get("data", {}).get("aggregatedHeliconeRequest", {}).get("costUSD", None)