chore: 调整图像输入size大小限制#1769
Conversation
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Greptile SummaryThis PR raises the per-image upload limit from 4 MB to 50 MB (matching the Azure OpenAI recommendation), increases the maximum image count from 10 to 16, and recalculates
Confidence Score: 3/5The limit relaxation itself is correct, but the trace-logging path now base64-encodes up to 800 MB of image data per request, which can exhaust memory under concurrent load. The core limit change is correct and well-tested. The concern is the trace-logging function that base64-encodes every uploaded image in-process: at 16 x 50 MB a single request can hold ~2.7 GB simultaneously, and concurrent uploads multiply that quickly. llm/transformer/openai/image_inbound.go — specifically the buildMultipartJSONBody call sites in transformEditRequest and transformVariationRequest. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Incoming HTTP Request] --> B{len body > maxImageBodySize ~816 MB?}
B -- Yes --> ERR1[Error: request body too large]
B -- No --> C[Parse multipart parts]
C --> D{Part has filename?}
D -- No: field --> E{len value > maxImageFileSize 50 MB?}
E -- Yes --> ERR2[Error: field too large]
E -- No --> F[Store as form field]
D -- Yes: file --> G{imageCount > 16?}
G -- Yes --> ERR3[Error: too many images]
G -- No --> H{len data > maxImageFileSize 50 MB?}
H -- Yes --> ERR4[Error: file too large]
H -- No --> I{Allowed MIME type?}
I -- No --> ERR5[Error: unsupported image type]
I -- Yes --> J[Append to formData.Images]
J --> C
F --> C
C --> K[buildMultipartJSONBody base64-encodes ALL images for trace logging]
K --> L[Return llm.Request]
|
| maxImageCount = 10 | ||
| defaultMaxImageFileSize = 50 * 1024 * 1024 | ||
| maxImageCount = 16 | ||
| maxImageBodySize = defaultMaxImageFileSize*maxImageCount + 16*1024*1024 |
There was a problem hiding this comment.
maxImageBodySize is derived from the compile-time constant defaultMaxImageFileSize, not from the runtime maxImageFileSize variable. If AXONHUB_MAX_IMAGE_FILE_SIZE is set to a value larger than 50 MB, the body-size gate won't reflect it, so the early rejection on line 389 becomes inaccurate. Consider deriving this guard dynamically, or at least document the intentional decoupling.
| maxImageBodySize = defaultMaxImageFileSize*maxImageCount + 16*1024*1024 | |
| // maxImageBodySize is intentionally based on defaultMaxImageFileSize (not the | |
| // runtime maxImageFileSize) and serves only as a fast-path guard before multipart | |
| // parsing. Per-file size is enforced per-part using maxImageFileSize. | |
| maxImageBodySize = defaultMaxImageFileSize*maxImageCount + 16*1024*1024 |
There was a problem hiding this comment.
将其交给用户进行选择,而不是网关层面锁死了大小
* fix: 修复了多图输入情况下转发失效的问题 * chore: 添加了登陆后页面标题自定义配置项 * Update frontend/src/features/system/components/brand-settings.tsx Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * feat: raise image upload limits to 50MB per file and 16 images --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: YuNing Shen <yuning.shen@starbucks.cn>
当前图像输入限制为 4MB,这在实际场景下不太实用,本次 PR 将其同步为 Azure 文档的推荐值(50MB)
可参考:https://learn.microsoft.com/en-us/azure/foundry/openai/how-to/dall-e?tabs=command-line%2Ckeyless%2Ctypescript-keyless&pivots=programming-language-studio