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
49.08k stars 7.03k forks source link

When talk to chatflow again, error prompt: variable size 5350 exceeds limit 5120 #9749

Open jenkin2120 opened 4 hours ago

jenkin2120 commented 4 hours ago

Self Checks

Dify version

Version 0.9.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

1.Designed a chatflow with two steps of qwen2.5, and chat memory settings is disable; 2.The first LLM prompt length is 3300+ characters, the second LLM prompt length is more 4000+; 3.When start a new conversation,first question is replayed perfectly, but second question prompt: variable size 5350 exceeds limit 5120 in the dialog page, Retry third、forth question prompt same error. 4.I searched content: 'raise VariableError(f"variable size {result.size} exceeds limit {dify_config.MAX_VARIABLE_SIZE}")' in the file 'variable_factory.py' should matching above error, but MAX_VARIABLE_SIZE is set in .env, and the value is 204800. 5.I searched all files with content 5120, but nothing found related to it.

✔️ Expected Behavior

pls check the reson of the error: variable size 5350 exceeds limit 5120, and fix the bug

❌ Actual Behavior

1

dosubot[bot] commented 4 hours ago

Hey @jenkin2120! 👋 I'm here to help you out with bugs, questions, and becoming a contributor. Let's squash this bug together!

I found a similar issue that was previously reported and closed. The error message you're encountering indicates that the variable size exceeds the limit defined in the configuration (dify_config.MAX_VARIABLE_SIZE). The default limit is set to 5120 bytes, and your variable size is 5350 bytes, which is causing the VariableError to be raised.

To resolve this, you can either:

  1. Reduce the size of the variable: Ensure that the data being processed does not exceed the 5120 bytes limit.
  2. Increase the MAX_VARIABLE_SIZE limit: If reducing the variable size is not feasible, you can increase the MAX_VARIABLE_SIZE limit in your configuration.

To modify the MAX_VARIABLE_SIZE in your Docker deployment for Dify, follow these steps:

  1. Edit the docker-compose.yaml file: Add or update the MAX_VARIABLE_SIZE environment variable under the appropriate service's environment section. For example, if it needs to be set for the api service, you would add it like this:

    api:
     image: your-api-image
     environment:
       MAX_VARIABLE_SIZE: ${MAX_VARIABLE_SIZE:-default_value}
       # other environment variables

    Replace your-api-image with the actual image name and default_value with the desired default value for MAX_VARIABLE_SIZE.

  2. Update the .env file: Ensure that your .env file includes the MAX_VARIABLE_SIZE variable. You can do this by copying the .env.example file to .env and then adding or modifying the MAX_VARIABLE_SIZE entry:

    cp .env.example .env

    Then, edit the .env file to include:

    MAX_VARIABLE_SIZE=your_desired_value
  3. Restart your Docker containers: After making these changes, restart your Docker containers to apply the new environment variable:

    docker compose down
    docker compose up -d

By following these steps, you can increase the MAX_VARIABLE_SIZE limit to accommodate larger variables in your Dify application. This should help resolve the error you're encountering [1].

To continue talking to Dosu, mention @dosu.

crazywoola commented 2 hours ago

For docker, please check the .env in this folder docker/.

jenkin2120 commented 1 minute ago

Thanks! I did as Dosu @dosu says, It works, I am continuously monitoring the operation status. I hope MAX_VARIABLE_SIZE variable can be writen into the section 'api' of docker-compose.yaml file explicitly later. Thank you once again.

dosubot[bot] commented 1 minute ago

Hey @jenkin2120! I'm glad to hear that the solution worked for you and that you're keeping an eye on things. As for your suggestion about the MAX_VARIABLE_SIZE variable, that's a great idea! However, I'm just a bot here to help with bugs, technical questions, and engineering knowledge. If you think this should be addressed, you might want to reach out to the Dosu Team to share your feedback. They'll be happy to hear from you! 😊

To continue talking to Dosu, mention @dosu.