langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
51.82k stars 7.51k forks source link

Text generation output error #10567

Open kelinkong opened 5 days ago

kelinkong commented 5 days ago

Self Checks

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}

dosubot[bot] commented 5 days ago

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.

crazywoola commented 5 days ago

Can you provide the time that you make the request?

kelinkong commented 5 days ago

It's around 9:30 this morning