[PR #24663] feat(api): maintain assistant content parts and file handling in advanced chat #30741

Closed
opened 2026-02-21 20:48:08 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/24663

State: closed
Merged: Yes


Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

This commit introduces support for handling assistant-generated content parts and improves file management in advanced chat workflows. Key changes include:

  • Recording files from LLM nodes in addition to answer and end nodes
  • Removing markdown image links from answers when files are present
  • Adding a new helper method to build prompt messages with file attachments
  • Improving file handling logic to distinguish between user and assistant files
  • Allowing tool-generated files to bypass upload restrictions
  • Adding proper file ID mapping based on transfer method

Screenshots

Before

The relationship between the image objects output by the model is not stored in the database, and the image objects output by the model are not added to the memory when the memory is restored.

case1 case2 case3
image image image

After

The image file is defined in memory with the correct data structure, and the model shows instant image-edit capability.

case1 case2 case3
image PixPin_2025-08-28_02-48-02 PixPin_2025-08-28_02-28-18

Image Edit [1]

round1 round2 round3
10e042ed-372f-4281-b146-8181612b100d (1) c9427736-9cc4-4f2a-95b2-c58b2a9db257 Gemini_Generated_Image_9oftmq9oftmq9oft

Image Edit [2]

Using the same focal length Master lens on the Sony A7M3, four more sets of sample shots were taken of the poses and expressions of the models shown here, under the same settings and lighting conditions.

Input Output
Image Image
Image
Image

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/24663 **State:** closed **Merged:** Yes --- > [!IMPORTANT] > > 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) > 1. Ensure there is an associated issue and you have been assigned to it > 1. Use the correct syntax to link this PR: `Fixes #<issue number>`. - Fixes: #24620 - Refes: https://github.com/langgenius/dify-official-plugins/pull/1600 ## Summary <!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> This commit introduces support for handling assistant-generated content parts and improves file management in advanced chat workflows. Key changes include: - Recording files from LLM nodes in addition to answer and end nodes - Removing markdown image links from answers when files are present - Adding a new helper method to build prompt messages with file attachments - Improving file handling logic to distinguish between user and assistant files - Allowing tool-generated files to bypass upload restrictions - Adding proper file ID mapping based on transfer method ## Screenshots ### Before The relationship between the image objects output by the model is not stored in the database, and the image objects output by the model are not added to the memory when the memory is restored. | case1 | case2 | case3 | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | <img alt="image" src="https://github.com/user-attachments/assets/b3b6c3e7-a505-476f-b930-4d8dc55caad0" /> | <img alt="image" src="https://github.com/user-attachments/assets/eeb0c9c4-dfc2-4ccc-83f4-39a4cdf2da7f" /> | <img alt="image" src="https://github.com/user-attachments/assets/f21d9c70-f74b-403c-b504-911c3329d601" /> | ### After The image file is defined in memory with the correct data structure, and the model shows instant `image-edit` capability. | case1 | case2 | case3 | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | <img alt="image" src="https://github.com/user-attachments/assets/5e30f9db-62c9-4cc5-bbb0-aa45ecf50b72" /> | <img alt="PixPin_2025-08-28_02-48-02" src="https://github.com/user-attachments/assets/4ee9d76b-55dd-42c2-8c79-d352e2bb6f58" /> | <img alt="PixPin_2025-08-28_02-28-18" src="https://github.com/user-attachments/assets/662f7a73-390e-49ab-be9f-e9cbab6a05fd" /> | ### Image Edit [1] | round1 | round2 | round3 | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | <img alt="10e042ed-372f-4281-b146-8181612b100d (1)" src="https://github.com/user-attachments/assets/42c0ec9d-458d-4ea0-a6c4-be1cb7e32455" /> | <img alt="c9427736-9cc4-4f2a-95b2-c58b2a9db257" src="https://github.com/user-attachments/assets/1a488c39-0e1a-4fd5-9ca1-7fd115ad484a" /> | <img alt="Gemini_Generated_Image_9oftmq9oftmq9oft" src="https://github.com/user-attachments/assets/1a4233c3-43ac-4223-8f30-521948ad6461" /> | ### Image Edit [2] > Using the same focal length Master lens on the Sony A7M3, four more sets of sample shots were taken of the poses and expressions of the models shown here, under the same settings and lighting conditions. | Input | Output | | ------------------------------------------------------------ | ------------------------------------------------------------ | | <img alt="Image" src="https://github.com/user-attachments/assets/5c4d00ea-f19c-4355-8a2d-5be93973e7c8" /> | <img alt="Image" src="https://github.com/user-attachments/assets/024fdafe-8a4f-456b-9fbd-d92edddb2d79" /> | | | <img alt="Image" src="https://github.com/user-attachments/assets/5de2c935-2433-4764-9d98-409a2ea77a46" /> | | | <img alt="Image" src="https://github.com/user-attachments/assets/374352d9-cd06-4f3f-851d-f09107a326d3" /> | ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:48:08 -05:00
yindo closed this issue 2026-02-21 20:48:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#30741