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

CampoTipoObbligatorioDescrizione
labeltextNome identificativo
providerselectProvider ML
modeltextNome/ID modello
inputjsonInput per inferenza
apiKeysecretPer cloudAPI Key provider
endpointtextPer customEndpoint custom
timeoutnumberNoTimeout in ms

Provider supportati

ProviderModelliUse case
openaiGPT-4, GPT-3.5, DALL-E, WhisperText, image, audio
anthropicClaude 3, Claude 2Text, reasoning
huggingfaceMigliaia di modelliVario
replicateStable Diffusion, LLaMAImage, text
localOllama, LM StudioSelf-hosted
customEndpoint HTTP customQualsiasi

OpenAI Integration

Workflow Esempio: Chatbot Support

Diagramma di flusso

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

Diagramma di flusso

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

Diagramma di flusso

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

Diagramma di flusso

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.

Diagramma di flusso

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

CampoTipoObbligatorioDescrizione
labeltextNome identificativo
specUrltextURL della specifica OpenAPI
specFilefileAltFile OpenAPI locale
baseUrltextNoBase URL override
authobjectNoAutenticazione default

Workflow Esempio: API Discovery

Diagramma di flusso

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

CampoTipoObbligatorioDescrizione
labeltextNome identificativo
sourceselectSorgente test (openapi, manual)
endpointsarrayEndpoint da testare
modeselectNoModalità (sequential, parallel, stress)
iterationsnumberPer stressNumero iterazioni
validateSchemabooleanNoValida response schema

Workflow Esempio: API Testing Pipeline

Diagramma di flusso

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.

Diagramma di flusso


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

Diagramma di flusso

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
  1. Sii specifico nel prompt di sistema
  2. Fornisci esempi (few-shot learning)
  3. Struttura l’output richiesto (JSON, markdown)
  4. 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
  1. Retry automatico per errori transitori
  2. Fallback a modello alternativo
  3. 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
  1. Content moderation prima di pubblicare
  2. Input validation prima di inferenza
  3. Output sanitization prima di usare
  4. PII detection per dati sensibili