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.18k stars 7.37k forks source link

If a Directed Cyclic Graph is configured within a workflow, it can cause the workflow to crash. #3097

Closed aute closed 7 months ago

aute commented 7 months ago

Self Checks

Dify version

0.6.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I can configure a Directed Cyclic Graph in the workflow.

截屏2024-04-03 15 51 29

But it won't function properly and will cause the page to crash.

截屏2024-04-03 15 58 00

✔️ Expected Behavior

Expected Behavior: The system should support Directed Cyclic Graphs and function properly; Fallback solution: Prohibit the configuration of Directed Cyclic Graphs during setup.

❌ Actual Behavior

Directed Cyclic Graph configurations can be made, but they do not function properly and lead to page crashes.

dosubot[bot] commented 7 months ago

Hey @aute, long time no debug! Hope you're ready to untangle some code spaghetti with me again. 🍝

To resolve the issue in Dify version 0.6.0 where configuring a Directed Cyclic Graph (DAG) within a workflow causes the system to crash in a self-hosted Docker environment, you can follow these steps:

  1. Ensure Compatibility: First, make sure that your Docker and Docker Compose versions meet the prerequisites mentioned in the Docker Compose Deployment guide. Dify requires Docker 19.03 or later and Docker Compose 1.25.1 or later for Linux platforms, and appropriate versions for macOS and Windows with WSL 2 enabled.

  2. Check for Updates: The issue might have been recognized and fixed in a newer version, so it's crucial to check if there's an update available for Dify. You can do this by pulling the latest changes from the Dify repository and updating your Docker containers. Use the following commands:

    cd dify/docker
    git pull origin main
    docker compose down
    docker compose pull
    docker compose up -d

    This ensures you have the latest version of Dify, which might include a fix for the issue.

  3. Review JavaScript Console and Network Logs: Since the crash results in a JavaScript application error in the browser console, closely examine the error message and stack trace for clues about the failure. JavaScript errors often point directly to the problematic code or give hints about what went wrong. Additionally, check the network tab in your browser's developer tools for failed network requests that might indicate backend issues.

  4. Report the Issue: If after updating Dify the problem persists, consider reporting the issue to the Dify developers. Include detailed information about your Docker environment, the steps to reproduce the issue, and any relevant logs or error messages from both the browser console and Docker logs. This can help the developers diagnose and address the issue more effectively.

  5. Temporary Workaround: As a temporary workaround, avoid configuring Directed Cyclic Graphs within workflows if possible, until a fix is released. If your workflow absolutely requires a DAG configuration, consider setting up a development environment outside Docker for this specific purpose, though this might not be ideal or feasible in all cases.

Remember, software environments and dependencies are constantly evolving, so staying updated can be key to resolving such issues.

Sources

#### About Dosu This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot.
crazywoola commented 7 months ago

It should be fixed in the latest preview.2.

aute commented 7 months ago

@crazywoola cloud.dify.ai With this configuration, the page still crashes

DSL:

app:
  description: ''
  icon: "\U0001F916"
  icon_background: '#FFEAD5'
  mode: advanced-chat
  name: "\u5DE5\u4F5C\u6D41\u6D4B\u8BD5"
workflow:
  features:
    file_upload:
      image:
        enabled: false
        number_limits: 3
        transfer_methods:
        - local_file
        - remote_url
    opening_statement: ''
    retriever_resource:
      enabled: false
    sensitive_word_avoidance:
      enabled: false
    speech_to_text:
      enabled: false
    suggested_questions: []
    suggested_questions_after_answer:
      enabled: false
    text_to_speech:
      enabled: false
      language: ''
      voice: ''
  graph:
    edges:
    - data:
        sourceType: llm
        targetType: answer
      id: llm-answer
      source: llm
      sourceHandle: source
      target: answer
      targetHandle: target
      type: custom
    - data:
        sourceType: answer
        targetType: llm
      id: answer-1712631599229
      source: answer
      sourceHandle: source
      target: '1712631599229'
      targetHandle: target
      type: custom
    - data:
        sourceType: llm
        targetType: llm
      id: 1712631599229-llm
      source: '1712631599229'
      sourceHandle: source
      target: llm
      targetHandle: target
      type: custom
    nodes:
    - data:
        desc: ''
        selected: false
        title: "\u5F00\u59CB"
        type: start
        variables: []
      height: 54
      id: '1712631571094'
      position:
        x: 80
        y: 282
      positionAbsolute:
        x: 80
        y: 282
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        context:
          enabled: false
          variable_selector: []
        desc: ''
        memory:
          window:
            enabled: false
            size: 10
        model:
          completion_params:
            temperature: 0.7
          mode: chat
          name: ''
          provider: ''
        prompt_template:
        - role: system
          text: ''
        selected: false
        title: LLM
        type: llm
        variables: []
        vision:
          enabled: false
      height: 54
      id: llm
      position:
        x: 380
        y: 282
      positionAbsolute:
        x: 380
        y: 282
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        answer: '{{#llm.text#}}'
        desc: ''
        selected: false
        title: "\u76F4\u63A5\u56DE\u590D"
        type: answer
        variables: []
      height: 107
      id: answer
      position:
        x: 680
        y: 282
      positionAbsolute:
        x: 680
        y: 282
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        context:
          enabled: false
          variable_selector: []
        desc: ''
        model:
          completion_params:
            frequency_penalty: 0
            max_tokens: 512
            presence_penalty: 0
            temperature: 0.7
            top_p: 1
          mode: chat
          name: gpt-4
          provider: openai
        prompt_template:
        - role: system
          text: '{{#sys.query#}}

            {{#llm.text#}}

            '
        selected: true
        title: LLM 2
        type: llm
        variables: []
        vision:
          enabled: false
      height: 98
      id: '1712631599229'
      position:
        x: 980
        y: 282
      positionAbsolute:
        x: 980
        y: 282
      selected: true
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    viewport:
      x: -107.42682239454302
      y: 174.42779870390524
      zoom: 0.7659653705592298
Wahtes commented 2 months ago

It should be fixed in the latest preview.2.

Actually, this issue still exists in main branch with default configuration and cloud.dify.ai. Is it solved in any branch?

WYY030903 commented 2 months ago

It should be fixed in the latest preview.2.

I can still find this problem? Is there any fix way?