feature: Add image url support for multimodal LLM #373
+345
−32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR: Add image URL support for multimodal LLM
Overview
This PR adds Image URL support to the Agent messaging system, allowing direct image link transmission instead of base64 encoding, significantly reducing network transmission overhead and improving multimodal scenario performance.
Motivation
Problem:
Solution:
Benefits:
Core Changes
1. Message.java - Add imageUrl Field
File:
genie-backend/src/main/java/com/jd/genie/agent/dto/Message.javaChanges:
imageUrlfielduserMessageWithImageUrl(content, imageUrl)assistantMessageWithImageUrl(content, imageUrl)hasImage()- Check if contains image (base64 or URL)isImageUrl()- Check if is URL-type imageDesign Consideration:
2. BaseAgent.java - Update Memory Management
File:
genie-backend/src/main/java/com/jd/genie/agent/agent/BaseAgent.javaChanges:
updateMemoryWithImage(role, content, base64Image, imageUrl, args)methodupdateMemory()method for backward compatibility3. LLM.java - Optimize Formatting Logic
File:
genie-backend/src/main/java/com/jd/genie/agent/llm/LLM.javaChanges:
imageUrlformatting to LLM API required formatTest Coverage
Unit Tests
File:
MessageImageUrlTest.javaCoverage: 11 test cases
Integration Tests
File:
ImageUrlIntegrationTest.javaCoverage: 2 test cases
Configuration Example:
Backward Compatibility
✅ Fully Compatible: All existing code requires no modification
updateMemory()method continues to workMessage.userMessage()and other methods continue to workReview Checklist