fix: app-chat generation images add prefix prompt#396
Open
keung67 wants to merge 2 commits intochenyme:mainfrom
Open
fix: app-chat generation images add prefix prompt#396keung67 wants to merge 2 commits intochenyme:mainfrom
keung67 wants to merge 2 commits intochenyme:mainfrom
Conversation
## Problem Grok silently updated their web API: 1. Image generation via `app-chat` with explicit `modelName`/`modelMode` no longer triggers image generation - Grok returns text instead 2. Image results moved from `modelResponse.generatedImageUrls` to `cardAttachment.jsonData.image_chunk` format 3. Image editing uses a different card type (`render_edited_image`) than generation (`render_generated_image`) This broke both `/v1/images/generations` and `/v1/images/edits`. ## Root Cause Captured browser network requests and compared with grok2api payloads: - Browser uses `modeId: "auto"` without `modelName`/`modelMode` - Browser sends explicit `toolOverrides` disabling search tools - Browser sends `disableMemory: false, temporary: false` for edits ## Fix **app_chat.py**: `build_payload()` supports `model=None` — omits `modelName`/`modelMode` fields, allowing `modeId`-based routing. **image.py**: `_stream_app_chat()` and `_collect_app_chat()` now use `model=None, mode=None` with `modeId: "auto"` in request_overrides. **image_edit.py**: - `ImageStreamProcessor` and `ImageCollectProcessor` parse new `cardAttachment` format with `image_chunk.imageUrl` (progress >= 100) - Match both `render_generated_image` and `render_edited_image` types - Image URL: `https://assets.grok.com/{image_chunk.imageUrl}` - Edit path uses `disableMemory=false, temporary=false` and browser-matching `toolOverrides` to prevent search fallback
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.
Summary
為圖片生成模型 (
grok-imagine-1.0與grok-imagine-1.0-fast) 自動加上"generation image: "的提示詞前綴。這修復了當使用者透過 app-chat 的 REST 方式 (
/chat/completions) 或是透過前端/v1/function/imagine呼叫生圖模型時,因為缺乏明確的圖像生成指令,導致 Grok 模型誤判為一般聊天對話,最終「只生成文字而不生成圖片」的問題。同樣在grok.com官網測試對話,若不加類似"生成圖片"的提示詞,則被當成一般對話生成文字而非生圖。
Changes
具體修改:
/chat/completionsAPI 中,針對圖片模型攔截並自動在 prompt 開頭加上"generation image: "前綴。Related Issues
Verification
验证说明: