feat(adapter-gemini): 支持 camelCase 媒体字段配置#892
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (2)
总览该PR为 Gemini 适配器添加配置选项以支持内联数据字段的不同命名风格(camelCase 或 snake_case),并重构内容处理逻辑以统一通过新工具函数生成内联数据部分。 变更Gemini 适配器内联数据命名约定支持
📊 代码审查工作量估算🎯 2 (简单) | ⏱️ ~10 分钟 诗
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces two new configuration options, useCamelCaseInlineData and useCamelCaseMimeType, to the Gemini adapter, allowing the system to toggle between camelCase and snake_case for inline data and mime type fields. It refactors the content processing logic in utils.ts to utilize these options and adds corresponding schema definitions and translations. The review feedback highlights a potential runtime error in utils.ts due to a lack of null-safety checks when processing inline data, and suggests correcting the Chinese translation in zh-CN.schema.yml to accurately refer to 'camelCase' as '驼峰式' instead of '大写' (uppercase).
| if (isGeminiInlineDataContent(part)) { | ||
| const inline = part.inline_data ?? part.inlineData | ||
| return createGeminiInlineDataPart( | ||
| plugin, | ||
| inline.data, | ||
| inline.mime_type ?? inline.mimeType | ||
| ) | ||
| } |
There was a problem hiding this comment.
在 isGeminiInlineDataContent(part) 返回 true 时,part.inline_data 或 part.inlineData 仍有可能为 undefined(例如属性存在但值为 undefined)。此外,如果 inline.data 缺失,直接访问 inline.data 会导致运行时错误,且不符合 createGeminiInlineDataPart 的参数类型要求。建议在调用前进行空值安全检查。
if (isGeminiInlineDataContent(part)) {
const inline = part.inline_data ?? part.inlineData
if (inline?.data != null) {
return createGeminiInlineDataPart(
plugin,
inline.data,
inline.mime_type ?? inline.mimeType ?? 'image/jpeg'
)
}
}| useCamelCaseInlineData: 使用大写的 inlineData 而不是小写的 inline_data | ||
| useCamelCaseMimeType: 使用大写的 mimeType 而不是小写的 mime_type |
dingyi222666
left a comment
There was a problem hiding this comment.
你让 codex 化简实现,byd 一个小功能怎么要加这么多行代码和类型
|
还有你的的 commit 记得签名,让 codex 去 git rebase 给你签名了,不弄我就 ntr 了 |
|
还有,两个开关直接合并成一个而不是两个 |
摘要
inlineData和mimeType字段的驼峰命名(camelCase)选项支持。