Nishan30 commited on
Commit
2e228bc
·
verified ·
1 Parent(s): e59b6c9

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +71 -9
app.py CHANGED
@@ -125,16 +125,78 @@ 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
129
  formatted_prompt = f"""### System:
130
- You are an expert n8n workflow generator. Given a user's request, you generate clean, functional TypeScript code using the @n8n-generator/core DSL.
131
-
132
- Your output should:
133
- - Only contain the code, no explanations
134
- - Use the Workflow class from @n8n-generator/core
135
- - Use workflow.add() to create nodes
136
- - Use .to() or workflow.connect() for connections
137
- - Be ready to compile directly to n8n JSON
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
  ### Instruction:
140
  {prompt}
 
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
+
132
+ Your task is to generate TypeScript DSL code for n8n workflows based on user requests.
133
+
134
+ ## Available n8n Nodes:
135
+
136
+ ### TRIGGERS (Start workflows):
137
+ - n8n-nodes-base.webhook - Receives HTTP requests
138
+ - n8n-nodes-base.scheduleTrigger - Runs workflows on schedule (cron)
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)
156
+ - n8n-nodes-base.switch - Multi-way branching
157
+ - n8n-nodes-base.set - Transform/set data fields
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'
180
+ }});
181
+
182
+ const actionNode = workflow.add('n8n-nodes-base.slack', {{
183
+ channel: '#general',
184
+ text: 'Message text'
185
+ }});
186
+
187
+ // Connect nodes
188
+ triggerNode.to(actionNode);
189
+ ```
190
+
191
+ ## Guidelines:
192
+ 1. Always start with a trigger node
193
+ 2. Use descriptive workflow names
194
+ 3. Connect nodes logically
195
+ 4. Include proper parameters for each node
196
+ 5. Only use nodes from the list above
197
+ 6. Keep workflows clean and maintainable
198
+
199
+ Generate ONLY the TypeScript DSL code, wrapped in ```typescript code blocks.
200
 
201
  ### Instruction:
202
  {prompt}