Maintain the Order of Text and Files in Prompt for Multimodal Models #7189

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

Originally created by @laipz8200 on GitHub (Dec 13, 2024).

Originally assigned to: @laipz8200 on GitHub.

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Models like Gemini 2.0 and Claude can recognize the relative order of text and files in the input prompt. Therefore, we need to preserve this order when providing PromptMessage to the model. The structure might look like this:

prompt_messages = [
  SystemPromptMessage(content=[TextMessage("...")]),
  UserPromptMessage(content=[
    TextMessage("..."),
    ImageMessage("..."),
    TextMessage("..."),
  ]),
  ...
]

Subsequently, we will convert this structure internally into a message format that is supported by the specific model.

Tasks

  1. Update the PromptMessage generation logic to preserve the relative order of text and files.
  2. Ensure the model’s internal processing translates this structure into the appropriate message format.
  3. Write tests to validate the order is maintained in both input and internal conversions.

Expected Outcome

• The model receives the input prompt with the order of text and files intact.
• Conversion to the internal message format retains this order without errors.

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @laipz8200 on GitHub (Dec 13, 2024). Originally assigned to: @laipz8200 on GitHub. ### Self Checks - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. Models like Gemini 2.0 and Claude can recognize the relative order of text and files in the input prompt. Therefore, we need to preserve this order when providing `PromptMessage` to the model. The structure might look like this: ```python prompt_messages = [ SystemPromptMessage(content=[TextMessage("...")]), UserPromptMessage(content=[ TextMessage("..."), ImageMessage("..."), TextMessage("..."), ]), ... ] ``` Subsequently, we will convert this structure internally into a message format that is supported by the specific model. Tasks 1. Update the PromptMessage generation logic to preserve the relative order of text and files. 2. Ensure the model’s internal processing translates this structure into the appropriate message format. 3. Write tests to validate the order is maintained in both input and internal conversions. Expected Outcome • The model receives the input prompt with the order of text and files intact. • Conversion to the internal message format retains this order without errors. ### 2. Additional context or comments _No response_ ### 3. Can you help us with this feature? - [X] I am interested in contributing to this feature.
yindo added the 💪 enhancement label 2026-02-21 18:19:20 -05:00
yindo closed this issue 2026-02-21 18:19:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#7189