INNER CODE UNIT · Python
deadline
skyportal/skyportal · services/assistant/app.py:182
deadline = time.monotonic() + budget
with requests.post(
f"{endpoint['base_url'].rstrip('/')}/chat/completions",
headers=headers,
json=payload,
stream=True,
timeout=min(STALL_TIMEOUT, budget),
) as response:
if response.status_code >= 400:
# The status alone says nothing: a refused request looks identical
# whether the context was too long, a tool schema was rejected or
# the model was unavailable, and the answer the user sees is the
# same sentence either way. The server's own words tell them apart.
log(
f"model refused the request: {response.status_code} "
f"{response.text[:600]} "
f"(messages={len(messages)}, tools={len(tools)}, "