Each time a large model is output, redundant \n symbols are reserved. #8061

Closed
opened 2026-02-21 18:23:42 -05:00 by yindo · 2 comments
Owner

Originally created by @fakers777 on GitHub (Feb 7, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • 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.

Dify version

0.15.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Each time a large model is output, redundant \n symbols are reserved.

{
"model_mode": "chat",
"prompts": [
{
"role": "user",
"text": "用户要咨询成都天气,请输出用户要咨询的城市名称\n输出的城市名称不要带\n符号!!直接给出城市名称",
"files": []
}
],
"model_provider": "google",
"model_name": "gemini-2.0-flash-exp"
}

result

{
"text": "成都\n",
"usage": {
"prompt_tokens": 30,
"prompt_unit_price": "0.00",
"prompt_price_unit": "0.000001",
"prompt_price": "0E-7",
"completion_tokens": 2,
"completion_unit_price": "0.00",
"completion_price_unit": "0.000001",
"completion_price": "0E-7",
"total_tokens": 32,
"total_price": "0E-7",
"currency": "USD",
"latency": 1.5279735641088337
},
"finish_reason": "1"
}

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @fakers777 on GitHub (Feb 7, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [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. ### Dify version 0.15.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Each time a large model is output, redundant \n symbols are reserved. { "model_mode": "chat", "prompts": [ { "role": "user", "text": "用户要咨询成都天气,请输出用户要咨询的城市名称\n输出的城市名称不要带\\n符号!!直接给出城市名称", "files": [] } ], "model_provider": "google", "model_name": "gemini-2.0-flash-exp" } result { "text": "成都\n", "usage": { "prompt_tokens": 30, "prompt_unit_price": "0.00", "prompt_price_unit": "0.000001", "prompt_price": "0E-7", "completion_tokens": 2, "completion_unit_price": "0.00", "completion_price_unit": "0.000001", "completion_price": "0E-7", "total_tokens": 32, "total_price": "0E-7", "currency": "USD", "latency": 1.5279735641088337 }, "finish_reason": "1" } ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:23:42 -05:00
yindo closed this issue 2026-02-21 18:23:42 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 7, 2025):

Hello, @fakers777! I'm here to assist you with any bugs, questions, or contributions. Let's work together to resolve your issue.

The issue you're experiencing with redundant newline characters in the model output might be related to how the OutputPanel component processes these outputs. In Dify, the OutputPanel component handles newline characters by joining array elements with newline characters when the output is an array of strings. This is done using the join('\n') method [1].

If the output is not intended to have newline characters, you might need to adjust the processing logic to trim or remove these characters after the model output is received. This could involve modifying the component or adding a utility function to clean the output string before it is displayed or used further.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot[bot] commented on GitHub (Feb 7, 2025): <!-- Greeting --> Hello, @fakers777! I'm here to assist you with any bugs, questions, or contributions. Let's work together to resolve your issue. <!-- Answer --> The issue you're experiencing with redundant newline characters in the model output might be related to how the `OutputPanel` component processes these outputs. In Dify, the `OutputPanel` component handles newline characters by joining array elements with newline characters when the output is an array of strings. This is done using the `join('\n')` method <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/app/components/workflow/run/output-panel.tsx)</sup>. If the output is not intended to have newline characters, you might need to adjust the processing logic to trim or remove these characters after the model output is received. This could involve modifying the component or adding a utility function to clean the output string before it is displayed or used further. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/97c6bb3c-eded-45d9-a038-8ed5328b0d35?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/97c6bb3c-eded-45d9-a038-8ed5328b0d35?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/97c6bb3c-eded-45d9-a038-8ed5328b0d35?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/97c6bb3c-eded-45d9-a038-8ed5328b0d35?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/97c6bb3c-eded-45d9-a038-8ed5328b0d35?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/97c6bb3c-eded-45d9-a038-8ed5328b0d35?feedback_type=other)</sup>
Author
Owner

@crazywoola commented on GitHub (Feb 7, 2025):

Duplicated https://github.com/langgenius/dify/issues/13359

@crazywoola commented on GitHub (Feb 7, 2025): Duplicated https://github.com/langgenius/dify/issues/13359
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#8061