[PR #30258] feat: add vibe workflow #32750

Closed
opened 2026-02-21 20:52:00 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/30258

State: closed
Merged: Yes


Summary

feat #29774

This PR refactors the Vibe Workflow generation logic, extracting it from api/core/llm_generator into a dedicated, modular architecture in api/core/workflow/generator. It introduces a robust 5-step generation process (Planner -> Context Filter -> Builder -> Repair -> Validate) to improve the stability and quality of generated workflows.

Key Changes

1. Modular Architecture (api/core/workflow/generator)

  • Planner: Responsible for generating the high-level workflow structure.
  • Builder: Handles the detailed configuration of individual nodes.
  • Validation Engine: A comprehensive rule-based system (ValidationEngine, WorkflowValidator) to check node and edge validity.
  • Auto-Repair: Implemented NodeRepair and EdgeRepair to automatically fix common generation errors (e.g., disconnected edges, invalid fields).
  • Mermaid Visualization: Added MermaidGenerator for workflow flowchart rendering.

2. Improvements & Fixes

  • Stability Warning: Added a localized stability warning (Chinese/English) to the API response to inform users that generated workflows may require debugging.
  • Pydantic Fix: Fixed a validation error in CodeNodeData where outputs.status could receive a string instead of a dictionary.
  • Linting & Cleanup:
    • Fixed multiple ruff linting errors (line lengths, implicit optionals, redundant exceptions).
    • Removed accidentally tracked .pyc files from the repository.

3. Testing

  • Added comprehensive unit tests for the new components:
    • test_mermaid_generator.py
    • test_node_repair.py
    • test_planner_prompts.py
    • test_validation_engine.py
    • test_workflow_validator_vibe.py

Screenshots

N/A (Backend logic refactoring)

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/30258 **State:** closed **Merged:** Yes --- # Summary feat #29774 This PR refactors the Vibe Workflow generation logic, extracting it from `api/core/llm_generator` into a dedicated, modular architecture in `api/core/workflow/generator`. It introduces a robust 5-step generation process (Planner -> Context Filter -> Builder -> Repair -> Validate) to improve the stability and quality of generated workflows. ## Key Changes ### 1. Modular Architecture (`api/core/workflow/generator`) - **Planner**: Responsible for generating the high-level workflow structure. - **Builder**: Handles the detailed configuration of individual nodes. - **Validation Engine**: A comprehensive rule-based system (`ValidationEngine`, `WorkflowValidator`) to check node and edge validity. - **Auto-Repair**: Implemented `NodeRepair` and `EdgeRepair` to automatically fix common generation errors (e.g., disconnected edges, invalid fields). - **Mermaid Visualization**: Added `MermaidGenerator` for workflow flowchart rendering. ### 2. Improvements & Fixes - **Stability Warning**: Added a localized stability warning (Chinese/English) to the API response to inform users that generated workflows may require debugging. - **Pydantic Fix**: Fixed a validation error in `CodeNodeData` where `outputs.status` could receive a string instead of a dictionary. - **Linting & Cleanup**: - Fixed multiple `ruff` linting errors (line lengths, implicit optionals, redundant exceptions). - Removed accidentally tracked `.pyc` files from the repository. ### 3. Testing - Added comprehensive unit tests for the new components: - `test_mermaid_generator.py` - `test_node_repair.py` - `test_planner_prompts.py` - `test_validation_engine.py` - `test_workflow_validator_vibe.py` ## Screenshots N/A (Backend logic refactoring) ## Checklist - [x] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:52:00 -05:00
yindo closed this issue 2026-02-21 20:52:00 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32750