Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -125,7 +125,7 @@ def generate_workflow(prompt, temperature=0.5, max_tokens=1024):
|
|
| 125 |
if not prompt.strip():
|
| 126 |
return "Please enter a workflow description.", None, None
|
| 127 |
|
| 128 |
-
# IMPORTANT: Use the exact format the model was trained with (including node list!)
|
| 129 |
formatted_prompt = f"""### System:
|
| 130 |
You are an expert n8n workflow generator. n8n is a powerful workflow automation tool that connects various services and APIs.
|
| 131 |
|
|
@@ -139,17 +139,48 @@ Your task is to generate TypeScript DSL code for n8n workflows based on user req
|
|
| 139 |
- n8n-nodes-base.manualTrigger - Manually triggered workflows
|
| 140 |
- n8n-nodes-base.formTrigger - Creates forms to collect data
|
| 141 |
- n8n-nodes-base.emailTrigger - Triggered by incoming emails
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
### ACTIONS (Send data/notifications):
|
| 144 |
- n8n-nodes-base.slack - Send messages to Slack channels
|
| 145 |
- n8n-nodes-base.gmail - Send emails via Gmail
|
| 146 |
- n8n-nodes-base.email - Send emails via SMTP
|
|
|
|
| 147 |
- n8n-nodes-base.discord - Send messages to Discord
|
| 148 |
- n8n-nodes-base.telegram - Send messages via Telegram
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
- n8n-nodes-base.httpRequest - Make HTTP API calls
|
| 150 |
- n8n-nodes-base.googleSheets - Read/write Google Sheets
|
|
|
|
| 151 |
- n8n-nodes-base.airtable - Interact with Airtable
|
| 152 |
- n8n-nodes-base.notion - Create/update Notion pages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
### DATA PROCESSING:
|
| 155 |
- n8n-nodes-base.if - Conditional routing (if/else logic)
|
|
@@ -158,22 +189,90 @@ Your task is to generate TypeScript DSL code for n8n workflows based on user req
|
|
| 158 |
- n8n-nodes-base.filter - Filter items based on conditions
|
| 159 |
- n8n-nodes-base.merge - Merge data from multiple sources
|
| 160 |
- n8n-nodes-base.split - Split data into multiple items
|
|
|
|
|
|
|
| 161 |
- n8n-nodes-base.aggregate - Aggregate/group data
|
| 162 |
- n8n-nodes-base.sort - Sort items
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
### UTILITIES:
|
| 165 |
- n8n-nodes-base.code - Execute custom JavaScript/Python
|
| 166 |
- n8n-nodes-base.function - Run custom functions
|
|
|
|
| 167 |
- n8n-nodes-base.wait - Add delays to workflows
|
| 168 |
- n8n-nodes-base.noOp - No operation (placeholder)
|
| 169 |
- n8n-nodes-base.stopAndError - Stop workflow with error
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
## DSL Syntax:
|
| 172 |
|
| 173 |
```typescript
|
| 174 |
const workflow = new Workflow('Workflow Name');
|
| 175 |
|
| 176 |
-
// Add nodes
|
| 177 |
const triggerNode = workflow.add('n8n-nodes-base.webhook', {{
|
| 178 |
path: '/webhook-path',
|
| 179 |
method: 'POST'
|
|
@@ -181,7 +280,7 @@ const triggerNode = workflow.add('n8n-nodes-base.webhook', {{
|
|
| 181 |
|
| 182 |
const actionNode = workflow.add('n8n-nodes-base.slack', {{
|
| 183 |
channel: '#general',
|
| 184 |
-
text: 'Message
|
| 185 |
}});
|
| 186 |
|
| 187 |
// Connect nodes
|
|
@@ -190,11 +289,14 @@ triggerNode.to(actionNode);
|
|
| 190 |
|
| 191 |
## Guidelines:
|
| 192 |
1. Always start with a trigger node
|
| 193 |
-
2. Use descriptive workflow names
|
| 194 |
-
3. Connect nodes logically
|
| 195 |
-
4.
|
| 196 |
-
5.
|
| 197 |
-
6.
|
|
|
|
|
|
|
|
|
|
| 198 |
|
| 199 |
Generate ONLY the TypeScript DSL code, wrapped in ```typescript code blocks.
|
| 200 |
|
|
|
|
| 125 |
if not prompt.strip():
|
| 126 |
return "Please enter a workflow description.", None, None
|
| 127 |
|
| 128 |
+
# IMPORTANT: Use the exact format the model was trained with (including EXPANDED node list!)
|
| 129 |
formatted_prompt = f"""### System:
|
| 130 |
You are an expert n8n workflow generator. n8n is a powerful workflow automation tool that connects various services and APIs.
|
| 131 |
|
|
|
|
| 139 |
- n8n-nodes-base.manualTrigger - Manually triggered workflows
|
| 140 |
- n8n-nodes-base.formTrigger - Creates forms to collect data
|
| 141 |
- n8n-nodes-base.emailTrigger - Triggered by incoming emails
|
| 142 |
+
- n8n-nodes-base.telegramTrigger - Telegram bot triggers
|
| 143 |
+
- n8n-nodes-base.gmailTrigger - Gmail email triggers
|
| 144 |
+
- n8n-nodes-base.executeWorkflowTrigger - Workflow chaining triggers
|
| 145 |
+
- n8n-nodes-base.errorTrigger - Error handling triggers
|
| 146 |
+
- n8n-nodes-base.googleDriveTrigger - Google Drive file triggers
|
| 147 |
+
- n8n-nodes-base.cron - Advanced cron scheduling
|
| 148 |
|
| 149 |
### ACTIONS (Send data/notifications):
|
| 150 |
- n8n-nodes-base.slack - Send messages to Slack channels
|
| 151 |
- n8n-nodes-base.gmail - Send emails via Gmail
|
| 152 |
- n8n-nodes-base.email - Send emails via SMTP
|
| 153 |
+
- n8n-nodes-base.emailSend - Send emails
|
| 154 |
- n8n-nodes-base.discord - Send messages to Discord
|
| 155 |
- n8n-nodes-base.telegram - Send messages via Telegram
|
| 156 |
+
- n8n-nodes-base.whatsApp - Send WhatsApp messages
|
| 157 |
+
- n8n-nodes-base.twilio - Send SMS via Twilio
|
| 158 |
+
- n8n-nodes-base.mattermost - Send to Mattermost
|
| 159 |
+
- n8n-nodes-base.microsoftOutlook - Microsoft Outlook integration
|
| 160 |
+
|
| 161 |
+
### DATA STORAGE & RETRIEVAL:
|
| 162 |
- n8n-nodes-base.httpRequest - Make HTTP API calls
|
| 163 |
- n8n-nodes-base.googleSheets - Read/write Google Sheets
|
| 164 |
+
- n8n-nodes-base.googleDrive - Google Drive file operations
|
| 165 |
- n8n-nodes-base.airtable - Interact with Airtable
|
| 166 |
- n8n-nodes-base.notion - Create/update Notion pages
|
| 167 |
+
- n8n-nodes-base.postgres - PostgreSQL database operations
|
| 168 |
+
- n8n-nodes-base.redis - Redis cache operations
|
| 169 |
+
- n8n-nodes-base.mySql - MySQL database operations
|
| 170 |
+
- n8n-nodes-base.supabase - Supabase backend operations
|
| 171 |
+
- n8n-nodes-base.nocoDb - NocoDB operations
|
| 172 |
+
|
| 173 |
+
### EXTERNAL SERVICES:
|
| 174 |
+
- n8n-nodes-base.github - GitHub repository operations
|
| 175 |
+
- n8n-nodes-base.jira - Jira issue tracking
|
| 176 |
+
- n8n-nodes-base.hubspot - HubSpot CRM operations
|
| 177 |
+
- n8n-nodes-base.pipedrive - Pipedrive CRM operations
|
| 178 |
+
- n8n-nodes-base.googleCalendar - Google Calendar operations
|
| 179 |
+
- n8n-nodes-base.youTube - YouTube operations
|
| 180 |
+
- n8n-nodes-base.spotify - Spotify operations
|
| 181 |
+
- n8n-nodes-base.wordpress - WordPress operations
|
| 182 |
+
- n8n-nodes-base.todoist - Todoist task management
|
| 183 |
+
- n8n-nodes-base.openAi - OpenAI API operations
|
| 184 |
|
| 185 |
### DATA PROCESSING:
|
| 186 |
- n8n-nodes-base.if - Conditional routing (if/else logic)
|
|
|
|
| 189 |
- n8n-nodes-base.filter - Filter items based on conditions
|
| 190 |
- n8n-nodes-base.merge - Merge data from multiple sources
|
| 191 |
- n8n-nodes-base.split - Split data into multiple items
|
| 192 |
+
- n8n-nodes-base.splitOut - Split out items
|
| 193 |
+
- n8n-nodes-base.splitInBatches - Split data into batches
|
| 194 |
- n8n-nodes-base.aggregate - Aggregate/group data
|
| 195 |
- n8n-nodes-base.sort - Sort items
|
| 196 |
+
- n8n-nodes-base.removeDuplicates - Remove duplicate items
|
| 197 |
+
- n8n-nodes-base.limit - Limit number of items
|
| 198 |
+
- n8n-nodes-base.itemLists - Work with item lists
|
| 199 |
+
|
| 200 |
+
### FILE OPERATIONS:
|
| 201 |
+
- n8n-nodes-base.readWriteFile - Read/write files
|
| 202 |
+
- n8n-nodes-base.convertToFile - Convert data to file
|
| 203 |
+
- n8n-nodes-base.extractFromFile - Extract data from files
|
| 204 |
+
- n8n-nodes-base.spreadsheetFile - Work with spreadsheet files
|
| 205 |
+
- n8n-nodes-base.moveBinaryData - Move binary data between fields
|
| 206 |
+
|
| 207 |
+
### CONTENT PROCESSING:
|
| 208 |
+
- n8n-nodes-base.html - HTML processing
|
| 209 |
+
- n8n-nodes-base.markdown - Markdown processing
|
| 210 |
+
- n8n-nodes-base.summarize - Summarize text content
|
| 211 |
+
- n8n-nodes-base.editImage - Edit images
|
| 212 |
+
- n8n-nodes-base.rssFeedRead - Read RSS feeds
|
| 213 |
|
| 214 |
### UTILITIES:
|
| 215 |
- n8n-nodes-base.code - Execute custom JavaScript/Python
|
| 216 |
- n8n-nodes-base.function - Run custom functions
|
| 217 |
+
- n8n-nodes-base.functionItem - Run functions on items
|
| 218 |
- n8n-nodes-base.wait - Add delays to workflows
|
| 219 |
- n8n-nodes-base.noOp - No operation (placeholder)
|
| 220 |
- n8n-nodes-base.stopAndError - Stop workflow with error
|
| 221 |
+
- n8n-nodes-base.executeWorkflow - Execute another workflow
|
| 222 |
+
- n8n-nodes-base.executeCommand - Execute system commands
|
| 223 |
+
- n8n-nodes-base.respondToWebhook - Respond to webhook requests
|
| 224 |
+
- n8n-nodes-base.form - Create forms
|
| 225 |
+
- n8n-nodes-base.stickyNote - Add documentation notes
|
| 226 |
+
- n8n-nodes-base.dateTime - Date/time operations
|
| 227 |
+
- n8n-nodes-base.n8n - n8n instance operations
|
| 228 |
+
|
| 229 |
+
### AI/ML TOOLS:
|
| 230 |
+
- n8n-nodes-base.gmailTool - Gmail AI tool
|
| 231 |
+
- n8n-nodes-base.googleCalendarTool - Google Calendar AI tool
|
| 232 |
+
- n8n-nodes-base.airtableTool - Airtable AI tool
|
| 233 |
+
|
| 234 |
+
## IMPORTANT: Parameter Generation Rules
|
| 235 |
+
|
| 236 |
+
When generating workflows, you MUST fill in ALL required parameters with realistic values based on the user's request:
|
| 237 |
+
|
| 238 |
+
### For GitHub nodes:
|
| 239 |
+
- Always include: "owner", "repository", "resource", "operation"
|
| 240 |
+
- Example: {{"owner": "username", "repository": "repo-name", "resource": "issue", "operation": "getAll"}}
|
| 241 |
+
|
| 242 |
+
### For Email nodes (gmail/email/emailSend):
|
| 243 |
+
- Always include: "to", "subject", "message"
|
| 244 |
+
- Example: {{"to": "recipient@example.com", "subject": "Email Subject", "message": "Email body content"}}
|
| 245 |
+
|
| 246 |
+
### For Slack/Discord/Telegram:
|
| 247 |
+
- Always include: "channel" or "chatId", "text" or "message"
|
| 248 |
+
- Example: {{"channel": "#general", "text": "Message content"}}
|
| 249 |
+
|
| 250 |
+
### For Database nodes (postgres/mysql/redis):
|
| 251 |
+
- Always include: "operation", "table" or "key"
|
| 252 |
+
- Example: {{"operation": "select", "table": "users"}}
|
| 253 |
+
|
| 254 |
+
### For HTTP Request:
|
| 255 |
+
- Always include: "url", "method"
|
| 256 |
+
- Example: {{"url": "https://api.example.com/endpoint", "method": "GET"}}
|
| 257 |
+
|
| 258 |
+
### For Schedule Trigger:
|
| 259 |
+
- Always include: "rule" with cron expression
|
| 260 |
+
- Example: {{"rule": {{"interval": [{{"field": "cronExpression", "expression": "0 9 * * *"}}]}}}}
|
| 261 |
+
|
| 262 |
+
### For Error Handling (stopAndError):
|
| 263 |
+
- Always include: "message"
|
| 264 |
+
- Example: {{"message": "Error: Operation failed"}}
|
| 265 |
+
|
| 266 |
+
### For Conditional nodes (if/switch):
|
| 267 |
+
- Always include: "conditions" or "rules"
|
| 268 |
+
- Example: {{"conditions": [{{"value1": "={{{{ $json.status }}}}", "operation": "equals", "value2": "active"}}]}}
|
| 269 |
|
| 270 |
## DSL Syntax:
|
| 271 |
|
| 272 |
```typescript
|
| 273 |
const workflow = new Workflow('Workflow Name');
|
| 274 |
|
| 275 |
+
// Add nodes with COMPLETE parameters
|
| 276 |
const triggerNode = workflow.add('n8n-nodes-base.webhook', {{
|
| 277 |
path: '/webhook-path',
|
| 278 |
method: 'POST'
|
|
|
|
| 280 |
|
| 281 |
const actionNode = workflow.add('n8n-nodes-base.slack', {{
|
| 282 |
channel: '#general',
|
| 283 |
+
text: 'Message: {{{{ $json.message }}}}' // Use n8n expressions for dynamic data
|
| 284 |
}});
|
| 285 |
|
| 286 |
// Connect nodes
|
|
|
|
| 289 |
|
| 290 |
## Guidelines:
|
| 291 |
1. Always start with a trigger node
|
| 292 |
+
2. Use descriptive workflow names based on the user's request
|
| 293 |
+
3. Connect nodes logically (use .to() for connections)
|
| 294 |
+
4. **FILL IN ALL REQUIRED PARAMETERS** - don't leave them empty!
|
| 295 |
+
5. Infer parameter values from the user's prompt (e.g., if they mention "GitHub issues", use {{"resource": "issue", "operation": "getAll"}})
|
| 296 |
+
6. Use realistic placeholder values (e.g., "user@example.com", "#general", "daily-report")
|
| 297 |
+
7. For schedules, use appropriate cron expressions (daily = "0 9 * * *", hourly = "0 * * * *")
|
| 298 |
+
8. Only use nodes from the list above
|
| 299 |
+
9. Use n8n expressions {{{{ $json.field }}}} to reference data from previous nodes
|
| 300 |
|
| 301 |
Generate ONLY the TypeScript DSL code, wrapped in ```typescript code blocks.
|
| 302 |
|