AI & ML Nodes
I nodi AI & ML permettono di integrare modelli di machine learning, API AI e automazioni intelligenti nei workflow.
ML Inference
mlInference
Esegue inferenza su modelli ML locali o remoti.
Configurazione
| Campo | Tipo | Obbligatorio | Descrizione |
|---|---|---|---|
label | text | Sì | Nome identificativo |
provider | select | Sì | Provider ML |
model | text | Sì | Nome/ID modello |
input | json | Sì | Input per inferenza |
apiKey | secret | Per cloud | API Key provider |
endpoint | text | Per custom | Endpoint custom |
timeout | number | No | Timeout in ms |
Provider supportati
| Provider | Modelli | Use case |
|---|---|---|
openai | GPT-4, GPT-3.5, DALL-E, Whisper | Text, image, audio |
anthropic | Claude 3, Claude 2 | Text, reasoning |
huggingface | Migliaia di modelli | Vario |
replicate | Stable Diffusion, LLaMA | Image, text |
local | Ollama, LM Studio | Self-hosted |
custom | Endpoint HTTP custom | Qualsiasi |
OpenAI Integration
Workflow Esempio: Chatbot Support
Configurazione OpenAI
type: mlInference
provider: openai
model: "gpt-4-turbo"
apiKey: "{{secrets.OPENAI_API_KEY}}"
input:
messages:
- role: "system"
content: |
Sei un assistente clienti per Example Corp.
Rispondi sempre in italiano.
Se non sai qualcosa, suggerisci di contattare support@example.com
- role: "user"
content: "{{trigger.data.message}}"
temperature: 0.7
max_tokens: 500
timeout: 30000
label: "GPT-4 Customer Support"
Output
{
"provider": "openai",
"model": "gpt-4-turbo",
"response": {
"id": "chatcmpl-abc123",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Ciao! Sono qui per aiutarti..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 150,
"completion_tokens": 85,
"total_tokens": 235
}
},
"latency": 1234
}
Sentiment Analysis
Analizza il sentiment di testo.
Workflow Esempio: Review Analysis
Configurazione sentiment
type: mlInference
provider: huggingface
model: "cardiffnlp/twitter-roberta-base-sentiment-latest"
apiKey: "{{secrets.HF_API_KEY}}"
input:
text: "{{trigger.data.reviewText}}"
label: "Sentiment Analysis"
Output
{
"provider": "huggingface",
"model": "cardiffnlp/twitter-roberta-base-sentiment-latest",
"response": [
{ "label": "positive", "score": 0.92 },
{ "label": "neutral", "score": 0.06 },
{ "label": "negative", "score": 0.02 }
],
"latency": 234
}
Image Generation
Genera immagini con AI.
Workflow Esempio: Social Media Automation
Configurazione DALL-E
type: mlInference
provider: openai
model: "dall-e-3"
apiKey: "{{secrets.OPENAI_API_KEY}}"
input:
prompt: "{{gptPrompt.output.response.choices[0].message.content}}"
size: "1024x1024"
quality: "hd"
style: "vivid"
label: "Generate Social Image"
Output
{
"provider": "openai",
"model": "dall-e-3",
"response": {
"data": [
{
"url": "https://oaidalleapiprodscus.blob.core.windows.net/...",
"revised_prompt": "A vibrant digital illustration..."
}
]
},
"latency": 15000
}
Local Models (Ollama)
Esegui modelli localmente con Ollama.
Workflow Esempio: Document Processing
Configurazione Ollama
type: mlInference
provider: local
endpoint: "http://localhost:11434"
model: "llama2"
input:
prompt: |
Riassumi il seguente documento in 3 punti chiave:
{{transform.output.extractedText}}
options:
temperature: 0.3
num_predict: 500
label: "Local LLM Summary"
Embeddings
Genera embeddings per ricerca semantica.
Workflow Esempio: Semantic Search
Configurazione embeddings
type: mlInference
provider: openai
model: "text-embedding-3-small"
apiKey: "{{secrets.OPENAI_API_KEY}}"
input:
input: "{{trigger.data.query}}"
dimensions: 512
label: "Generate Query Embedding"
Output
{
"provider": "openai",
"model": "text-embedding-3-small",
"response": {
"data": [
{
"embedding": [0.0023, -0.0045, 0.0123, ...],
"index": 0
}
],
"usage": {
"prompt_tokens": 8,
"total_tokens": 8
}
}
}
OpenAPI Importer
openApiImporter
Importa specifiche OpenAPI per generare automaticamente nodi API.
Configurazione
| Campo | Tipo | Obbligatorio | Descrizione |
|---|---|---|---|
label | text | Sì | Nome identificativo |
specUrl | text | Sì | URL della specifica OpenAPI |
specFile | file | Alt | File OpenAPI locale |
baseUrl | text | No | Base URL override |
auth | object | No | Autenticazione default |
Workflow Esempio: API Discovery
Configurazione
type: openApiImporter
specUrl: "https://api.example.com/openapi.json"
baseUrl: "https://api.example.com/v2"
auth:
type: bearer
token: "{{secrets.API_TOKEN}}"
label: "Import Example API"
Output
{
"title": "Example API",
"version": "2.0.0",
"baseUrl": "https://api.example.com/v2",
"endpoints": [
{
"path": "/users",
"method": "GET",
"operationId": "listUsers",
"summary": "List all users",
"parameters": [
{ "name": "limit", "in": "query", "type": "integer" }
]
},
{
"path": "/users/{id}",
"method": "GET",
"operationId": "getUser",
"summary": "Get user by ID"
}
],
"schemas": {
"User": { "type": "object", "properties": {...} }
}
}
API Test Suite
apiTestSuite
Esegue test automatici su API importate da OpenAPI.
Configurazione
| Campo | Tipo | Obbligatorio | Descrizione |
|---|---|---|---|
label | text | Sì | Nome identificativo |
source | select | Sì | Sorgente test (openapi, manual) |
endpoints | array | Sì | Endpoint da testare |
mode | select | No | Modalità (sequential, parallel, stress) |
iterations | number | Per stress | Numero iterazioni |
validateSchema | boolean | No | Valida response schema |
Workflow Esempio: API Testing Pipeline
Configurazione test suite
type: apiTestSuite
source: openapi
openApiSpec: "{{openApiImporter.output}}"
mode: sequential
endpoints:
- operationId: "listUsers"
expectedStatus: 200
validateSchema: true
- operationId: "getUser"
pathParams:
id: "user_123"
expectedStatus: 200
- operationId: "createUser"
body:
name: "Test User"
email: "test@example.com"
expectedStatus: 201
timeout: 10000
label: "API Integration Tests"
Output
{
"mode": "sequential",
"totalTests": 3,
"passed": 2,
"failed": 1,
"duration": 1234,
"results": [
{
"operationId": "listUsers",
"status": "passed",
"responseStatus": 200,
"responseTime": 145,
"schemaValid": true
},
{
"operationId": "getUser",
"status": "passed",
"responseStatus": 200,
"responseTime": 89
},
{
"operationId": "createUser",
"status": "failed",
"responseStatus": 500,
"error": "Internal Server Error",
"responseTime": 234
}
]
}
Workflow Completo: AI Content Pipeline
Pipeline completa per generazione e moderazione contenuti.
Rate Limiting e Costi
Gestione rate limits
Configurazione rate limiting
type: mlInference
provider: openai
model: "gpt-4-turbo"
rateLimit:
maxRequests: 60
perMinutes: 1
onLimitReached: queue # queue, error, skip
Monitoraggio costi
Workflow cost tracking
type: transform
expression: |
{
timestamp: new Date().toISOString(),
model: mlInference.output.model,
tokens: mlInference.output.response.usage.total_tokens,
cost: calculateCost(
mlInference.output.model,
mlInference.output.response.usage
)
}
Best Practices
Prompt engineering
- Sii specifico nel prompt di sistema
- Fornisci esempi (few-shot learning)
- Struttura l’output richiesto (JSON, markdown)
- Imposta temperature in base al task
- 0.0-0.3: Task precisi (estrazione, classificazione)
- 0.5-0.7: Task creativi bilanciati
- 0.8-1.0: Task molto creativi
Fallback e retry
- Retry automatico per errori transitori
- Fallback a modello alternativo
- Circuit breaker per proteggere da outage
type: mlInference
provider: openai
model: "gpt-4-turbo"
fallback:
provider: anthropic
model: "claude-3-sonnet"
retries: 3
retryDelay: 1000
Caching
Cache le risposte per query identiche:
cache:
enabled: true
ttl: 3600 # 1 ora
keyFields: ["messages", "model"]
Sicurezza
- Content moderation prima di pubblicare
- Input validation prima di inferenza
- Output sanitization prima di usare
- PII detection per dati sensibili