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
48.72k stars 6.98k forks source link

Variables starting with "sys" cannot be referenced correctly. #8421

Closed yanxiyue closed 1 month ago

yanxiyue commented 1 month ago

Self Checks

Dify version

v0.8.2

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. Add a variable named "systemCode" in the start node.
  2. Reference this variable in the end node.
  3. run

✔️ Expected Behavior

output correctly value

❌ Actual Behavior

output null

dosubot[bot] commented 1 month ago

@yanxiyue Hello! I'm here to assist you with any bugs, questions, or contributions you may have for Dify. Let's work together to solve the issue you're facing.

Variables starting with "sys" are not being referenced correctly in Dify v0.8.2 when self-hosted because system variables are pre-set system-level parameters that need to be globally read by other nodes. If they are not being referenced correctly, it could be due to a misconfiguration or a missing feature that needs to be enabled.

For example, the sys.files variable requires the image upload function to be enabled in the 'Features' section in the upper right corner of the application orchestration page. Ensure that all necessary features are enabled and correctly configured.

Additionally, ensure that the environment variables are correctly set up in your self-hosted environment. The create_flask_app_with_configs function in api/app.py populates configurations into system environment variables. If these configurations are not correctly loaded, it could lead to issues with referencing system variables.

def create_flask_app_with_configs() -> Flask:
    """
    create a raw flask app
    with configs loaded from .env file
    """
    dify_app = DifyApp(__name__)
    dify_app.config.from_mapping(dify_config.model_dump())

    # populate configs into system environment variables
    for key, value in dify_app.config.items():
        if isinstance(value, str):
            os.environ[key] = value
        elif isinstance(value, int | float | bool):
            os.environ[key] = str(value)
        elif value is None:
            os.environ[key] = ""

    return dify_app

Ensure that the system variables are correctly set up and that any required features are enabled [1][2].

To continue talking to Dosu, mention @dosu.

yanxiyue commented 1 month ago

pr #8422