Heya, any tips on how to address a Gateway timeout error when querying for requests?
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
</body>
</html>
Here's roughly what I'm doing:
HELICONE_URL = "https://api.helicone.ai/v1/request/query"
HELICONE_API_KEY = os.getenv("HELICONE_API_KEY")
HELICONE_HEADERS = {
"Content-Type": "application/json",
"authorization": f"Bearer {HELICONE_API_KEY}",
}
def get_helicone_requests(
project: str, created_time_start: str, created_time_end: str, limit_n: int
):
"""
Get Helicone requests for a particular project.
"""
print(
f"getting helicone requests for {project}, created time start {created_time_start}, created time end {created_time_end}..."
)
payload = {
"filter": {
"request": {
"user_id": {"equals": project},
"created_at": {
"gte": created_time_start,
"lte": created_time_end,
},
}
},
"limit": limit_n,
"sort": {"created_at": "asc"},
}
try:
response = requests.post(
HELICONE_URL, headers=HELICONE_HEADERS, data=json.dumps(payload)
)
if response.status_code != 200:
raise RuntimeError(f"Error occurred, response: {response.text}")
return response.json().get("data", [])
except Exception as e:
print(f"error occured: {e}")
print(traceback.format_exc())
return []
Seems to happen sporadically but go through otherwise