princeta3011 commited on
Commit
d1c9322
Β·
verified Β·
1 Parent(s): 534192d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +148 -148
app.py CHANGED
@@ -1,148 +1,148 @@
1
- import gradio as gr
2
- from gradio_workflowbuilder import WorkflowBuilder
3
- import json
4
-
5
-
6
- def export_workflow(workflow_data):
7
- """Export workflow as formatted JSON"""
8
- if not workflow_data:
9
- return "No workflow to export"
10
- return json.dumps(workflow_data, indent=2)
11
-
12
-
13
- # Create the main interface
14
- with gr.Blocks(
15
- title="🎨 Visual Workflow Builder",
16
- theme=gr.themes.Soft(),
17
- css="""
18
- .main-container { max-width: 1600px; margin: 0 auto; }
19
- .workflow-section { margin-bottom: 2rem; }
20
- .button-row { display: flex; gap: 1rem; justify-content: center; margin: 1rem 0; }
21
-
22
- .component-description {
23
- padding: 24px;
24
- background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
25
- border-radius: 12px;
26
- border-left: 4px solid #3b82f6;
27
- margin: 16px 0;
28
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
29
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
30
- }
31
-
32
- .component-description p {
33
- margin: 10px 0;
34
- line-height: 1.6;
35
- color: #374151;
36
- }
37
-
38
- .base-description {
39
- font-size: 17px;
40
- font-weight: 600;
41
- color: #1e293b;
42
- }
43
-
44
- .base-description strong {
45
- color: #3b82f6;
46
- font-weight: 700;
47
- }
48
-
49
- .feature-description {
50
- font-size: 16px;
51
- color: #1e293b;
52
- font-weight: 500;
53
- }
54
-
55
- .customization-note {
56
- font-size: 15px;
57
- color: #64748b;
58
- font-style: italic;
59
- }
60
-
61
- .sample-intro {
62
- font-size: 15px;
63
- color: #1e293b;
64
- font-weight: 600;
65
- margin-top: 16px;
66
- border-top: 1px solid #e2e8f0;
67
- padding-top: 16px;
68
- }
69
- """
70
- ) as demo:
71
-
72
- with gr.Column(elem_classes=["main-container"]):
73
- gr.Markdown("""
74
- # 🎨 Visual Workflow Builder
75
-
76
- **Create sophisticated workflows with drag and drop simplicity.**
77
- """)
78
-
79
- # Simple description section with styling
80
- gr.HTML("""
81
- <div class="component-description">
82
- <p class="base-description">Base custom component powered by <strong>svelteflow</strong>.</p>
83
- <p class="feature-description">Create custom workflows.</p>
84
- <p class="customization-note">You can customise the nodes as well as the design of the workflow.</p>
85
- <p class="sample-intro">Here is a sample:</p>
86
- </div>
87
- """)
88
-
89
- # Main workflow builder section
90
- with gr.Column(elem_classes=["workflow-section"]):
91
- workflow_builder = WorkflowBuilder(
92
- label="🎨 Visual Workflow Designer",
93
- info="Drag components from the sidebar β†’ Connect nodes by dragging from output (right) to input (left) β†’ Click nodes to edit properties"
94
- )
95
-
96
- # Export section below the workflow
97
- gr.Markdown("## πŸ’Ύ Export Workflow")
98
-
99
- with gr.Row():
100
- with gr.Column():
101
- export_output = gr.Code(
102
- language="json",
103
- label="Workflow Configuration",
104
- lines=10
105
- )
106
-
107
- # Action button
108
- with gr.Row(elem_classes=["button-row"]):
109
- export_btn = gr.Button("πŸ’Ύ Export JSON", variant="primary", size="lg")
110
-
111
- # Instructions
112
- with gr.Accordion("πŸ“– How to Use", open=False):
113
- gr.Markdown("""
114
- ### πŸš€ Getting Started
115
-
116
- 1. **Add Components**: Drag items from the left sidebar onto the canvas
117
- 2. **Connect Nodes**: Drag from the blue circle on the right of a node to the left circle of another
118
- 3. **Edit Properties**: Click any node to see its editable properties on the right panel
119
- 4. **Organize**: Drag nodes around to create a clean workflow layout
120
- 5. **Delete**: Use the βœ• button on nodes or click the red circle on connections
121
-
122
- ### 🎯 Component Types
123
-
124
- - **πŸ“₯ Inputs**: Text fields, file uploads, number inputs
125
- - **βš™οΈ Processing**: Language models, text processors, conditionals
126
- - **πŸ“€ Outputs**: Text displays, file exports, charts
127
- - **πŸ”§ Tools**: API calls, data transformers, validators
128
-
129
- ### πŸ’‘ Pro Tips
130
-
131
- - **Collapsible Panels**: Use the arrow buttons to hide/show sidebars
132
- - **Live Updates**: Properties update in real-time as you edit
133
- - **Export Options**: Get JSON config for your workflow
134
- """)
135
-
136
- # Event handlers
137
- export_btn.click(
138
- fn=export_workflow,
139
- inputs=[workflow_builder],
140
- outputs=[export_output]
141
- )
142
-
143
-
144
- if __name__ == "__main__":
145
- demo.launch(
146
- server_name="0.0.0.0",
147
- show_error=True
148
- )
 
1
+ import gradio as gr
2
+ from gradio_workflowbuilder import WorkflowBuilder
3
+ import json
4
+
5
+
6
+ def export_workflow(workflow_data):
7
+ """Export workflow as formatted JSON"""
8
+ if not workflow_data:
9
+ return "No workflow to export"
10
+ return json.dumps(workflow_data, indent=2)
11
+
12
+
13
+ # Create the main interface
14
+ with gr.Blocks(
15
+ title="🎨 Agentic Workflow Builder, Make Whatever You Want GO Crazy like me...",
16
+ theme=gr.themes.Soft(),
17
+ css="""
18
+ .main-container { max-width: 1600px; margin: 0 auto; }
19
+ .workflow-section { margin-bottom: 2rem; }
20
+ .button-row { display: flex; gap: 1rem; justify-content: center; margin: 1rem 0; }
21
+
22
+ .component-description {
23
+ padding: 24px;
24
+ background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
25
+ border-radius: 12px;
26
+ border-left: 4px solid #3b82f6;
27
+ margin: 16px 0;
28
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
29
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
30
+ }
31
+
32
+ .component-description p {
33
+ margin: 10px 0;
34
+ line-height: 1.6;
35
+ color: #374151;
36
+ }
37
+
38
+ .base-description {
39
+ font-size: 17px;
40
+ font-weight: 600;
41
+ color: #1e293b;
42
+ }
43
+
44
+ .base-description strong {
45
+ color: #3b82f6;
46
+ font-weight: 700;
47
+ }
48
+
49
+ .feature-description {
50
+ font-size: 16px;
51
+ color: #1e293b;
52
+ font-weight: 500;
53
+ }
54
+
55
+ .customization-note {
56
+ font-size: 15px;
57
+ color: #64748b;
58
+ font-style: italic;
59
+ }
60
+
61
+ .sample-intro {
62
+ font-size: 15px;
63
+ color: #1e293b;
64
+ font-weight: 600;
65
+ margin-top: 16px;
66
+ border-top: 1px solid #e2e8f0;
67
+ padding-top: 16px;
68
+ }
69
+ """
70
+ ) as demo:
71
+
72
+ with gr.Column(elem_classes=["main-container"]):
73
+ gr.Markdown("""
74
+ # 🎨 Visual Workflow Builder
75
+
76
+ **Create sophisticated workflows with drag and drop simplicity.**
77
+ """)
78
+
79
+ # Simple description section with styling
80
+ gr.HTML("""
81
+ <div class="component-description">
82
+ <p class="base-description">Base custom component powered by <strong>svelteflow</strong>.</p>
83
+ <p class="feature-description">Create custom workflows.</p>
84
+ <p class="customization-note">You can customise the nodes as well as the design of the workflow.</p>
85
+ <p class="sample-intro">Here is a sample:</p>
86
+ </div>
87
+ """)
88
+
89
+ # Main workflow builder section
90
+ with gr.Column(elem_classes=["workflow-section"]):
91
+ workflow_builder = WorkflowBuilder(
92
+ label="🎨 Visual Workflow Designer",
93
+ info="Drag components from the sidebar β†’ Connect nodes by dragging from output (right) to input (left) β†’ Click nodes to edit properties"
94
+ )
95
+
96
+ # Export section below the workflow
97
+ gr.Markdown("## πŸ’Ύ Export Workflow")
98
+
99
+ with gr.Row():
100
+ with gr.Column():
101
+ export_output = gr.Code(
102
+ language="json",
103
+ label="Workflow Configuration",
104
+ lines=10
105
+ )
106
+
107
+ # Action button
108
+ with gr.Row(elem_classes=["button-row"]):
109
+ export_btn = gr.Button("πŸ’Ύ Export JSON", variant="primary", size="lg")
110
+
111
+ # Instructions
112
+ with gr.Accordion("πŸ“– How to Use", open=False):
113
+ gr.Markdown("""
114
+ ### πŸš€ Getting Started
115
+
116
+ 1. **Add Components**: Drag items from the left sidebar onto the canvas
117
+ 2. **Connect Nodes**: Drag from the blue circle on the right of a node to the left circle of another
118
+ 3. **Edit Properties**: Click any node to see its editable properties on the right panel
119
+ 4. **Organize**: Drag nodes around to create a clean workflow layout
120
+ 5. **Delete**: Use the βœ• button on nodes or click the red circle on connections
121
+
122
+ ### 🎯 Component Types
123
+
124
+ - **πŸ“₯ Inputs**: Text fields, file uploads, number inputs
125
+ - **βš™οΈ Processing**: Language models, text processors, conditionals
126
+ - **πŸ“€ Outputs**: Text displays, file exports, charts
127
+ - **πŸ”§ Tools**: API calls, data transformers, validators
128
+
129
+ ### πŸ’‘ Pro Tips
130
+
131
+ - **Collapsible Panels**: Use the arrow buttons to hide/show sidebars
132
+ - **Live Updates**: Properties update in real-time as you edit
133
+ - **Export Options**: Get JSON config for your workflow
134
+ """)
135
+
136
+ # Event handlers
137
+ export_btn.click(
138
+ fn=export_workflow,
139
+ inputs=[workflow_builder],
140
+ outputs=[export_output]
141
+ )
142
+
143
+
144
+ if __name__ == "__main__":
145
+ demo.launch(
146
+ server_name="0.0.0.0",
147
+ show_error=True
148
+ )