Merge pull request #438 from chenyme/fix_token

chore: improve error handling in xai_usage.py
This commit is contained in:
Chenyme authored and GitHub committed 2026-04-10 18:18:23 +08:00
commit f32aaabae0
6 files changed
+10 -6

No files matched your search

+1 -1
View File
@@ -71,7 +71,7 @@ RUN mkdir -p /app/data /app/logs \
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD wget -qO /dev/null http://localhost:${SERVER_PORT}/health || exit 1
CMD ["sh", "-c", "wget -qO /dev/null http://127.0.0.1:${SERVER_PORT}/health || exit 1"]
ENTRYPOINT ["/app/scripts/entrypoint.sh"]
CMD ["sh", "-c", "exec granian --interface asgi --host ${SERVER_HOST} --port ${SERVER_PORT} --workers ${SERVER_WORKERS} app.main:app"]
+1 -1
View File
@@ -13,7 +13,7 @@ MODELS: tuple[ModelSpec, ...] = (
# Basic+
ModelSpec("grok-4.20-0309-non-reasoning", ModeId.FAST, Tier.BASIC, Capability.CHAT, True, "Grok 4.20 0309 Non-Reasoning"),
ModelSpec("grok-4.20-0309", ModeId.AUTO, Tier.BASIC, Capability.CHAT, True, "Grok 4.20-0309"),
ModelSpec("grok-4.20-0309", ModeId.AUTO, Tier.BASIC, Capability.CHAT, True, "Grok 4.20 0309"),
ModelSpec("grok-4.20-0309-reasoning", ModeId.EXPERT, Tier.BASIC, Capability.CHAT, True, "Grok 4.20 0309 Reasoning"),
# Super+
ModelSpec("grok-4.20-0309-non-reasoning-super", ModeId.FAST, Tier.SUPER, Capability.CHAT, True, "Grok 4.20 0309 Non-Reasoning Super"),
-1
View File
@@ -120,7 +120,6 @@ async def apply_changes(
table._update_slot(existing, **args, old_tags=old_tags, new_tags=tags)
else:
table._append_slot(record.token, **args, tags=tags)
table.size += 1
changed = True
+6 -1
View File
@@ -1,5 +1,7 @@
"""XAI rate-limits API protocol — fetch live quota data per mode."""
import asyncio
import orjson
from app.platform.errors import UpstreamError
@@ -124,7 +126,10 @@ async def _fetch_one(token: str, mode_id: int) -> object | None:
"""Fetch quota window for a single mode. Returns QuotaWindow or None."""
mode_name = _MODE_NAMES.get(mode_id, "auto")
try:
body = await _do_fetch(token, mode_name)
body = await asyncio.wait_for(_do_fetch(token, mode_name), timeout=25.0)
except asyncio.TimeoutError:
logger.debug("rate-limits fetch timed out: token={}... mode={}", token[:10], mode_name)
return None
except Exception as exc:
if is_invalid_credentials_error(exc):
raise
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "grok2api"
version = "2.0.2"
version = "2.0.4.rc0"
description = "Grok2API rebuilt with FastAPI, fully aligned with the latest web call format. Supports streaming and non-streaming chat, image generation/editing, deep thinking, token pool concurrency, and automatic load balancing."
readme = "README.md"
requires-python = ">=3.13"
Generated
+1 -1
View File
@@ -580,7 +580,7 @@ wheels = [
[[package]]
name = "grok2api"
version = "2.0.2"
version = "2.0.4rc0"
source = { virtual = "." }
dependencies = [
{ name = "aiohttp" },