feat(agui): Add multimodal input support (image/video/audio) to AguiM… - #1380
feat(agui): Add multimodal input support (image/video/audio) to AguiM…#1380NoiAI wants to merge 1 commit into
Conversation
|
|
88419b9 to
2e87d78
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…essage and AguiMessageConverter Adds support for multimodal input (image, video, audio, document) in the AG-UI extension, aligning with the AG-UI Protocol InputContent specification. - AguiMessage.content: String -> Object (backward compatible) - AguiMessageConverter: InputContent[] -> ContentBlock conversion - Supports both url and data (base64) source types
2e87d78 to
5d6cb4b
Compare
|
这个功能对我们项目非常重要,我们已经测试过可以正常使用,希望能尽快合并,非常感谢! |
|
PTAL @chickenlj |
|
We have a real-world need for this feature (Spring Boot + HarnessAgent + DashScope + AG-UI web client, where users send images/audio recordings from the browser). Currently we have to work around the protocol layer by smuggling attachments through To help move this forward, I independently verified this PR today (2026-07-28):
@chickenlj @LearningGp Could this get a review? If the original author is no longer available, I'd be happy to help rebase, fill in the PR description checklist, and cover the remaining uncovered lines flagged by codecov. |
oss-maintainer
left a comment
There was a problem hiding this comment.
-
@SuppressWarnings("unchecked")— Multiple unchecked casts fromMap<String, Object>. This is acceptable given JSON deserialization constraints, but consider adding a typed DTO (e.g.,InputContent) for type safety in a follow-up. -
CLA not signed — The CLA assistant flag is still pending. Please sign the CLA at https://cla-assistant.io/agentscope-ai/agentscope-java?pullRequest=1380 before this can be merged.
-
May need rebase — This PR has been open since May. Please rebase onto current
mainto ensure no merge conflicts with recent AG-UI changes (e.g., PR #2452 metadata field, PR #2463 toolkit refactoring).
Verdict
Solid implementation of a much-requested feature. The core conversion logic is correct and well-tested. Addressing the document data loss (#1) and rebasing would make this merge-ready.
|
@junnan2014 Can you support multimodal output based on the latest agui module in the main branch? We are very welcome |
一、设计问题问题 1:类型安全缺失
private final Object content; // String or List<Map<String, Object>>
public List<Map<String, Object>> getMultimodalContent() // 退化到动态语言风格
问题 2:概念命名错误 —— "多模态"窄化public boolean isMultimodalContent() // ← 命名问题
public List<Map<String, Object>> getMultimodalContent()两个层面的概念错误: AG-UI 协议层面:协议官方术语是 AgentScope 模型层面:ContentBlock 体系包含 7 种块,其中 ThinkingBlock、ToolUseBlock、ToolResultBlock 与"模态"无关。ContentBlock 是通用内容单元,"多模态"只是其能力的子集,不是定义特征。 问题 3:两层概念未分离PR 没有区分两个本应独立的概念层:
PR 直接用 二、建议的类架构架构总览
设计要点1. AguiMessage.content —— 类型安全的联合
2. InputContent —— 类型化的协议模型
3. Converter —— 编译期穷尽的类型映射 ** content 字段的反序列化处理代码片段:** // 指定该属性使用我们自定义的反序列化器
@JsonDeserialize(using = MessageContentDeserializer.class)
private MessageContent content;public class MessageContentDeserializer extends JsonDeserializer<MessageContent> {
@Override
public MessageContent deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
JsonToken currentToken = p.currentToken();
// 场景 1:JSON 中是字符串 "content": "hello"
if (currentToken == JsonToken.VALUE_STRING) {
String textValue = p.getValueAsString();
return new Text(textValue);
}
// 场景 2:JSON 中是数组 "content": ["block1", "block2"]
else if (currentToken == JsonToken.START_ARRAY) {
// 使用 TypeReference 保证泛型类型正确解析
List<String> list = p.readValueAs(new TypeReference<List<String>>() {});
return new Blocks(list);
}
// 场景 3:处理 null 值
else if (currentToken == JsonToken.VALUE_NULL) {
return null;
}
// 场景 4:不支持的类型,抛出异常
else {
throw ctxt.wrongTokenException(p, MessageContent.class, currentToken,
"Expected STRING or START_ARRAY for 'content' field");
}
}
}命名修正对照
建议对该 PR 进行更规范化设计修改。 AG-UI 官方messages文档:https://docs.ag-ui.com/concepts/messages |
…essage and AguiMessageConverter
Adds support for multimodal input (image, video, audio, document) in the AG-UI extension, aligning with the AG-UI Protocol InputContent specification.
AgentScope-Java Version
[The version of AgentScope-Java you are working on, e.g. 1.0.12, check your pom.xml dependency version or run
mvn dependency:tree | grep agentscope-parent:pom(only mac/linux)]Description
[Please describe the background, purpose, changes made, and how to test this PR]
Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)