Text generation output error #6687

Closed
opened 2026-02-21 18:16:51 -05:00 by yindo · 4 comments
Owner

Originally created by @kelinkong on GitHub (Nov 11, 2024).

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

https://cloud.dify.ai/

Cloud or Self Hosted

Cloud

Steps to reproduce

I am using text generation AI to create a test question generation assistant. Here is my prompt:

<instruction>
请根据{{{context}}}}生成试题。确保输出包含必要的信息,如题目内容、选项、正确答案等。输出格式应为JSON,不得包含任何XML标签。

步骤:
1. 从知识库中查询与用户输入的试题难度、试题类型相关的内容。
2. 根据查询结果生成指定数量的试题。
3. 每个试题应包含题目内容、选项和正确答案。
4. 将所有生成的试题以JSON格式输出。

输入变量:
- 难度等级:{{difficulty_level}}(例如:简单、中等、困难)
- 试题类型:{{question_type}}(例如:选择题、填空题、判断题)
- 试题数量:{{question_count}}(例如:5)

输出格式:
{
  "questions": [
    {
      "question_content": "题目内容",
      "options": [
        "选项A",
        "选项B",
        "选项C",
        "选项D"
      ],
      "correct_answer": "正确答案"
    },
    ...
  ]
}
</instruction>
<input>
<difficulty_level>简单</difficulty_level>
<question_type>选择题</question_type>
<question_count>5</question_count>
</input>
<output>
{
  "questions": [
    {
      "question_content": "1 + 1 等于多少?",
      "options": [
        "1",
        "2",
        "3",
        "4"
      ],
      "correct_answer": "2"
    },
    {
      "question_content": "地球是哪个行星?",
      "options": [
        "火星",
        "地球",
        "金星",
        "木星"
      ],
      "correct_answer": "地球"
    },
    ...
  ]
}
</output>
<example>
输入:难度等级为“简单”,试题类型为“选择题”,试题数量为“5”。
输出:包含5道简单选择题的JSON格式数据。
</example>

When I input the corresponding variable, I don't get any output.

✔️ Expected Behavior

Using text generation AI, expect to return the generated text

Actual Behavior

data: {"event": "error", "message_id": "a04e042e-4b5f-4b18-afc0-f37bb7e1d4d1", "created_at": 1731374336, "code": "internal_server_error", "message": "Internal Server Error, please contact support.", "status": 500}

Originally created by @kelinkong on GitHub (Nov 11, 2024). ### 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 https://cloud.dify.ai/ ### Cloud or Self Hosted Cloud ### Steps to reproduce I am using text generation AI to create a test question generation assistant. Here is my prompt: ```xml <instruction> 请根据{{{context}}}}生成试题。确保输出包含必要的信息,如题目内容、选项、正确答案等。输出格式应为JSON,不得包含任何XML标签。 步骤: 1. 从知识库中查询与用户输入的试题难度、试题类型相关的内容。 2. 根据查询结果生成指定数量的试题。 3. 每个试题应包含题目内容、选项和正确答案。 4. 将所有生成的试题以JSON格式输出。 输入变量: - 难度等级:{{difficulty_level}}(例如:简单、中等、困难) - 试题类型:{{question_type}}(例如:选择题、填空题、判断题) - 试题数量:{{question_count}}(例如:5) 输出格式: { "questions": [ { "question_content": "题目内容", "options": [ "选项A", "选项B", "选项C", "选项D" ], "correct_answer": "正确答案" }, ... ] } </instruction> <input> <difficulty_level>简单</difficulty_level> <question_type>选择题</question_type> <question_count>5</question_count> </input> <output> { "questions": [ { "question_content": "1 + 1 等于多少?", "options": [ "1", "2", "3", "4" ], "correct_answer": "2" }, { "question_content": "地球是哪个行星?", "options": [ "火星", "地球", "金星", "木星" ], "correct_answer": "地球" }, ... ] } </output> <example> 输入:难度等级为“简单”,试题类型为“选择题”,试题数量为“5”。 输出:包含5道简单选择题的JSON格式数据。 </example> ``` When I input the corresponding variable, I don't get any output. ### ✔️ Expected Behavior Using text generation AI, expect to return the generated text ### ❌ Actual Behavior data: {"event": "error", "message_id": "a04e042e-4b5f-4b18-afc0-f37bb7e1d4d1", "created_at": 1731374336, "code": "internal_server_error", "message": "Internal Server Error, please contact support.", "status": 500}
yindo added the 🐞 bugstale labels 2026-02-21 18:16:51 -05:00
yindo closed this issue 2026-02-21 18:16:51 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Nov 11, 2024):

Hey @kelinkong! 👋 I'm here to help you with bug fixes, questions, and more. I'm a bot, but I'll make sure you get the assistance you need while waiting for a human maintainer.

I found a similar issue related to 'Internal Server Error' in Dify's cloud environment. The error often occurs due to unhandled exceptions or unexpected errors in the code. In the Dify codebase, the _error_to_stream_response method in the AppGenerateResponseConverter class is responsible for mapping exceptions to error responses. If an exception does not match any predefined error types, it defaults to logging the error and returning an 'Internal Server Error' response [1].

To troubleshoot this issue, you might want to:

  1. Check the server logs for any unhandled exceptions or errors that could provide more context on the issue.
  2. Ensure that the input data is correctly formatted and does not exceed any size limits that might be imposed by the system.
  3. Review any recent changes in the codebase that might have introduced new exceptions or errors.

If the problem persists, consider increasing the logging level to capture more detailed information about the error, which can help in diagnosing the root cause.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Nov 11, 2024): <!-- Greeting --> Hey @kelinkong! 👋 I'm here to help you with bug fixes, questions, and more. I'm a bot, but I'll make sure you get the assistance you need while waiting for a human maintainer. <!-- Answer --> I found a similar issue related to 'Internal Server Error' in Dify's cloud environment. The error often occurs due to unhandled exceptions or unexpected errors in the code. In the Dify codebase, the `_error_to_stream_response` method in the `AppGenerateResponseConverter` class is responsible for mapping exceptions to error responses. If an exception does not match any predefined error types, it defaults to logging the error and returning an 'Internal Server Error' response <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/app/apps/base_app_generate_response_converter.py)</sup>. To troubleshoot this issue, you might want to: 1. Check the server logs for any unhandled exceptions or errors that could provide more context on the issue. 2. Ensure that the input data is correctly formatted and does not exceed any size limits that might be imposed by the system. 3. Review any recent changes in the codebase that might have introduced new exceptions or errors. If the problem persists, consider increasing the logging level to capture more detailed information about the error, which can help in diagnosing the root cause. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Nov 11, 2024):

Can you provide the time that you make the request?

@crazywoola commented on GitHub (Nov 11, 2024): Can you provide the time that you make the request?
Author
Owner

@kelinkong commented on GitHub (Nov 11, 2024):

It's around 9:30 this morning

@kelinkong commented on GitHub (Nov 11, 2024): It's around 9:30 this morning
Author
Owner

@dosubot[bot] commented on GitHub (Dec 13, 2024):

Hi, @kelinkong. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • Problem with text generation output in Dify's cloud version.
  • Output is incomplete or incorrect, not following the specified JSON format.
  • Suggested troubleshooting steps include checking server logs, input data formatting, and recent code changes.
  • Timing of the request was around 9:30 in the morning.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of the Dify repository by commenting here.
  • If there is no further activity, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Dec 13, 2024): Hi, @kelinkong. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog. I'm marking this issue as stale. **Issue Summary:** - Problem with text generation output in Dify's cloud version. - Output is incomplete or incorrect, not following the specified JSON format. - Suggested troubleshooting steps include checking server logs, input data formatting, and recent code changes. - Timing of the request was around 9:30 in the morning. **Next Steps:** - Please confirm if this issue is still relevant to the latest version of the Dify repository by commenting here. - If there is no further activity, this issue will be automatically closed in 15 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6687