|
| 1 | +import { TemplateCategory } from './template.entity'; |
| 2 | +import type { FlowGraph } from '../flows/entities/flow.entity'; |
| 3 | + |
| 4 | +interface SeedTemplate { |
| 5 | + name: string; |
| 6 | + description: string; |
| 7 | + category: TemplateCategory; |
| 8 | + icon: string; |
| 9 | + graph: FlowGraph; |
| 10 | + isBuiltin: boolean; |
| 11 | +} |
| 12 | + |
| 13 | +export const BUILTIN_TEMPLATES: SeedTemplate[] = [ |
| 14 | + { |
| 15 | + name: 'Web Scraper → Summarize → Email', |
| 16 | + description: 'Scrape a webpage, summarize the content with an LLM, and send the summary by email.', |
| 17 | + category: TemplateCategory.AI, |
| 18 | + icon: '🌐', |
| 19 | + isBuiltin: true, |
| 20 | + graph: { |
| 21 | + nodes: [ |
| 22 | + { id: 'n1', type: 'web-scraper', position: { x: 100, y: 200 }, data: { label: 'Web Scraper', config: { url: '', selector: 'body' } } }, |
| 23 | + { id: 'n2', type: 'ai-llm', position: { x: 400, y: 200 }, data: { label: 'Summarize', config: { prompt: 'Summarize this content in 3 bullet points: {{input}}', model: 'gpt-4o-mini' } } }, |
| 24 | + { id: 'n3', type: 'email-sender', position: { x: 700, y: 200 }, data: { label: 'Send Email', config: { to: '', subject: 'Daily Summary' } } }, |
| 25 | + ], |
| 26 | + edges: [ |
| 27 | + { id: 'e1', source: 'n1', target: 'n2' }, |
| 28 | + { id: 'e2', source: 'n2', target: 'n3' }, |
| 29 | + ], |
| 30 | + }, |
| 31 | + }, |
| 32 | + { |
| 33 | + name: 'GitHub PR Review', |
| 34 | + description: 'Fetch open pull requests from a GitHub repo and generate an AI code review for each.', |
| 35 | + category: TemplateCategory.AI, |
| 36 | + icon: '🔍', |
| 37 | + isBuiltin: true, |
| 38 | + graph: { |
| 39 | + nodes: [ |
| 40 | + { id: 'n1', type: 'api-caller', position: { x: 100, y: 200 }, data: { label: 'Fetch PRs', config: { url: 'https://api.github.com/repos/{{owner}}/{{repo}}/pulls', method: 'GET', headers: { Authorization: 'Bearer {{github_token}}' } } } }, |
| 41 | + { id: 'n2', type: 'ai-llm', position: { x: 400, y: 200 }, data: { label: 'Review Code', config: { prompt: 'Review this pull request and identify potential issues: {{input}}', model: 'gpt-4o' } } }, |
| 42 | + { id: 'n3', type: 'webhook-sender', position: { x: 700, y: 200 }, data: { label: 'Post Comment', config: { url: '', method: 'POST' } } }, |
| 43 | + ], |
| 44 | + edges: [ |
| 45 | + { id: 'e1', source: 'n1', target: 'n2' }, |
| 46 | + { id: 'e2', source: 'n2', target: 'n3' }, |
| 47 | + ], |
| 48 | + }, |
| 49 | + }, |
| 50 | + { |
| 51 | + name: 'Daily News Digest', |
| 52 | + description: 'Fetch news from an RSS feed, filter relevant items, and compile a daily digest.', |
| 53 | + category: TemplateCategory.AUTOMATION, |
| 54 | + icon: '📰', |
| 55 | + isBuiltin: true, |
| 56 | + graph: { |
| 57 | + nodes: [ |
| 58 | + { id: 'n1', type: 'rss-reader', position: { x: 100, y: 200 }, data: { label: 'RSS Feed', config: { url: '', maxItems: 20 } } }, |
| 59 | + { id: 'n2', type: 'ai-llm', position: { x: 400, y: 200 }, data: { label: 'Filter & Rank', config: { prompt: 'From these news items, select the 5 most important and explain why: {{input}}', model: 'gpt-4o-mini' } } }, |
| 60 | + { id: 'n3', type: 'email-sender', position: { x: 700, y: 200 }, data: { label: 'Send Digest', config: { to: '', subject: 'Daily News Digest' } } }, |
| 61 | + ], |
| 62 | + edges: [ |
| 63 | + { id: 'e1', source: 'n1', target: 'n2' }, |
| 64 | + { id: 'e2', source: 'n2', target: 'n3' }, |
| 65 | + ], |
| 66 | + }, |
| 67 | + }, |
| 68 | + { |
| 69 | + name: 'API Health Monitor', |
| 70 | + description: 'Ping a list of API endpoints, check response times, and alert on failures.', |
| 71 | + category: TemplateCategory.MONITORING, |
| 72 | + icon: '🔔', |
| 73 | + isBuiltin: true, |
| 74 | + graph: { |
| 75 | + nodes: [ |
| 76 | + { id: 'n1', type: 'api-caller', position: { x: 100, y: 200 }, data: { label: 'Health Check', config: { url: '', method: 'GET', timeout: 5000 } } }, |
| 77 | + { id: 'n2', type: 'condition', position: { x: 400, y: 200 }, data: { label: 'Check Status', config: { condition: '{{status}} !== 200 || {{responseTime}} > 2000' } } }, |
| 78 | + { id: 'n3', type: 'webhook-sender', position: { x: 700, y: 100 }, data: { label: 'Alert Slack', config: { url: '', method: 'POST' } } }, |
| 79 | + { id: 'n4', type: 'logger', position: { x: 700, y: 300 }, data: { label: 'Log OK', config: { level: 'info' } } }, |
| 80 | + ], |
| 81 | + edges: [ |
| 82 | + { id: 'e1', source: 'n1', target: 'n2' }, |
| 83 | + { id: 'e2', source: 'n2', target: 'n3', label: 'fail' }, |
| 84 | + { id: 'e3', source: 'n2', target: 'n4', label: 'pass' }, |
| 85 | + ], |
| 86 | + }, |
| 87 | + }, |
| 88 | + { |
| 89 | + name: 'Data Extractor & CSV Export', |
| 90 | + description: 'Extract structured data from text or HTML using an LLM and format it as CSV.', |
| 91 | + category: TemplateCategory.DATA, |
| 92 | + icon: '📊', |
| 93 | + isBuiltin: true, |
| 94 | + graph: { |
| 95 | + nodes: [ |
| 96 | + { id: 'n1', type: 'web-scraper', position: { x: 100, y: 200 }, data: { label: 'Scrape Data', config: { url: '', selector: 'table' } } }, |
| 97 | + { id: 'n2', type: 'ai-llm', position: { x: 400, y: 200 }, data: { label: 'Extract Structure', config: { prompt: 'Extract all data from this content and return as JSON array with consistent keys: {{input}}', model: 'gpt-4o-mini' } } }, |
| 98 | + { id: 'n3', type: 'transformer', position: { x: 700, y: 200 }, data: { label: 'To CSV', config: { format: 'csv' } } }, |
| 99 | + ], |
| 100 | + edges: [ |
| 101 | + { id: 'e1', source: 'n1', target: 'n2' }, |
| 102 | + { id: 'e2', source: 'n2', target: 'n3' }, |
| 103 | + ], |
| 104 | + }, |
| 105 | + }, |
| 106 | +]; |
0 commit comments