fix(DashScope formatter): convert local files to base64 data in dashscope formatter#1253
fix(DashScope formatter): convert local files to base64 data in dashscope formatter#1253qbc2016 wants to merge 3 commits intoagentscope-ai:mainfrom
Conversation
Summary of ChangesHello @qbc2016, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses issues with how local media files are handled within the DashScope formatter. It prevents 'FileAlreadyExists' errors and optimizes media processing by converting local file paths into base64 data URIs. This change ensures that media content is directly embedded, avoiding redundant uploads and standardizing the formatting logic. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request successfully addresses the FileAlreadyExists error in the DashScope SDK by converting local media files to base64 data URIs instead of using file:// URLs. This is a robust fix that avoids repeated uploads to OSS. The refactoring of DashScopeMultiAgentFormatter to reuse _format_dashscope_media_block is a positive change for maintainability and consistency. My feedback focuses on ensuring that type hints and docstrings accurately reflect the support for video blocks, which are now being processed by this centralized logic.
Style Guide Adherence:
- [MUST] Comment Standards: I've suggested updates to the docstrings in
_format_dashscope_media_blockto ensure they are complete and include the newly supportedVideoBlock(Repository Style Guide, line 46). - [MUST] Encapsulation Standards: The internal helper function
_format_dashscope_media_blockcorrectly uses the_prefix (Repository Style Guide, line 27). - [MUST] Lazy Loading: Standard library imports (
base64,mimetypes) are placed at the top, which is acceptable as they are not third-party dependencies. Third-party libraries likedashscopeare correctly imported at the point of use elsewhere in the file (Repository Style Guide, line 10).
AgentScope Version
1.0.16
Description
FileAlreadyExistserror from DashScope SDK when the same local image appears in memory across multiple agent calls_format_dashscope_media_blockinstead offile:// URLs, avoiding repeated OSS uploads_format_dashscope_media_blockfor consistent media handlingChecklist
Please check the following items before code is ready to be reviewed.
pre-commit run --all-filescommand