Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
Return none as fallback Helicone
Browse files Browse the repository at this point in the history
Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com>
  • Loading branch information
waynehamadi committed Aug 1, 2023
1 parent 5a6f663 commit 765a595
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions agbenchmark/utils/get_data_from_helicone.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ def get_data_from_helicone(challenge: str) -> Optional[float]:
"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)
Expand Down

0 comments on commit 765a595

Please sign in to comment.