-
Notifications
You must be signed in to change notification settings - Fork 614
fix:openai return base64 image str not been recognized as base64 #647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes update the handling of base64-encoded image data returned by the OpenAI image generation API. Both affected modules now ensure that base64 strings are consistently prefixed with "data:image/png;base64," before caching, guaranteeing proper data URI formatting for PNG images. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (8)**/*.{ts,tsx,js,jsx,vue}📄 CodeRabbit Inference Engine (CLAUDE.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit Inference Engine (CLAUDE.md)
Files:
src/main/**/*.ts📄 CodeRabbit Inference Engine (CLAUDE.md)
Files:
src/main/presenter/**/*.ts📄 CodeRabbit Inference Engine (CLAUDE.md)
Files:
src/main/presenter/llmProviderPresenter/providers/*.ts📄 CodeRabbit Inference Engine (CLAUDE.md)
Files:
**/*.{js,jsx,ts,tsx}📄 CodeRabbit Inference Engine (.cursor/rules/development-setup.mdc)
Files:
src/{main,renderer}/**/*.ts📄 CodeRabbit Inference Engine (.cursor/rules/electron-best-practices.mdc)
Files:
src/main/**/*.{ts,js,tsx,jsx}📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)
Files:
🧠 Learnings (2)src/main/presenter/llmProviderPresenter/providers/openAICompatibleProvider.ts (10)Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR src/main/presenter/llmProviderPresenter/providers/openAIResponsesProvider.ts (10)Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR Learnt from: CR 🔇 Additional comments (2)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
LGTM |
在使用OpenAI的图像生成API的时候,返回的图片不能被正确的显示

日志中debug显示为 图片格式不支持
参考内部实现,发现OpenAI返回的图片对象在 b64_json 字段中,
该字段openai只会返回base64字符串, 但是不会返回前面的转义标识符
因此在后续cache的时候会被认为是不支持的格式
以防未来这个字段也会返回
data:image/png;base64
在传递到cache方法的时候加了一个判断
添加之后OpenAI图片可以被正确的识别和返回
Summary by CodeRabbit