Add grok-superimage support, safer SSE streaming, image recovery & proxy/ retry improvements#50
Merged
lijirou12 merged 2 commits intoFeb 27, 2026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
grok-superimage-1.0with unified server-side image parameters and safer streaming semantics for chat image outputs.Description
grok-superimage-1.0ModelInfoand a server-side config section[superimage]inconfig.defaults.tomland admin UI support (app/static/admin/js/config.js) to controln,size, andresponse_format, and addedSUPERIMAGE_MODEL_IDand_superimage_server_image_config()inapp/api/v1/chat.pyso the server overrides clientimage_configfor this model.app/api/v1/chat.py:_safe_sse_stream()converts exceptions into SSEerrorevents and yields a finaldata: [DONE], and_streaming_error_response()to return a one-shot SSE error response for sync exceptions during stream setup; integrated these into image generation/edit and general chat/video streaming return paths.app/services/grok/services/image.py: added configurable parallel recovery attempts controlled byimage.blocked_parallel_attempts, run extra parallel_fetch_batchattempts when finals are insufficient, and raiseUpstreamExceptionwhen still insufficient after recovery.image.pyandimage_edit.py: only expose final images for chat-format streams, preserve original imagine image name forgrok-superimage-1.0(no-finalsuffix), ensure a final empty chat chunk anddata: [DONE]are emitted if no intermediate chat chunk was emitted, and avoid exposing preview partials for chat streams.app/services/reverse/ws_imagine.py: classify final images by byte-size threshold (final_min_bytes) rather than filename extension, log and raise a_BlockedErroron suspected blocked/review conditions to trigger recovery behavior.app/services/grok/utils/retry.py: addedtransient_upstream()that detects transient upstream errors/timeouts; used inapp/services/grok/services/chat.pyto attempt switching tokens on transient upstream errors when alternatives exist.app/services/reverse/app_chat.py: normalize proxy URLs (convertsocks5://->socks5h://,socks4://->socks4a://), preferproxyparam for SOCKS proxies while usingproxiesfor HTTP/HTTPS, and adjust timeout selection logic.get_storage->resolve_storageand router functionget_storage->get_storage_modeto avoid name collision inapp/api/v1/admin_api/config.py.readme.mdto list the new model and behavior notes, and added new default config keys inconfig.defaults.tomland localized admin UI strings inapp/static/admin/js/config.js.Testing
pytest -qand all tests passed.flake8and no new lint errors were reported.POST /v1/chat/completionsfor an image model stream and confirmed SSE error payloads andgrok-superimage-1.0behavior (server-siden/size/response_format) were emitted as expected.Codex Task