Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/dataplane/reverse/transport/asset_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

_UPLOAD_URL = "https://grok.com/rest/app-chat/upload-file"
_X_USER_ID_RE = re.compile(r"(?:^|;\s*)x-userid=([^;]+)")
_URL_FETCH_HEADERS = {
"Accept": "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8",
}

# Global semaphore — limits concurrent upload_file() calls across all requests.
# Initialised lazily on first call so the event loop is guaranteed to be running.
Expand Down Expand Up @@ -186,10 +189,13 @@ async def upload_from_input(token: str, file_input: str) -> tuple[str, str]:
proxy = await get_proxy_runtime()
lease = await proxy.acquire()
try:
headers = build_http_headers(token, lease=lease)
kwargs = build_session_kwargs(lease=lease)
async with ResettableSession(**kwargs) as session:
resp = await session.get(file_input, headers=headers, timeout=30.0)
resp = await session.get(
file_input,
headers=_URL_FETCH_HEADERS,
timeout=30.0,
)
raw = resp.content
if resp.status_code != 200:
await proxy.feedback(
Expand Down