Skip to content

Feat/multimodal model#879

Merged
suluyana merged 7 commits intomodelscope:mainfrom
suluyana:feat/multimodal_model
Mar 6, 2026
Merged

Feat/multimodal model#879
suluyana merged 7 commits intomodelscope:mainfrom
suluyana:feat/multimodal_model

Conversation

@suluyana
Copy link
Collaborator

@suluyana suluyana commented Mar 5, 2026

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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!

此拉取请求为 ms-agent 框架引入了强大的多模态能力,使其能够理解和处理图像信息,从而实现更丰富、更具交互性的对话体验。通过新增的配置选项、详细的中文文档和全面的测试用例,用户可以轻松地集成和利用多模态模型进行视觉内容分析和多轮对话。这些改动显著提升了 ms-agent 在处理复杂、混合媒体输入方面的灵活性和功能性。

Highlights

  • 多模态模型支持: ms-agent 现已全面支持多模态模型,例如阿里云的 qwen3.5-plus,能够进行图片理解、对象识别和结合图片内容的对话。
  • 配置与使用指南: 新增了详细的中文文档 MULTIMODAL_SUPPORT.md,指导用户如何安装依赖、配置 API Key、通过配置文件或代码设置多模态模型,并提供了 LLMAgent 的基本用法、流式/非流式模式以及多轮对话示例。
  • 多模态消息格式: 系统现在支持 OpenAI 兼容的多模态消息格式,允许通过图片 URL、Base64 编码或本地文件路径提供图片内容。
  • 新增配置示例: 添加了新的配置文件 config/cfg_model_multimodal.yaml,作为多模态模型(如 qwen3.5-plus)的配置模板,包含 DashScope 服务设置和生成参数。
  • 功能测试: 新增了测试文件 examples/agent/test_llm_agent_multimodal.py,用于验证 LLMAgent 在非流式、流式、Base64 图片输入以及多轮对话场景下的多模态功能。
  • 日志与消息处理优化: 优化了 LLMAgentlog_output 方法,使其能够正确处理和显示多模态内容;同时修改了 openai_llm.py 中的 _format_input_message 方法,确保多模态消息内容(列表类型)在格式化时不会被错误地处理为字符串。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • MULTIMODAL_SUPPORT.md
    • 新增了关于如何使用 ms-agent 进行多模态对话的详细中文指南,包括图片理解和分析功能。
    • 包含了安装依赖、API Key 配置、模型配置(通过文件或代码)、LLMAgent 基本用法、流式/非流式模式、多轮对话的示例代码。
    • 详细说明了 OpenAI 兼容的多模态消息格式,支持图片 URL、Base64 编码和本地文件路径。
    • 提供了常见问题解答,如图片大小限制、支持的图片格式和多图发送。
  • config/cfg_model_multimodal.yaml
    • 新增了多模态模型(如 qwen3.5-plus)的示例配置文件。
    • 配置了 DashScope 服务、模型名称、API Key、兼容模式 URL、生成参数(如 temperature, max_tokens, stream)和系统提示词。
    • 包含了关于多模态助手职责的系统提示词示例。
  • examples/agent/test_llm_agent_multimodal.py
    • 新增了 LLMAgent 多模态对话的测试套件。
    • 包含了非流式模式下 URL 图片的多模态对话测试。
    • 包含了流式模式下 URL 图片的多模态对话测试。
    • 包含了非流式模式下 Base64 编码图片的多模态对话测试。
    • 包含了多轮对话中混合多模态和文本输入的测试。
  • ms_agent/agent/llm_agent.py
    • 修改了 log_output 方法,使其能够识别并正确处理多模态内容(列表类型)。
    • 当内容为多模态列表时,提取文本部分和截断的图片 URL 进行日志记录,以提高可读性。
  • ms_agent/llm/openai_llm.py
    • 修改了 _format_input_message 方法,确保在处理 Message 对象的 content 字段时,仅对字符串类型的内容进行 strip() 操作。
    • 优化了消息字典的构建逻辑,以正确处理多模态内容(列表类型),避免将其错误地转换为字符串或丢失结构。
    • 确保 content 字段在格式化后的消息中正确设置,无论是字符串还是多模态列表。
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次 PR 引入了对多模态模型的支持,包括文档、配置、示例和核心逻辑的修改。整体实现很好,但有几个地方可以改进:

  • 文档和配置中有一些可以使新用户更容易上手的改进点。
  • 示例代码中存在重复,可以进行重构。
  • llm_agent.py 中有一个类型不一致的问题。
  • openai_llm.py 中发现一个严重 bug,它破坏了现有的前缀缓存功能,需要立即修复。
    我已经在具体的 review comment 中提供了详细的反馈和代码建议。

@suluyana suluyana merged commit ea824b7 into modelscope:main Mar 6, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants