mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-05-24 13:38:42 +08:00

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>
11 lines
305 B
Python
11 lines
305 B
Python
import pydantic
|
|
from pydantic import BaseModel
|
|
|
|
|
|
def dump_model(model: BaseModel) -> dict:
|
|
if hasattr(pydantic, "model_dump"):
|
|
# FIXME mypy error, try to fix it instead of using type: ignore
|
|
return pydantic.model_dump(model) # type: ignore
|
|
else:
|
|
return model.model_dump()
|