mirror of
				https://github.com/langgenius/dify.git
				synced 2025-10-31 02:42:59 +00:00 
			
		
		
		
	 349c3cf7b8
			
		
	
	
		349c3cf7b8
		
			
		
	
	
	
	
		
			
			Enhance `LLMNode` with multimodal capability, introducing support for image outputs. This implementation extracts base64-encoded images from LLM responses, saves them to the storage service, and records the file metadata in the `ToolFile` table. In conversations, these images are rendered as markdown-based inline images. Additionally, the images are included in the LLMNode's output as file variables, enabling subsequent nodes in the workflow to utilize them. To integrate file outputs into workflows, adjustments to the frontend code are necessary. For multimodal output functionality, updates to related model configurations are required. Currently, this capability has been applied exclusively to Google's Gemini models. Close #15814. Signed-off-by: -LAN- <laipz8200@outlook.com> Co-authored-by: -LAN- <laipz8200@outlook.com>
		
			
				
	
	
		
			20 lines
		
	
	
		
			585 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			585 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from collections.abc import Callable
 | |
| from typing import TYPE_CHECKING
 | |
| 
 | |
| if TYPE_CHECKING:
 | |
|     from core.tools.tool_file_manager import ToolFileManager
 | |
| 
 | |
| _tool_file_manager_factory: Callable[[], "ToolFileManager"] | None = None
 | |
| 
 | |
| 
 | |
| class ToolFileParser:
 | |
|     @staticmethod
 | |
|     def get_tool_file_manager() -> "ToolFileManager":
 | |
|         assert _tool_file_manager_factory is not None
 | |
|         return _tool_file_manager_factory()
 | |
| 
 | |
| 
 | |
| def set_tool_file_manager_factory(factory: Callable[[], "ToolFileManager"]) -> None:
 | |
|     global _tool_file_manager_factory
 | |
|     _tool_file_manager_factory = factory
 |