mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 15:07:55 -05:00
feat(i18n): update translations (#1794)
* feat(i18n): update translations * remove all outdated triggers, cleanup yml too
This commit is contained in:
@@ -1,187 +0,0 @@
|
||||
---
|
||||
title: API-Trigger
|
||||
description: Starten Sie einen Workflow über eine authentifizierte HTTP-Anfrage
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Übersicht
|
||||
|
||||
Der API-Trigger stellt Ihren Workflow als sicheren HTTP-Endpunkt bereit. Senden Sie JSON-Daten an den Endpunkt und Ihr Workflow verarbeitet diese sofort. API-Aufrufe werden immer gegen Ihre neueste Bereitstellung ausgeführt.
|
||||
|
||||
## Eingabeformat konfigurieren
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/api-trigger-light.png'
|
||||
alt='API-Trigger Eingabeformat'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
Fügen Sie für jeden Parameter ein Feld **Eingabeformat** hinzu. Die Ausgabeschlüssel zur Laufzeit spiegeln das Schema wider und sind auch unter `<api.input>` verfügbar.
|
||||
|
||||
Manuelle Ausführungen im Editor verwenden die Spalte `value`, damit Sie testen können, ohne eine Anfrage zu senden. Während der Ausführung füllt der Resolver sowohl `<api.userId>` als auch `<api.input.userId>` aus.
|
||||
|
||||
## Anfrage-Beispiel
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{"userId":"demo-user","maxTokens":1024}'
|
||||
```
|
||||
|
||||
Erfolgreiche Antworten geben das serialisierte Ausführungsergebnis vom Executor zurück. Fehler zeigen Validierungs-, Authentifizierungs- oder Workflow-Fehler an.
|
||||
|
||||
## Streaming-Antworten
|
||||
|
||||
Aktivieren Sie Echtzeit-Streaming, um Workflow-Ausgaben zu erhalten, während sie zeichen-für-zeichen generiert werden. Dies ist nützlich, um KI-Antworten progressiv für Benutzer anzuzeigen.
|
||||
|
||||
### Anfrageparameter
|
||||
|
||||
Fügen Sie diese Parameter hinzu, um Streaming zu aktivieren:
|
||||
|
||||
- `stream` - Auf `true` setzen, um Server-Sent Events (SSE) Streaming zu aktivieren
|
||||
- `selectedOutputs` - Array von Block-Ausgaben zum Streamen (z.B. `["agent1.content"]`)
|
||||
|
||||
### Block-Ausgabeformat
|
||||
|
||||
Verwenden Sie das `blockName.attribute` Format, um anzugeben, welche Block-Ausgaben gestreamt werden sollen:
|
||||
- Format: `"blockName.attribute"` (z.B. Wenn Sie den Inhalt des Agent 1-Blocks streamen möchten, würden Sie `"agent1.content"` verwenden)
|
||||
- Blocknamen sind nicht case-sensitive und Leerzeichen werden ignoriert
|
||||
|
||||
### Beispielanfrage
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{
|
||||
"message": "Count to five",
|
||||
"stream": true,
|
||||
"selectedOutputs": ["agent1.content"]
|
||||
}'
|
||||
```
|
||||
|
||||
### Antwortformat
|
||||
|
||||
Streaming-Antworten verwenden das Server-Sent Events (SSE) Format:
|
||||
|
||||
```
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"}
|
||||
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"}
|
||||
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", three"}
|
||||
|
||||
data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}}
|
||||
|
||||
data: [DONE]
|
||||
```
|
||||
|
||||
Jedes Ereignis enthält:
|
||||
- **Streaming-Chunks**: `{"blockId": "...", "chunk": "text"}` - Echtzeit-Text während er generiert wird
|
||||
- **Abschlussereignis**: `{"event": "done", ...}` - Ausführungsmetadaten und vollständige Ergebnisse
|
||||
- **Terminator**: `[DONE]` - Signalisiert das Ende des Streams
|
||||
|
||||
### Streaming mehrerer Blöcke
|
||||
|
||||
Wenn `selectedOutputs` mehrere Blöcke enthält, zeigt jeder Chunk an, welcher Block ihn erzeugt hat:
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{
|
||||
"message": "Process this request",
|
||||
"stream": true,
|
||||
"selectedOutputs": ["agent1.content", "agent2.content"]
|
||||
}'
|
||||
```
|
||||
|
||||
Das Feld `blockId` in jedem Chunk ermöglicht es Ihnen, die Ausgabe zum richtigen UI-Element zu leiten:
|
||||
|
||||
```
|
||||
data: {"blockId":"agent1-uuid","chunk":"Processing..."}
|
||||
|
||||
data: {"blockId":"agent2-uuid","chunk":"Analyzing..."}
|
||||
|
||||
data: {"blockId":"agent1-uuid","chunk":" complete"}
|
||||
```
|
||||
|
||||
## Ausgabereferenz
|
||||
|
||||
| Referenz | Beschreibung |
|
||||
|-----------|-------------|
|
||||
| `<api.field>` | Im Eingabeformat definiertes Feld |
|
||||
| `<api.input>` | Gesamter strukturierter Anfragekörper |
|
||||
|
||||
Wenn kein Eingabeformat definiert ist, stellt der Executor das rohe JSON nur unter `<api.input>` zur Verfügung.
|
||||
|
||||
<Callout type="warning">
|
||||
Ein Workflow kann nur einen API-Trigger enthalten. Veröffentlichen Sie nach Änderungen eine neue Bereitstellung, damit der Endpunkt aktuell bleibt.
|
||||
</Callout>
|
||||
|
||||
### Datei-Upload-Format
|
||||
|
||||
Die API akzeptiert Dateien in zwei Formaten:
|
||||
|
||||
**1. Base64-kodierte Dateien** (empfohlen für SDKs):
|
||||
|
||||
```json
|
||||
{
|
||||
"documents": [{
|
||||
"type": "file",
|
||||
"data": "data:application/pdf;base64,JVBERi0xLjQK...",
|
||||
"name": "document.pdf",
|
||||
"mime": "application/pdf"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
- Maximale Dateigröße: 20MB pro Datei
|
||||
- Dateien werden in den Cloud-Speicher hochgeladen und in UserFile-Objekte mit allen Eigenschaften umgewandelt
|
||||
|
||||
**2. Direkte URL-Referenzen**:
|
||||
|
||||
```json
|
||||
{
|
||||
"documents": [{
|
||||
"type": "url",
|
||||
"data": "https://example.com/document.pdf",
|
||||
"name": "document.pdf",
|
||||
"mime": "application/pdf"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
- Die Datei wird nicht hochgeladen, die URL wird direkt weitergegeben
|
||||
- Nützlich für die Referenzierung bestehender Dateien
|
||||
|
||||
### Dateieigenschaften
|
||||
|
||||
Für Dateien können alle Eigenschaften abgerufen werden:
|
||||
|
||||
| Eigenschaft | Beschreibung | Typ |
|
||||
|----------|-------------|------|
|
||||
| `<api.fieldName[0].url>` | Signierte Download-URL | string |
|
||||
| `<api.fieldName[0].name>` | Ursprünglicher Dateiname | string |
|
||||
| `<api.fieldName[0].size>` | Dateigröße in Bytes | number |
|
||||
| `<api.fieldName[0].type>` | MIME-Typ | string |
|
||||
| `<api.fieldName[0].uploadedAt>` | Upload-Zeitstempel (ISO 8601) | string |
|
||||
| `<api.fieldName[0].expiresAt>` | URL-Ablaufzeitstempel (ISO 8601) | string |
|
||||
|
||||
Für URL-referenzierte Dateien sind dieselben Eigenschaften verfügbar, außer `uploadedAt` und `expiresAt`, da die Datei nicht in unseren Speicher hochgeladen wird.
|
||||
|
||||
Wenn kein Eingabeformat definiert ist, stellt der Executor das rohe JSON nur unter `<api.input>` zur Verfügung.
|
||||
|
||||
<Callout type="warning">
|
||||
Ein Workflow kann nur einen API-Trigger enthalten. Veröffentlichen Sie nach Änderungen eine neue Bereitstellung, damit der Endpunkt aktuell bleibt.
|
||||
</Callout>
|
||||
@@ -1,51 +0,0 @@
|
||||
---
|
||||
title: Chat-Auslöser
|
||||
description: Starten Sie einen Workflow aus einer Chat-Bereitstellung
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Übersicht
|
||||
|
||||
Der Chat-Auslöser erstellt eine Konversationsschnittstelle für Ihren Workflow. Stellen Sie Ihren Workflow als Chat bereit, und Benutzer können über eine teilbare URL damit interagieren. Jede Nachricht startet eine neue Workflow-Ausführung mit Ihrer neuesten Bereitstellung.
|
||||
|
||||
## Laufzeit-Ausgaben
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/chat-trigger-light.png'
|
||||
alt='Chat-Bereitstellungskonversation'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
Der Auslöser schreibt drei Felder, auf die nachfolgende Blöcke verweisen können:
|
||||
|
||||
| Referenz | Beschreibung |
|
||||
|-----------|-------------|
|
||||
| `<chat.input>` | Neueste Benutzernachricht |
|
||||
| `<chat.conversationId>` | Konversations-Thread-ID |
|
||||
| `<chat.files>` | Optionale hochgeladene Dateien |
|
||||
|
||||
Dateien enthalten `name`, `mimeType` und einen signierten Download `url`.
|
||||
|
||||
## Nutzungshinweise
|
||||
|
||||
1. Fügen Sie einen Chat-Auslöser-Block pro Workflow hinzu.
|
||||
2. Stellen Sie den Workflow im Chat-Modus bereit.
|
||||
3. Teilen Sie den Bereitstellungslink – jede Antwort verwendet die Konversations-ID wieder, sodass der Workflow den Kontext beibehalten kann.
|
||||
|
||||
<Callout type="info">
|
||||
Der Builder blockiert mehrere Chat-Auslöser-Blöcke im selben Workflow.
|
||||
</Callout>
|
||||
|
||||
1. Fügen Sie einen Chat-Trigger-Block pro Workflow hinzu.
|
||||
2. Stellen Sie den Workflow im Chat-Modus bereit.
|
||||
3. Teilen Sie den Bereitstellungslink – jede Antwort verwendet die Konversations-ID wieder, damit der Workflow den Kontext beibehalten kann.
|
||||
|
||||
<Callout type="info">
|
||||
Der Builder blockiert mehrere Chat-Trigger-Blöcke im selben Workflow.
|
||||
</Callout>
|
||||
@@ -7,46 +7,34 @@ import { Card, Cards } from 'fumadocs-ui/components/card'
|
||||
|
||||
## Kern-Auslöser
|
||||
|
||||
Wähle einen Auslöser pro Workflow, um zu definieren, wie er startet:
|
||||
Verwende den Start-Block für alles, was vom Editor, von Deploy-to-API oder von Deploy-to-Chat-Erfahrungen ausgeht. Andere Trigger bleiben für ereignisgesteuerte Workflows verfügbar:
|
||||
|
||||
<Cards>
|
||||
<Card title="API" href="/triggers/api">
|
||||
HTTP-Endpunkt, der JSON-Bodies in Workflow-Eingaben umwandelt
|
||||
</Card>
|
||||
<Card title="Chat" href="/triggers/chat">
|
||||
Bereitgestellte Chat-Oberfläche mit Streaming-Antworten
|
||||
</Card>
|
||||
<Card title="Eingabeformular" href="/triggers/input-form">
|
||||
Typisierte manuelle Eingabe für Editor-Ausführungen und Unterworkflows
|
||||
</Card>
|
||||
<Card title="Manuell" href="/triggers/manual">
|
||||
Bedarfsgesteuerte Ausführungen ohne zusätzliche Daten
|
||||
</Card>
|
||||
<Card title="Zeitplan" href="/triggers/schedule">
|
||||
Cron- oder intervallbasierte Ausführung
|
||||
<Card title="Start" href="/triggers/start">
|
||||
Einheitlicher Einstiegspunkt, der Editor-Ausführungen, API-Bereitstellungen und Chat-Bereitstellungen unterstützt
|
||||
</Card>
|
||||
<Card title="Webhook" href="/triggers/webhook">
|
||||
Externe Webhook-Payloads empfangen
|
||||
</Card>
|
||||
<Card title="Schedule" href="/triggers/schedule">
|
||||
Cron- oder intervallbasierte Ausführung
|
||||
</Card>
|
||||
</Cards>
|
||||
|
||||
## Schneller Vergleich
|
||||
|
||||
| Auslöser | Startbedingung |
|
||||
| Trigger | Startbedingung |
|
||||
|---------|-----------------|
|
||||
| **API** | Authentifizierter HTTP POST |
|
||||
| **Chat** | Chat-Deployment-Nachricht |
|
||||
| **Eingabeformular** | Bei manueller Übermittlung im Editor oder übergeordneten Workflow |
|
||||
| **Manuell** | Ausführen-Schaltfläche im Editor |
|
||||
| **Zeitplan** | Timer, der im Zeitplan-Modal verwaltet wird |
|
||||
| **Webhook** | Bei eingehendem HTTP-Request |
|
||||
| **Start** | Editor-Ausführungen, Deploy-to-API-Anfragen oder Chat-Nachrichten |
|
||||
| **Schedule** | Timer, der im Zeitplan-Modal verwaltet wird |
|
||||
| **Webhook** | Bei eingehender HTTP-Anfrage |
|
||||
|
||||
## Verwendung von Auslösern
|
||||
> Der Start-Block stellt immer `input`, `conversationId` und `files`Felder bereit. Füge benutzerdefinierte Felder zum Eingabeformat für zusätzliche strukturierte Daten hinzu.
|
||||
|
||||
1. Platziere den Auslöser-Block im Startslot.
|
||||
2. Konfiguriere alle erforderlichen Schemas oder Authentifizierungen.
|
||||
## Verwendung von Triggern
|
||||
|
||||
1. Platziere den Start-Block im Startslot (oder einen alternativen Trigger wie Webhook/Schedule).
|
||||
2. Konfiguriere alle erforderlichen Schema- oder Authentifizierungseinstellungen.
|
||||
3. Verbinde den Block mit dem Rest des Workflows.
|
||||
|
||||
> Deployments unterstützen jeden Auslöser. Aktualisiere den Workflow, stelle ihn neu bereit, und alle Auslöser-Einstiegspunkte übernehmen den neuen Snapshot. Erfahre mehr unter [Ausführung → Deployment-Snapshots](/execution).
|
||||
|
||||
Legacy-Starter-Blöcke bleiben für bestehende Flows erhalten, erscheinen aber nicht mehr in neuen Builds.
|
||||
> Bereitstellungen unterstützen jeden Trigger. Aktualisiere den Workflow, stelle ihn erneut bereit, und alle Trigger-Einstiegspunkte übernehmen den neuen Snapshot. Erfahre mehr unter [Ausführung → Bereitstellungs-Snapshots](/execution).
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
---
|
||||
title: Eingabeformular-Trigger
|
||||
description: Manueller Trigger mit einem strukturierten Eingabeschema
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Übersicht
|
||||
|
||||
Verwenden Sie einen Eingabeformular-Trigger, wenn ein Workflow vom Editor aus mit typisierten Feldern gestartet werden soll. Das Ausführungspanel zeigt genau die Felder an, die Sie definieren, sodass der Workflow immer saubere Daten erhält.
|
||||
|
||||
## Was Sie definieren
|
||||
|
||||
Fügen Sie Felder im Eingabeformat-Builder hinzu (Text, Zahl, Boolean, JSON usw.). Für jedes Feld:
|
||||
|
||||
- Der Wert erscheint als `<blockName.field>` im Workflow.
|
||||
- Die vollständige Nutzlast wird zur Vereinfachung unter `<blockName.input>` gespiegelt.
|
||||
|
||||
Wenn Sie das Formular leer lassen, hat der Trigger keine Ausgaben.
|
||||
|
||||
## Manuelle Ausführungen
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/input-form-panel-light.png'
|
||||
alt='Eingabeformular-Ausführungspanel'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
Wenn Sie im Editor auf Ausführen drücken, rendert das Panel das Formular. Übermittelte Werte fließen direkt in die Trigger-Ausgabe ein, sodass nachgelagerte Blöcke darauf verweisen können, ohne zusätzliches Parsing. Zahlen werden in Zahlentypen umgewandelt, Booleans werden zu true/false, und JSON-Felder werden geparst, bevor der Workflow sie verarbeitet.
|
||||
|
||||
## Untergeordnete Workflows
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/workflow-input-mapping-light.png'
|
||||
alt='Workflow-Eingabezuordnung'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
Eingabeformular-Trigger steuern auch den Workflow-Block. Wenn Sie einen untergeordneten Workflow einbetten, zeigt der Zuordnungsschritt die Formularfelder des untergeordneten Workflows an, sodass Sie Variablen aus dem übergeordneten Workflow verbinden können. Was auch immer Sie zuordnen, wird zur Eingabeformular-Übermittlung des untergeordneten Workflows.
|
||||
|
||||
<Callout>
|
||||
Benötigen Sie eine schnelle Ausführungsschaltfläche ohne Felder? Verwenden Sie einen manuellen Trigger. Wählen Sie Eingabeformular, wenn Sie Validierung und eine vorhersehbare Struktur wünschen.
|
||||
</Callout>
|
||||
@@ -1,41 +0,0 @@
|
||||
---
|
||||
title: Manueller Auslöser
|
||||
description: Führen Sie einen Workflow auf Anforderung ohne Eingaben aus
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Übersicht
|
||||
|
||||
Der manuelle Auslöser fügt einen einfachen Ausführen-Button am Anfang Ihres Workflows hinzu. Verwenden Sie ihn, wenn Sie den Workflow sofort ausführen möchten, ohne zusätzliche Daten zu sammeln.
|
||||
|
||||
## Funktionsweise
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/manual-run-light.png'
|
||||
alt='Ausführen-Button für manuellen Auslöser'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
- Startet den Workflow mit dem aktiven Deployment-Snapshot
|
||||
- Sendet keine Nutzlast – nachgelagerte Blöcke sehen nur, was sie bereits konfiguriert haben
|
||||
- Perfekt für schnelle Plausibilitätsprüfungen, Smoke-Tests oder Abläufe, die nur auf internen Variablen basieren
|
||||
|
||||
## Anwendungsfälle
|
||||
|
||||
- Starten Sie einen Workflow nach der Veröffentlichung eines neuen Deployments, um zu bestätigen, dass alles noch funktioniert
|
||||
- Führen Sie Wartungsaufgaben aus, die keine externe Eingabe erfordern
|
||||
- Lösen Sie untergeordnete Workflows aus, die nur Status- oder Umgebungsvariablen lesen
|
||||
|
||||
## Vergleich mit Eingabeformular
|
||||
|
||||
Benötigen Sie strukturierte Werte oder Typvalidierung zur Laufzeit? Wechseln Sie stattdessen zu einem Eingabeformular-Auslöser – das Ausführungspanel sammelt diese Felder, bevor der Workflow startet.
|
||||
|
||||
<Callout>
|
||||
Manuelle Auslöser-Ausführungen überschreiben nicht Ihren Deployment-Verlauf. Aktualisieren und stellen Sie neu bereit, wenn Canvas-Änderungen live gehen sollen.
|
||||
</Callout>
|
||||
97
apps/docs/content/docs/de/triggers/start.mdx
Normal file
97
apps/docs/content/docs/de/triggers/start.mdx
Normal file
@@ -0,0 +1,97 @@
|
||||
---
|
||||
title: Start
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Tab, Tabs } from 'fumadocs-ui/components/tabs'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
Der Start-Block ist der Standard-Auslöser für Workflows, die in Sim erstellt werden. Er sammelt strukturierte Eingaben und verteilt sie an den Rest deines Graphen für Editor-Tests, API-Bereitstellungen und Chat-Erlebnisse.
|
||||
|
||||
<div className="flex justify-center">
|
||||
<Image
|
||||
src="/static/start.png"
|
||||
alt="Start-Block mit Eingabeformat-Feldern"
|
||||
width={360}
|
||||
height={380}
|
||||
className="my-6"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Callout type="info">
|
||||
Der Start-Block befindet sich in der Startposition, wenn du einen Workflow erstellst. Behalte ihn dort, wenn du denselben Einstiegspunkt für Editor-Ausführungen, Deploy-to-API-Anfragen und Chat-Sitzungen verwenden möchtest. Tausche ihn mit Webhook- oder Schedule-Triggern aus, wenn du nur ereignisgesteuerte Ausführung benötigst.
|
||||
</Callout>
|
||||
|
||||
## Von Start bereitgestellte Felder
|
||||
|
||||
Der Start-Block gibt je nach Ausführungsumgebung unterschiedliche Daten aus:
|
||||
|
||||
- **Eingabeformat-Felder** — Jedes Feld, das du hinzufügst, wird als <code><start.fieldName></code> verfügbar. Zum Beispiel erscheint ein `customerId`Feld als <code><start.customerId></code> in nachgelagerten Blöcken und Vorlagen.
|
||||
- **Nur-Chat-Felder** — Wenn der Workflow über das Chat-Seitenfeld oder ein bereitgestelltes Chat-Erlebnis ausgeführt wird, stellt Sim auch <code><start.input></code> (neueste Benutzernachricht), <code><start.conversationId></code> (aktive Sitzungs-ID) und <code><start.files></code> (Chat-Anhänge) bereit.
|
||||
|
||||
Halte die Eingabeformat-Felder auf die Namen beschränkt, auf die du später verweisen möchtest – diese Werte sind die einzigen strukturierten Felder, die über Editor-, API- und Chat-Ausführungen hinweg geteilt werden.
|
||||
|
||||
## Konfiguriere das Eingabeformat
|
||||
|
||||
Verwende den Eingabeformat-Unterblock, um das Schema zu definieren, das für alle Ausführungsmodi gilt:
|
||||
|
||||
1. Füge ein Feld für jeden Wert hinzu, den du sammeln möchtest.
|
||||
2. Wähle einen Typ (`string`, `number`, `boolean`, `object`, `array` oder `files`). Dateifelder akzeptieren Uploads von Chat- und API-Aufrufern.
|
||||
3. Gib Standardwerte an, wenn du möchtest, dass das manuelle Ausführungsmodal automatisch Testdaten einfügt. Diese Standardwerte werden für bereitgestellte Ausführungen ignoriert.
|
||||
4. Ordne Felder neu an, um zu steuern, wie sie im Editor-Formular erscheinen.
|
||||
|
||||
Referenzieren Sie strukturierte Werte nachgelagert mit Ausdrücken wie <code><start.customerId></code> abhängig vom Block, den Sie verbinden.
|
||||
|
||||
## Wie es sich je nach Einstiegspunkt verhält
|
||||
|
||||
<Tabs items={['Editor-Ausführung', 'Bereitstellung als API', 'Bereitstellung für Chat']}>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
Wenn Sie im Editor auf <strong>Ausführen</strong> klicken, rendert der Start-Block das Eingabeformat als Formular. Standardwerte erleichtern das erneute Testen ohne erneute Dateneingabe. Durch das Absenden des Formulars wird der Workflow sofort ausgelöst und die Werte werden unter <code><start.feldName></code> (zum Beispiel <code><start.sampleField></code>) verfügbar.
|
||||
</p>
|
||||
<p>
|
||||
Dateifelder im Formular werden direkt in die entsprechenden{' '}
|
||||
<code><start.fieldName></code> hochgeladen; verwenden Sie diese Werte,
|
||||
um nachgelagerte Tools oder Speicherschritte zu versorgen.
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
Die Bereitstellung als API verwandelt das Eingabeformat in einen JSON-Vertrag für Clients. Jedes Feld wird Teil des Anforderungskörpers, und Sim erzwingt primitive Typen bei der Aufnahme. Dateifelder erwarten Objekte, die auf hochgeladene Dateien verweisen; verwenden Sie den Ausführungs-Datei-Upload-Endpunkt, bevor Sie den Workflow aufrufen.
|
||||
</p>
|
||||
<p>
|
||||
API-Aufrufer können zusätzliche optionale Eigenschaften einbeziehen. Diese
|
||||
werden in den <code><start.fieldName></code>Ausgaben beibehalten, sodass
|
||||
Sie experimentieren können, ohne sofort neu bereitzustellen.
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
Bei Chat-Bereitstellungen bindet sich der Start-Block an die aktive Konversation. Die neueste Nachricht füllt <code><start.input></code>, die Sitzungskennung ist unter <code><start.conversationId></code> verfügbar, und Benutzeranhänge erscheinen unter <code><start.files></code>, zusammen mit allen Eingabeformatfeldern, die als <code><start.fieldName></code> definiert sind.
|
||||
</p>
|
||||
<p>
|
||||
Wenn Sie den Chat mit zusätzlichem strukturiertem Kontext starten (zum
|
||||
Beispiel aus einer Einbettung), wird dieser mit den entsprechenden{' '}
|
||||
<code><start.fieldName></code>Ausgaben zusammengeführt, wodurch
|
||||
nachgelagerte Blöcke konsistent mit API- und manuellen Ausführungen bleiben.
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## Referenzierung von Start-Daten in nachgelagerten Komponenten
|
||||
|
||||
- Verbinde <code><start.fieldName></code> direkt mit Agenten, Tools oder Funktionen, die strukturierte Daten erwarten.
|
||||
- Verwende Template-Syntax wie <code><start.sampleField></code> oder <code><start.files[0].url></code> (nur für Chat) in Prompt-Feldern.
|
||||
- Halte <code><start.conversationId></code> bereit, wenn du Ausgaben gruppieren, den Gesprächsverlauf aktualisieren oder die Chat-API erneut aufrufen musst.
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Behandle den Start-Block als einzigen Einstiegspunkt, wenn du sowohl API- als auch Chat-Aufrufer unterstützen möchtest.
|
||||
- Bevorzuge benannte Eingabeformat-Felder gegenüber dem Parsen von rohem JSON in nachgelagerten Knoten; Typumwandlung erfolgt automatisch.
|
||||
- Füge unmittelbar nach dem Start Validierung oder Routing hinzu, wenn bestimmte Felder für den Erfolg deines Workflows erforderlich sind.
|
||||
@@ -1,67 +0,0 @@
|
||||
---
|
||||
title: Starter (Veraltet)
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Tab, Tabs } from 'fumadocs-ui/components/tabs'
|
||||
import { Image } from '@/components/ui/image'
|
||||
import { Video } from '@/components/ui/video'
|
||||
|
||||
<Callout type="warning">
|
||||
Der Starter-Block ist veraltet und wurde durch spezialisierte Core-Trigger ersetzt. Bitte beachten Sie die [Core-Trigger-Dokumentation](/triggers) für die neuen API-, Chat-, Eingabeformular-, Manuell-, Zeitplan- und Webhook-Trigger.
|
||||
</Callout>
|
||||
|
||||
Der Starter-Block ermöglicht es Ihnen, die Workflow-Ausführung manuell mit Eingabeparametern zu starten und bietet zwei Eingabemodi: strukturierte Parameter oder konversationellen Chat.
|
||||
|
||||
<div className="flex justify-center">
|
||||
<Image
|
||||
src="/static/starter.png"
|
||||
alt="Starter-Block mit manuellen und Chat-Modus-Optionen"
|
||||
width={500}
|
||||
height={400}
|
||||
className="my-6"
|
||||
/>
|
||||
</div>
|
||||
|
||||
## Ausführungsmodi
|
||||
|
||||
Wählen Sie Ihre Eingabemethode aus dem Dropdown-Menü:
|
||||
|
||||
<Tabs items={['Manueller Modus', 'Chat-Modus']}>
|
||||
<Tab>
|
||||
<div className="space-y-4">
|
||||
<ul className="list-disc space-y-1 pl-6">
|
||||
<li><strong>API-freundliche strukturierte Eingaben</strong>: Definieren Sie spezifische Parameter (Text, Zahl, Boolean, JSON, Datei, Datum)</li>
|
||||
<li><strong>Testen während der Workflow-Erstellung</strong>: Schnelle Iteration beim Debuggen von Workflows</li>
|
||||
</ul>
|
||||
|
||||
<div className="mx-auto w-full overflow-hidden rounded-lg">
|
||||
<Video src="input-format.mp4" width={700} height={450} />
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-gray-600">Konfigurieren Sie Eingabeparameter, die beim Bereitstellen als API-Endpunkt verfügbar sein werden.</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-4">
|
||||
<ul className="list-disc space-y-1 pl-6">
|
||||
<li><strong>Natürliche Sprache</strong>: Benutzer geben Fragen oder Anfragen ein</li>
|
||||
<li><strong>Konversationell</strong>: Ideal für KI-gestützte Workflows</li>
|
||||
</ul>
|
||||
|
||||
<div className="mx-auto w-full overflow-hidden rounded-lg">
|
||||
<Video src="chat-input.mp4" width={700} height={450} />
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-gray-600">Chatten Sie mit Ihrem Workflow und greifen Sie auf Eingabetext, Konversations-ID und hochgeladene Dateien für kontextbezogene Antworten zu.</p>
|
||||
</div>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## Verwendung von Chat-Variablen
|
||||
|
||||
Im Chat-Modus können Sie über spezielle Variablen auf Benutzereingaben und Konversationskontext zugreifen:
|
||||
|
||||
- **`<start.input>`** - Enthält den Nachrichtentext des Benutzers
|
||||
- **`<start.conversationId>`** - Eindeutige Kennung für den Konversationsverlauf
|
||||
- **`<start.files>`** - Array von Dateien, die vom Benutzer hochgeladen wurden (falls vorhanden)
|
||||
@@ -1,357 +0,0 @@
|
||||
---
|
||||
title: Loop Block YAML Schema
|
||||
description: YAML-Konfigurationsreferenz für Loop-Blöcke
|
||||
---
|
||||
|
||||
## Schema-Definition
|
||||
|
||||
```yaml
|
||||
type: object
|
||||
required:
|
||||
- type
|
||||
- name
|
||||
- connections
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
enum: [loop]
|
||||
description: Block type identifier
|
||||
name:
|
||||
type: string
|
||||
description: Display name for this loop block
|
||||
inputs:
|
||||
type: object
|
||||
description: Optional. If omitted, defaults will be applied.
|
||||
properties:
|
||||
loopType:
|
||||
type: string
|
||||
enum: [for, forEach]
|
||||
description: Type of loop to execute
|
||||
default: for
|
||||
iterations:
|
||||
type: number
|
||||
description: Number of iterations (for 'for' loops)
|
||||
default: 5
|
||||
minimum: 1
|
||||
maximum: 1000
|
||||
collection:
|
||||
type: string
|
||||
description: Collection to iterate over (for 'forEach' loops)
|
||||
default: ""
|
||||
maxConcurrency:
|
||||
type: number
|
||||
description: Maximum concurrent executions
|
||||
default: 1
|
||||
minimum: 1
|
||||
maximum: 10
|
||||
connections:
|
||||
type: object
|
||||
properties:
|
||||
# Nested format (recommended)
|
||||
loop:
|
||||
type: object
|
||||
properties:
|
||||
start:
|
||||
type: string
|
||||
description: Target block ID to execute inside the loop
|
||||
end:
|
||||
type: string
|
||||
description: Target block ID for loop completion (optional)
|
||||
# Direct handle format (alternative)
|
||||
loop-start-source:
|
||||
type: string | string[]
|
||||
description: Target block ID to execute inside the loop (direct format)
|
||||
loop-end-source:
|
||||
type: string | string[]
|
||||
description: Target block ID for loop completion (direct format, optional)
|
||||
error:
|
||||
type: string
|
||||
description: Target block ID for error handling
|
||||
note: Use either the nested 'loop' format OR the direct 'loop-start-source' format, not both
|
||||
```
|
||||
|
||||
## Verbindungskonfiguration
|
||||
|
||||
Loop-Blöcke unterstützen zwei Verbindungsformate:
|
||||
|
||||
### Direktes Handle-Format (Alternative)
|
||||
|
||||
```yaml
|
||||
connections:
|
||||
loop-start-source: <string> # Target block ID to execute inside the loop
|
||||
loop-end-source: <string> # Target block ID after loop completion (optional)
|
||||
error: <string> # Target block ID for error handling (optional)
|
||||
```
|
||||
|
||||
Beide Formate funktionieren identisch. Verwenden Sie das Format, das Ihnen besser gefällt.
|
||||
|
||||
## Konfiguration von untergeordneten Blöcken
|
||||
|
||||
Blöcke innerhalb einer Schleife müssen ihre `parentId` auf die Loop-Block-ID gesetzt haben. Die Eigenschaft `extent` wird automatisch auf `'parent'` gesetzt und muss nicht angegeben werden:
|
||||
|
||||
```yaml
|
||||
loop-1:
|
||||
type: loop
|
||||
name: "Process Items"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.items>
|
||||
connections:
|
||||
loop:
|
||||
start: process-item
|
||||
end: final-results
|
||||
|
||||
# Child block inside the loop
|
||||
process-item:
|
||||
type: agent
|
||||
name: "Process Item"
|
||||
parentId: loop-1 # References the loop block
|
||||
inputs:
|
||||
systemPrompt: "Process this item"
|
||||
userPrompt: <loop.currentItem>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
## Beispiele
|
||||
|
||||
### For-Schleife (feste Anzahl von Iterationen)
|
||||
|
||||
```yaml
|
||||
countdown-loop:
|
||||
type: loop
|
||||
name: "Countdown Loop"
|
||||
inputs:
|
||||
loopType: for
|
||||
iterations: 5
|
||||
connections:
|
||||
loop:
|
||||
start: countdown-agent
|
||||
end: countdown-complete
|
||||
|
||||
countdown-agent:
|
||||
type: agent
|
||||
name: "Countdown Agent"
|
||||
parentId: countdown-loop
|
||||
inputs:
|
||||
systemPrompt: "Generate a countdown message"
|
||||
userPrompt: "Count down from 5. Current number: <loop.index>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### ForEach-Schleife (Verarbeitung von Sammlungen)
|
||||
|
||||
```yaml
|
||||
email-processor-loop:
|
||||
type: loop
|
||||
name: "Email Processor Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.emails>
|
||||
connections:
|
||||
loop:
|
||||
start: process-single-email
|
||||
end: all-emails-processed
|
||||
|
||||
process-single-email:
|
||||
type: agent
|
||||
name: "Process Single Email"
|
||||
parentId: email-processor-loop
|
||||
inputs:
|
||||
systemPrompt: "Classify and respond to this email"
|
||||
userPrompt: "Email content: <loop.currentItem>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### Schleife mit mehreren untergeordneten Blöcken
|
||||
|
||||
```yaml
|
||||
data-analysis-loop:
|
||||
type: loop
|
||||
name: "Data Analysis Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <data-fetcher.records>
|
||||
maxConcurrency: 3
|
||||
connections:
|
||||
loop:
|
||||
start: validate-record
|
||||
end: generate-report
|
||||
error: handle-loop-error
|
||||
|
||||
validate-record:
|
||||
type: function
|
||||
name: "Validate Record"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
code: |
|
||||
const record = <loop.currentItem>;
|
||||
const index = <loop.index>;
|
||||
|
||||
// Validate the record
|
||||
if (!record.id || !record.data) {
|
||||
throw new Error(`Invalid record at index ${index}`);
|
||||
}
|
||||
|
||||
return {
|
||||
valid: true,
|
||||
recordId: record.id,
|
||||
processedAt: new Date().toISOString()
|
||||
};
|
||||
connections:
|
||||
success: analyze-record
|
||||
error: record-error
|
||||
|
||||
analyze-record:
|
||||
type: agent
|
||||
name: "Analyze Record"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
systemPrompt: "Analyze this data record and extract insights"
|
||||
userPrompt: |
|
||||
Record ID: <validaterecord.recordId>
|
||||
Data: <loop.currentItem.data>
|
||||
Position in collection: <loop.index>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
connections:
|
||||
success: store-analysis
|
||||
|
||||
store-analysis:
|
||||
type: function
|
||||
name: "Store Analysis"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
code: |
|
||||
const analysis = <analyzerecord.content>;
|
||||
const recordId = <validaterecord.recordId>;
|
||||
|
||||
// Store analysis result
|
||||
return {
|
||||
recordId,
|
||||
analysis,
|
||||
completedAt: new Date().toISOString()
|
||||
};
|
||||
```
|
||||
|
||||
### Schleife für parallele Verarbeitung
|
||||
|
||||
```yaml
|
||||
parallel-processing-loop:
|
||||
type: loop
|
||||
name: "Parallel Processing Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.tasks>
|
||||
maxConcurrency: 5
|
||||
connections:
|
||||
loop:
|
||||
start: process-task
|
||||
end: aggregate-results
|
||||
|
||||
process-task:
|
||||
type: api
|
||||
name: "Process Task"
|
||||
parentId: parallel-processing-loop
|
||||
inputs:
|
||||
url: "https://api.example.com/process"
|
||||
method: POST
|
||||
headers:
|
||||
- key: "Authorization"
|
||||
value: "Bearer {{API_TOKEN}}"
|
||||
body: |
|
||||
{
|
||||
"taskId": "<loop.currentItem.id>",
|
||||
"data": "<loop.currentItem.data>"
|
||||
}
|
||||
connections:
|
||||
success: task-completed
|
||||
```
|
||||
|
||||
### Beispiel für direktes Handle-Format
|
||||
|
||||
Dieselbe Schleife kann mit dem direkten Handle-Format geschrieben werden:
|
||||
|
||||
```yaml
|
||||
my-loop:
|
||||
type: loop
|
||||
name: "Process Items"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.items>
|
||||
connections:
|
||||
loop-start-source: process-item # Direct handle format
|
||||
loop-end-source: final-results # Direct handle format
|
||||
error: handle-error
|
||||
|
||||
process-item:
|
||||
type: agent
|
||||
name: "Process Item"
|
||||
parentId: my-loop
|
||||
inputs:
|
||||
systemPrompt: "Process this item"
|
||||
userPrompt: <loop.currentItem>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### Minimales Schleifenbeispiel (mit Standardwerten)
|
||||
|
||||
Sie können den Abschnitt `inputs` vollständig weglassen, dann werden Standardwerte angewendet:
|
||||
|
||||
```yaml
|
||||
simple-loop:
|
||||
type: loop
|
||||
name: "Simple Loop"
|
||||
# No inputs section - defaults to loopType: 'for', iterations: 5
|
||||
connections:
|
||||
loop-start-source: process-step
|
||||
loop-end-source: complete
|
||||
|
||||
process-step:
|
||||
type: agent
|
||||
name: "Process Step"
|
||||
parentId: simple-loop
|
||||
inputs:
|
||||
systemPrompt: "Execute step"
|
||||
userPrompt: "Step <loop.index>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
Diese Schleife führt standardmäßig 5 Iterationen aus.
|
||||
|
||||
## Schleifenvariablen
|
||||
|
||||
Innerhalb von Schleifenunterblöcken sind diese speziellen Variablen verfügbar:
|
||||
|
||||
```yaml
|
||||
# Available in all child blocks of the loop
|
||||
<loop.index> # Current iteration number (0-based)
|
||||
<loop.currentItem> # Current item being processed (forEach loops)
|
||||
<loop.items> # Full collection (forEach loops)
|
||||
```
|
||||
|
||||
## Ausgabereferenzen
|
||||
|
||||
Nach Abschluss einer Schleife können Sie auf ihre aggregierten Ergebnisse verweisen:
|
||||
|
||||
```yaml
|
||||
# In blocks after the loop
|
||||
final-processor:
|
||||
inputs:
|
||||
all-results: <loop-name.results> # Array of all iteration results
|
||||
total-count: <loop-name.count> # Number of iterations completed
|
||||
```
|
||||
|
||||
## Bewährte Praktiken
|
||||
|
||||
- Setzen Sie angemessene Iterationsgrenzen, um lange Ausführungszeiten zu vermeiden
|
||||
- Verwenden Sie forEach für die Verarbeitung von Sammlungen, for-Schleifen für feste Iterationen
|
||||
- Erwägen Sie die Verwendung von maxConcurrency für I/O-gebundene Operationen
|
||||
- Integrieren Sie Fehlerbehandlung für eine robuste Schleifenausführung
|
||||
- Verwenden Sie aussagekräftige Namen für Schleifenunterblöcke
|
||||
- Testen Sie zuerst mit kleinen Sammlungen
|
||||
- Überwachen Sie die Ausführungszeit für große Sammlungen
|
||||
@@ -1,185 +0,0 @@
|
||||
---
|
||||
title: API Trigger
|
||||
description: Start a workflow from an authenticated HTTP request
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Overview
|
||||
|
||||
The API trigger exposes your workflow as a secure HTTP endpoint. Send JSON data to the endpoint and your workflow processes it immediately. API calls always execute against your latest deployment.
|
||||
|
||||
## Configure Input Format
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/api-trigger-light.png'
|
||||
alt='API trigger input format'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
Add an **Input Format** field for each parameter. Supported types:
|
||||
|
||||
- **string** - Text values
|
||||
- **number** - Numeric values
|
||||
- **boolean** - True/false values
|
||||
- **json** - JSON objects
|
||||
- **files** - File uploads (access via `<api.fieldName[0].url>`, `<api.fieldName[0].name>`, etc.)
|
||||
|
||||
Runtime output keys mirror the schema and are available under `<api.input>`.
|
||||
|
||||
Manual runs in the editor use the `value` column so you can test without sending a request. During execution the resolver populates both `<api.fieldName>` and `<api.input.fieldName>`.
|
||||
|
||||
## Request Example
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{"userId":"demo-user","maxTokens":1024}'
|
||||
```
|
||||
|
||||
Successful responses return the serialized execution result from the Executor. Errors surface validation, auth, or workflow failures.
|
||||
|
||||
## Streaming Responses
|
||||
|
||||
Enable real-time streaming to receive workflow output as it's generated, character-by-character. This is useful for displaying AI responses progressively to users.
|
||||
|
||||
### Request Parameters
|
||||
|
||||
Add these parameters to enable streaming:
|
||||
|
||||
- `stream` - Set to `true` to enable Server-Sent Events (SSE) streaming
|
||||
- `selectedOutputs` - Array of block outputs to stream (e.g., `["agent1.content"]`)
|
||||
|
||||
### Block Output Format
|
||||
|
||||
Use the `blockName.attribute` format to specify which block outputs to stream:
|
||||
- Format: `"blockName.attribute"` (e.g., If you want to stream the content of the Agent 1 block, you would use `"agent1.content"`)
|
||||
- Block names are case-insensitive and spaces are ignored
|
||||
|
||||
### Example Request
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{
|
||||
"message": "Count to five",
|
||||
"stream": true,
|
||||
"selectedOutputs": ["agent1.content"]
|
||||
}'
|
||||
```
|
||||
|
||||
### Response Format
|
||||
|
||||
Streaming responses use Server-Sent Events (SSE) format:
|
||||
|
||||
```
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"}
|
||||
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"}
|
||||
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", three"}
|
||||
|
||||
data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}}
|
||||
|
||||
data: [DONE]
|
||||
```
|
||||
|
||||
Each event includes:
|
||||
- **Streaming chunks**: `{"blockId": "...", "chunk": "text"}` - Real-time text as it's generated
|
||||
- **Final event**: `{"event": "done", ...}` - Execution metadata and complete results
|
||||
- **Terminator**: `[DONE]` - Signals end of stream
|
||||
|
||||
### Multiple Block Streaming
|
||||
|
||||
When `selectedOutputs` includes multiple blocks, each chunk indicates which block produced it:
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{
|
||||
"message": "Process this request",
|
||||
"stream": true,
|
||||
"selectedOutputs": ["agent1.content", "agent2.content"]
|
||||
}'
|
||||
```
|
||||
|
||||
The `blockId` field in each chunk lets you route output to the correct UI element:
|
||||
|
||||
```
|
||||
data: {"blockId":"agent1-uuid","chunk":"Processing..."}
|
||||
|
||||
data: {"blockId":"agent2-uuid","chunk":"Analyzing..."}
|
||||
|
||||
data: {"blockId":"agent1-uuid","chunk":" complete"}
|
||||
```
|
||||
|
||||
## Output Reference
|
||||
|
||||
| Reference | Description |
|
||||
|-----------|-------------|
|
||||
| `<api.field>` | Field defined in the Input Format |
|
||||
| `<api.input>` | Entire structured request body |
|
||||
|
||||
### File Upload Format
|
||||
|
||||
The API accepts files in two formats:
|
||||
|
||||
**1. Base64-encoded files** (recommended for SDKs):
|
||||
```json
|
||||
{
|
||||
"documents": [{
|
||||
"type": "file",
|
||||
"data": "data:application/pdf;base64,JVBERi0xLjQK...",
|
||||
"name": "document.pdf",
|
||||
"mime": "application/pdf"
|
||||
}]
|
||||
}
|
||||
```
|
||||
- Maximum file size: 20MB per file
|
||||
- Files are uploaded to cloud storage and converted to UserFile objects with all properties
|
||||
|
||||
**2. Direct URL references**:
|
||||
```json
|
||||
{
|
||||
"documents": [{
|
||||
"type": "url",
|
||||
"data": "https://example.com/document.pdf",
|
||||
"name": "document.pdf",
|
||||
"mime": "application/pdf"
|
||||
}]
|
||||
}
|
||||
```
|
||||
- File is not uploaded, URL is passed through directly
|
||||
- Useful for referencing existing files
|
||||
|
||||
### File Properties
|
||||
|
||||
For files, access all properties:
|
||||
|
||||
| Property | Description | Type |
|
||||
|----------|-------------|------|
|
||||
| `<api.fieldName[0].url>` | Signed download URL | string |
|
||||
| `<api.fieldName[0].name>` | Original filename | string |
|
||||
| `<api.fieldName[0].size>` | File size in bytes | number |
|
||||
| `<api.fieldName[0].type>` | MIME type | string |
|
||||
| `<api.fieldName[0].uploadedAt>` | Upload timestamp (ISO 8601) | string |
|
||||
| `<api.fieldName[0].expiresAt>` | URL expiry timestamp (ISO 8601) | string |
|
||||
|
||||
For URL-referenced files, the same properties are available except `uploadedAt` and `expiresAt` since the file is not uploaded to our storage.
|
||||
|
||||
If no Input Format is defined, the executor exposes the raw JSON at `<api.input>` only.
|
||||
|
||||
<Callout type="warning">
|
||||
A workflow can contain only one API Trigger. Publish a new deployment after changes so the endpoint stays up to date.
|
||||
</Callout>
|
||||
@@ -1,54 +0,0 @@
|
||||
---
|
||||
title: Chat Trigger
|
||||
description: Start a workflow from a chat deployment
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Overview
|
||||
|
||||
The Chat trigger creates a conversational interface for your workflow. Deploy your workflow as a chat and users can interact with it through a shareable URL. Each message starts a new workflow execution using your latest deployment.
|
||||
|
||||
## Runtime Outputs
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/chat-trigger-light.png'
|
||||
alt='Chat deployment conversation'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
The trigger writes three fields that downstream blocks can reference:
|
||||
|
||||
| Reference | Description | Type |
|
||||
|-----------|-------------|------|
|
||||
| `<chat.input>` | Latest user message | string |
|
||||
| `<chat.conversationId>` | Conversation thread ID | string |
|
||||
| `<chat.files>` | Optional uploaded files | files array |
|
||||
|
||||
### File Properties
|
||||
|
||||
Access individual file properties using array indexing:
|
||||
|
||||
| Property | Description | Type |
|
||||
|----------|-------------|------|
|
||||
| `<chat.files[0].url>` | Signed download URL | string |
|
||||
| `<chat.files[0].name>` | Original filename | string |
|
||||
| `<chat.files[0].size>` | File size in bytes | number |
|
||||
| `<chat.files[0].type>` | MIME type | string |
|
||||
| `<chat.files[0].uploadedAt>` | Upload timestamp (ISO 8601) | string |
|
||||
| `<chat.files[0].expiresAt>` | URL expiry timestamp (ISO 8601) | string |
|
||||
|
||||
## Usage Notes
|
||||
|
||||
1. Add one Chat Trigger block per workflow.
|
||||
2. Deploy the workflow in chat mode.
|
||||
3. Share the deployment link—every reply reuses the conversation ID so the workflow can keep context.
|
||||
|
||||
<Callout type="info">
|
||||
The builder blocks multiple Chat Trigger blocks in the same workflow.
|
||||
</Callout>
|
||||
@@ -1,52 +0,0 @@
|
||||
---
|
||||
title: Input Form Trigger
|
||||
description: Manual trigger with a structured input schema
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Overview
|
||||
|
||||
Use an Input Form trigger when a workflow should start from the editor with typed fields. The run panel shows exactly the fields you define, so the workflow always receives clean data.
|
||||
|
||||
## What You Define
|
||||
|
||||
Add fields in the Input Format builder (text, number, boolean, JSON, etc.). For each field:
|
||||
|
||||
- The value appears as `<blockName.field>` in the workflow.
|
||||
- The full payload is mirrored at `<blockName.input>` for convenience.
|
||||
|
||||
If you leave the form empty, the trigger has no outputs.
|
||||
|
||||
## Manual Runs
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/input-form-panel-light.png'
|
||||
alt='Input form run panel'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
When you press Run in the editor, the panel renders the form. Submitted values feed directly into the trigger output, so downstream blocks can reference them without extra parsing. Numbers are cast to numbers, booleans become true/false, and JSON fields are parsed before the workflow sees them.
|
||||
|
||||
## Child Workflows
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/workflow-input-mapping-light.png'
|
||||
alt='Workflow input mapping'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
Input Form triggers also power the Workflow block. When you embed a child workflow, the mapping step shows the child form fields so you can connect variables from the parent. Whatever you map becomes the child workflow’s Input Form submission.
|
||||
|
||||
<Callout>
|
||||
Need a quick run button with no fields? Drop a Manual Trigger. Choose Input Form when you want validation and predictable structure.
|
||||
</Callout>
|
||||
@@ -1,41 +0,0 @@
|
||||
---
|
||||
title: Manual Trigger
|
||||
description: Run a workflow on demand without inputs
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Overview
|
||||
|
||||
The Manual trigger adds a simple Run button to the top of your workflow. Use it when you want to execute the workflow immediately without collecting extra data.
|
||||
|
||||
## How It Works
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/manual-run-light.png'
|
||||
alt='Manual trigger run button'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
- Launches the workflow using the active deployment snapshot
|
||||
- Sends no payload—downstream blocks only see what they already have configured
|
||||
- Perfect for quick sanity checks, smoke tests, or flows that only rely on internal variables
|
||||
|
||||
## When to Use
|
||||
|
||||
- Kick off a workflow after publishing a new deployment to confirm everything still works
|
||||
- Run maintenance jobs that don’t require external input
|
||||
- Trigger child workflows that read state or environment variables only
|
||||
|
||||
## Compared to Input Form
|
||||
|
||||
Need structured values or type validation at runtime? Switch to an Input Form trigger instead—the run panel will collect those fields before the workflow starts.
|
||||
|
||||
<Callout>
|
||||
Manual trigger runs don’t override your deployment history. Update and redeploy whenever canvas changes need to go live.
|
||||
</Callout>
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"pages": ["index", "start", "schedule", "webhook", "starter"]
|
||||
"pages": ["index", "start", "schedule", "webhook"]
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ The Start block sits in the start slot when you create a workflow. Keep it there
|
||||
|
||||
The Start block emits different data depending on the execution surface:
|
||||
|
||||
- **Input Format fields** — Every field you add becomes available as `<start.fieldName>`. For example, a `customerId` field shows up as `<start.customerId>` in downstream blocks and templates.
|
||||
- **Chat-only fields** — When the workflow runs from the chat side panel or a deployed chat experience, Sim also provides `<start.input>` (latest user message), `<start.conversationId>` (active session id), and `<start.files>` (chat attachments).
|
||||
- **Input Format fields** — Every field you add becomes available as <code><start.fieldName></code>. For example, a `customerId` field shows up as <code><start.customerId></code> in downstream blocks and templates.
|
||||
- **Chat-only fields** — When the workflow runs from the chat side panel or a deployed chat experience, Sim also provides <code><start.input></code> (latest user message), <code><start.conversationId></code> (active session id), and <code><start.files></code> (chat attachments).
|
||||
|
||||
Keep Input Format fields scoped to the names you expect to reference later—those values are the only structured fields shared across editor, API, and chat runs.
|
||||
|
||||
@@ -40,7 +40,7 @@ Use the Input Format sub-block to define the schema that applies across executio
|
||||
3. Provide default values when you want the manual run modal to populate test data automatically. These defaults are ignored for deployed executions.
|
||||
4. Reorder fields to control how they appear in the editor form.
|
||||
|
||||
Reference structured values downstream with expressions such as `<start.customerId>` depending on the block you connect.
|
||||
Reference structured values downstream with expressions such as <code><start.customerId></code> depending on the block you connect.
|
||||
|
||||
## How it behaves per entry point
|
||||
|
||||
@@ -51,7 +51,9 @@ Reference structured values downstream with expressions such as `<start.customer
|
||||
When you click <strong>Run</strong> in the editor, the Start block renders the Input Format as a form. Default values make it easy to retest without retyping data. Submitting the form triggers the workflow immediately and the values become available on <code><start.fieldName></code> (for example <code><start.sampleField></code>).
|
||||
</p>
|
||||
<p>
|
||||
File fields in the form upload directly into the corresponding `<start.fieldName>`; use those values to feed downstream tools or storage steps.
|
||||
File fields in the form upload directly into the corresponding{' '}
|
||||
<code><start.fieldName></code>; use those values to feed downstream
|
||||
tools or storage steps.
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
@@ -61,7 +63,9 @@ Reference structured values downstream with expressions such as `<start.customer
|
||||
Deploying to API turns the Input Format into a JSON contract for clients. Each field becomes part of the request body, and Sim coerces primitive types on ingestion. File fields expect objects that reference uploaded files; use the execution file upload endpoint before invoking the workflow.
|
||||
</p>
|
||||
<p>
|
||||
API callers can include additional optional properties. They are preserved inside `<start.fieldName>` outputs so you can experiment without redeploying immediately.
|
||||
API callers can include additional optional properties. They are preserved
|
||||
inside <code><start.fieldName></code> outputs so you can experiment
|
||||
without redeploying immediately.
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
@@ -71,7 +75,7 @@ Reference structured values downstream with expressions such as `<start.customer
|
||||
In chat deployments the Start block binds to the active conversation. The latest message fills <code><start.input></code>, the session identifier is available at <code><start.conversationId></code>, and user attachments appear on <code><start.files></code>, alongside any Input Format fields scoped as <code><start.fieldName></code>.
|
||||
</p>
|
||||
<p>
|
||||
If you launch chat with additional structured context (for example from an embed), it merges into the corresponding `<start.fieldName>` outputs, keeping downstream blocks consistent with API and manual runs.
|
||||
If you launch chat with additional structured context (for example from an embed), it merges into the corresponding <code><start.fieldName></code> outputs, keeping downstream blocks consistent with API and manual runs.
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
@@ -79,9 +83,9 @@ Reference structured values downstream with expressions such as `<start.customer
|
||||
|
||||
## Referencing Start data downstream
|
||||
|
||||
- Connect `<start.fieldName>` directly into agents, tools, or functions that expect structured payloads.
|
||||
- Use templating syntax like `<start.sampleField>` or `<start.files[0].url>` (chat only) in prompt fields.
|
||||
- Keep `<start.conversationId>` handy when you need to group outputs, update conversation history, or call back into the chat API.
|
||||
- Connect <code><start.fieldName></code> directly into agents, tools, or functions that expect structured payloads.
|
||||
- Use templating syntax like <code><start.sampleField></code> or <code><start.files[0].url></code> (chat only) in prompt fields.
|
||||
- Keep <code><start.conversationId></code> handy when you need to group outputs, update conversation history, or call back into the chat API.
|
||||
|
||||
## Best practices
|
||||
|
||||
|
||||
@@ -1,187 +0,0 @@
|
||||
---
|
||||
title: Disparador de API
|
||||
description: Inicia un flujo de trabajo desde una solicitud HTTP autenticada
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Descripción general
|
||||
|
||||
El disparador de API expone tu flujo de trabajo como un punto de conexión HTTP seguro. Envía datos JSON al punto de conexión y tu flujo de trabajo los procesa inmediatamente. Las llamadas a la API siempre se ejecutan contra tu última implementación.
|
||||
|
||||
## Configurar formato de entrada
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/api-trigger-light.png'
|
||||
alt='Formato de entrada del disparador de API'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
Añade un campo de **Formato de entrada** para cada parámetro. Las claves de salida en tiempo de ejecución reflejan el esquema y también están disponibles bajo `<api.input>`.
|
||||
|
||||
Las ejecuciones manuales en el editor utilizan la columna `value` para que puedas realizar pruebas sin enviar una solicitud. Durante la ejecución, el resolutor completa tanto `<api.userId>` como `<api.input.userId>`.
|
||||
|
||||
## Ejemplo de solicitud
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{"userId":"demo-user","maxTokens":1024}'
|
||||
```
|
||||
|
||||
Las respuestas exitosas devuelven el resultado de ejecución serializado del Ejecutor. Los errores muestran fallos de validación, autenticación o flujo de trabajo.
|
||||
|
||||
## Respuestas en streaming
|
||||
|
||||
Habilita el streaming en tiempo real para recibir la salida del flujo de trabajo a medida que se genera, carácter por carácter. Esto es útil para mostrar las respuestas de IA progresivamente a los usuarios.
|
||||
|
||||
### Parámetros de solicitud
|
||||
|
||||
Añade estos parámetros para habilitar el streaming:
|
||||
|
||||
- `stream` - Establece a `true` para habilitar el streaming de eventos enviados por el servidor (SSE)
|
||||
- `selectedOutputs` - Array de salidas de bloques para transmitir (p. ej., `["agent1.content"]`)
|
||||
|
||||
### Formato de salida de bloque
|
||||
|
||||
Usa el formato `blockName.attribute` para especificar qué salidas de bloques transmitir:
|
||||
- Formato: `"blockName.attribute"` (p. ej., si quieres transmitir el contenido del bloque Agente 1, usarías `"agent1.content"`)
|
||||
- Los nombres de los bloques no distinguen entre mayúsculas y minúsculas y se ignoran los espacios
|
||||
|
||||
### Ejemplo de solicitud
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{
|
||||
"message": "Count to five",
|
||||
"stream": true,
|
||||
"selectedOutputs": ["agent1.content"]
|
||||
}'
|
||||
```
|
||||
|
||||
### Formato de respuesta
|
||||
|
||||
Las respuestas en streaming utilizan el formato de eventos enviados por el servidor (SSE):
|
||||
|
||||
```
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"}
|
||||
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"}
|
||||
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", three"}
|
||||
|
||||
data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}}
|
||||
|
||||
data: [DONE]
|
||||
```
|
||||
|
||||
Cada evento incluye:
|
||||
- **Fragmentos de streaming**: `{"blockId": "...", "chunk": "text"}` - Texto en tiempo real a medida que se genera
|
||||
- **Evento final**: `{"event": "done", ...}` - Metadatos de ejecución y resultados completos
|
||||
- **Terminador**: `[DONE]` - Señala el fin del stream
|
||||
|
||||
### Streaming de múltiples bloques
|
||||
|
||||
Cuando `selectedOutputs` incluye múltiples bloques, cada fragmento indica qué bloque lo produjo:
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{
|
||||
"message": "Process this request",
|
||||
"stream": true,
|
||||
"selectedOutputs": ["agent1.content", "agent2.content"]
|
||||
}'
|
||||
```
|
||||
|
||||
El campo `blockId` en cada fragmento te permite dirigir la salida al elemento de UI correcto:
|
||||
|
||||
```
|
||||
data: {"blockId":"agent1-uuid","chunk":"Processing..."}
|
||||
|
||||
data: {"blockId":"agent2-uuid","chunk":"Analyzing..."}
|
||||
|
||||
data: {"blockId":"agent1-uuid","chunk":" complete"}
|
||||
```
|
||||
|
||||
## Referencia de salida
|
||||
|
||||
| Referencia | Descripción |
|
||||
|-----------|-------------|
|
||||
| `<api.field>` | Campo definido en el formato de entrada |
|
||||
| `<api.input>` | Cuerpo de solicitud estructurado completo |
|
||||
|
||||
Si no se define un formato de entrada, el ejecutor expone el JSON sin procesar solo en `<api.input>`.
|
||||
|
||||
<Callout type="warning">
|
||||
Un flujo de trabajo puede contener solo un disparador de API. Publica una nueva implementación después de los cambios para que el endpoint se mantenga actualizado.
|
||||
</Callout>
|
||||
|
||||
### Formato de carga de archivos
|
||||
|
||||
La API acepta archivos en dos formatos:
|
||||
|
||||
**1. Archivos codificados en Base64** (recomendado para SDKs):
|
||||
|
||||
```json
|
||||
{
|
||||
"documents": [{
|
||||
"type": "file",
|
||||
"data": "data:application/pdf;base64,JVBERi0xLjQK...",
|
||||
"name": "document.pdf",
|
||||
"mime": "application/pdf"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
- Tamaño máximo de archivo: 20MB por archivo
|
||||
- Los archivos se suben al almacenamiento en la nube y se convierten en objetos UserFile con todas las propiedades
|
||||
|
||||
**2. Referencias directas de URL**:
|
||||
|
||||
```json
|
||||
{
|
||||
"documents": [{
|
||||
"type": "url",
|
||||
"data": "https://example.com/document.pdf",
|
||||
"name": "document.pdf",
|
||||
"mime": "application/pdf"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
- El archivo no se sube, la URL se pasa directamente
|
||||
- Útil para referenciar archivos existentes
|
||||
|
||||
### Propiedades de archivos
|
||||
|
||||
Para archivos, accede a todas las propiedades:
|
||||
|
||||
| Propiedad | Descripción | Tipo |
|
||||
|----------|-------------|------|
|
||||
| `<api.fieldName[0].url>` | URL de descarga firmada | string |
|
||||
| `<api.fieldName[0].name>` | Nombre original del archivo | string |
|
||||
| `<api.fieldName[0].size>` | Tamaño del archivo en bytes | number |
|
||||
| `<api.fieldName[0].type>` | Tipo MIME | string |
|
||||
| `<api.fieldName[0].uploadedAt>` | Marca de tiempo de subida (ISO 8601) | string |
|
||||
| `<api.fieldName[0].expiresAt>` | Marca de tiempo de caducidad de URL (ISO 8601) | string |
|
||||
|
||||
Para archivos referenciados por URL, las mismas propiedades están disponibles excepto `uploadedAt` y `expiresAt` ya que el archivo no se sube a nuestro almacenamiento.
|
||||
|
||||
Si no se define un formato de entrada, el ejecutor expone solo el JSON sin procesar en `<api.input>`.
|
||||
|
||||
<Callout type="warning">
|
||||
Un flujo de trabajo puede contener solo un disparador de API. Publica una nueva implementación después de los cambios para que el punto de conexión se mantenga actualizado.
|
||||
</Callout>
|
||||
@@ -1,51 +0,0 @@
|
||||
---
|
||||
title: Disparador de chat
|
||||
description: Inicia un flujo de trabajo desde un despliegue de chat
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Descripción general
|
||||
|
||||
El disparador de Chat crea una interfaz conversacional para tu flujo de trabajo. Despliega tu flujo de trabajo como un chat y los usuarios pueden interactuar con él a través de una URL compartible. Cada mensaje inicia una nueva ejecución del flujo de trabajo utilizando tu último despliegue.
|
||||
|
||||
## Salidas en tiempo de ejecución
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/chat-trigger-light.png'
|
||||
alt='Conversación de despliegue de chat'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
El disparador escribe tres campos que los bloques posteriores pueden referenciar:
|
||||
|
||||
| Referencia | Descripción |
|
||||
|-----------|-------------|
|
||||
| `<chat.input>` | Último mensaje del usuario |
|
||||
| `<chat.conversationId>` | ID del hilo de conversación |
|
||||
| `<chat.files>` | Archivos subidos opcionales |
|
||||
|
||||
Los archivos incluyen `name`, `mimeType`, y una descarga firmada `url`.
|
||||
|
||||
## Notas de uso
|
||||
|
||||
1. Añade un bloque de Disparador de Chat por flujo de trabajo.
|
||||
2. Despliega el flujo de trabajo en modo chat.
|
||||
3. Comparte el enlace de despliegue—cada respuesta reutiliza el ID de conversación para que el flujo de trabajo pueda mantener el contexto.
|
||||
|
||||
<Callout type="info">
|
||||
El constructor bloquea múltiples bloques de Disparador de Chat en el mismo flujo de trabajo.
|
||||
</Callout>
|
||||
|
||||
1. Añade un bloque de Disparador de Chat por flujo de trabajo.
|
||||
2. Despliega el flujo de trabajo en modo chat.
|
||||
3. Comparte el enlace de despliegue—cada respuesta reutiliza el ID de conversación para que el flujo de trabajo pueda mantener el contexto.
|
||||
|
||||
<Callout type="info">
|
||||
El constructor bloquea múltiples bloques de Disparador de Chat en el mismo flujo de trabajo.
|
||||
</Callout>
|
||||
@@ -7,46 +7,34 @@ import { Card, Cards } from 'fumadocs-ui/components/card'
|
||||
|
||||
## Disparadores principales
|
||||
|
||||
Elige un disparador por flujo de trabajo para definir cómo comienza:
|
||||
Usa el bloque Start para todo lo que se origina desde el editor, deploy-to-API o experiencias deploy-to-chat. Otros disparadores siguen disponibles para flujos de trabajo basados en eventos:
|
||||
|
||||
<Cards>
|
||||
<Card title="API" href="/triggers/api">
|
||||
Punto final HTTP que mapea cuerpos JSON a entradas de flujo de trabajo
|
||||
</Card>
|
||||
<Card title="Chat" href="/triggers/chat">
|
||||
Interfaz de chat implementada con respuestas en streaming
|
||||
</Card>
|
||||
<Card title="Formulario de entrada" href="/triggers/input-form">
|
||||
Entrada manual tipada utilizada en ejecuciones del editor y flujos de trabajo secundarios
|
||||
</Card>
|
||||
<Card title="Manual" href="/triggers/manual">
|
||||
Ejecuciones bajo demanda sin datos adicionales
|
||||
</Card>
|
||||
<Card title="Programación" href="/triggers/schedule">
|
||||
Ejecución basada en cron o intervalos
|
||||
<Card title="Start" href="/triggers/start">
|
||||
Punto de entrada unificado que admite ejecuciones del editor, despliegues de API y despliegues de chat
|
||||
</Card>
|
||||
<Card title="Webhook" href="/triggers/webhook">
|
||||
Recibe cargas útiles de webhooks externos
|
||||
</Card>
|
||||
<Card title="Schedule" href="/triggers/schedule">
|
||||
Ejecución basada en cron o intervalos
|
||||
</Card>
|
||||
</Cards>
|
||||
|
||||
## Comparación rápida
|
||||
|
||||
| Disparador | Condición de inicio |
|
||||
|---------|-----------------|
|
||||
| **API** | POST HTTP autenticado |
|
||||
| **Chat** | Mensaje de implementación de chat |
|
||||
| **Formulario de entrada** | Al enviar manualmente en el editor o flujo de trabajo principal |
|
||||
| **Manual** | Botón de ejecución en el editor |
|
||||
| **Programación** | Temporizador gestionado en el modal de programación |
|
||||
| **Webhook** | Al recibir una solicitud HTTP |
|
||||
| **Start** | Ejecuciones del editor, solicitudes deploy-to-API o mensajes de chat |
|
||||
| **Schedule** | Temporizador gestionado en el modal de programación |
|
||||
| **Webhook** | En solicitud HTTP entrante |
|
||||
|
||||
> El bloque Start siempre expone los campos `input`, `conversationId` y `files`. Añade campos personalizados al formato de entrada para datos estructurados adicionales.
|
||||
|
||||
## Uso de disparadores
|
||||
|
||||
1. Coloca el bloque disparador en la ranura de inicio.
|
||||
1. Coloca el bloque Start en la ranura de inicio (o un disparador alternativo como Webhook/Schedule).
|
||||
2. Configura cualquier esquema o autenticación requerida.
|
||||
3. Conecta el bloque al resto del flujo de trabajo.
|
||||
|
||||
> Las implementaciones potencian cada disparador. Actualiza el flujo de trabajo, vuelve a implementarlo, y todos los puntos de entrada de disparadores recogen la nueva instantánea. Aprende más en [Ejecución → Instantáneas de implementación](/execution).
|
||||
|
||||
Los bloques de inicio heredados permanecen para flujos existentes pero ya no aparecen en nuevas compilaciones.
|
||||
> Los despliegues alimentan cada disparador. Actualiza el flujo de trabajo, vuelve a desplegar, y todos los puntos de entrada de disparadores recogen la nueva instantánea. Aprende más en [Ejecución → Instantáneas de despliegue](/execution).
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
---
|
||||
title: Disparador de formulario de entrada
|
||||
description: Disparador manual con un esquema de entrada estructurado
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Descripción general
|
||||
|
||||
Utiliza un disparador de formulario de entrada cuando un flujo de trabajo debe iniciarse desde el editor con campos tipados. El panel de ejecución muestra exactamente los campos que defines, por lo que el flujo de trabajo siempre recibe datos limpios.
|
||||
|
||||
## Lo que defines
|
||||
|
||||
Añade campos en el constructor de formato de entrada (texto, número, booleano, JSON, etc.). Para cada campo:
|
||||
|
||||
- El valor aparece como `<blockName.field>` en el flujo de trabajo.
|
||||
- La carga completa se refleja en `<blockName.input>` para mayor comodidad.
|
||||
|
||||
Si dejas el formulario vacío, el disparador no tiene salidas.
|
||||
|
||||
## Ejecuciones manuales
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/input-form-panel-light.png'
|
||||
alt='Panel de ejecución del formulario de entrada'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
Cuando presionas Ejecutar en el editor, el panel muestra el formulario. Los valores enviados alimentan directamente la salida del disparador, por lo que los bloques posteriores pueden referenciarlos sin análisis adicional. Los números se convierten a números, los booleanos se convierten en verdadero/falso, y los campos JSON se analizan antes de que el flujo de trabajo los vea.
|
||||
|
||||
## Flujos de trabajo secundarios
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/workflow-input-mapping-light.png'
|
||||
alt='Mapeo de entrada de flujo de trabajo'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
Los disparadores de formulario de entrada también alimentan el bloque de flujo de trabajo. Cuando incrustas un flujo de trabajo secundario, el paso de mapeo muestra los campos del formulario secundario para que puedas conectar variables desde el padre. Todo lo que mapeas se convierte en el envío del formulario de entrada del flujo de trabajo secundario.
|
||||
|
||||
<Callout>
|
||||
¿Necesitas un botón de ejecución rápida sin campos? Usa un disparador manual. Elige el formulario de entrada cuando quieras validación y una estructura predecible.
|
||||
</Callout>
|
||||
@@ -1,41 +0,0 @@
|
||||
---
|
||||
title: Disparador manual
|
||||
description: Ejecuta un flujo de trabajo bajo demanda sin entradas
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Descripción general
|
||||
|
||||
El disparador manual añade un simple botón Ejecutar en la parte superior de tu flujo de trabajo. Úsalo cuando quieras ejecutar el flujo de trabajo inmediatamente sin recopilar datos adicionales.
|
||||
|
||||
## Cómo funciona
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/manual-run-light.png'
|
||||
alt='Botón de ejecución del disparador manual'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
- Inicia el flujo de trabajo utilizando la instantánea de despliegue activa
|
||||
- No envía ninguna carga útil—los bloques posteriores solo ven lo que ya tienen configurado
|
||||
- Perfecto para comprobaciones rápidas, pruebas de humo o flujos que solo dependen de variables internas
|
||||
|
||||
## Cuándo usarlo
|
||||
|
||||
- Inicia un flujo de trabajo después de publicar un nuevo despliegue para confirmar que todo sigue funcionando
|
||||
- Ejecuta tareas de mantenimiento que no requieren entrada externa
|
||||
- Activa flujos de trabajo secundarios que solo leen estado o variables de entorno
|
||||
|
||||
## Comparación con el formulario de entrada
|
||||
|
||||
¿Necesitas valores estructurados o validación de tipos en tiempo de ejecución? Cambia a un disparador de formulario de entrada en su lugar—el panel de ejecución recopilará esos campos antes de que comience el flujo de trabajo.
|
||||
|
||||
<Callout>
|
||||
Las ejecuciones del disparador manual no sobrescriben tu historial de despliegue. Actualiza y vuelve a desplegar cuando los cambios en el lienzo necesiten entrar en producción.
|
||||
</Callout>
|
||||
97
apps/docs/content/docs/es/triggers/start.mdx
Normal file
97
apps/docs/content/docs/es/triggers/start.mdx
Normal file
@@ -0,0 +1,97 @@
|
||||
---
|
||||
title: Inicio
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Tab, Tabs } from 'fumadocs-ui/components/tabs'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
El bloque Inicio es el disparador predeterminado para los flujos de trabajo creados en Sim. Recopila entradas estructuradas y se distribuye al resto de tu gráfico para pruebas de editor, implementaciones de API y experiencias de chat.
|
||||
|
||||
<div className="flex justify-center">
|
||||
<Image
|
||||
src="/static/start.png"
|
||||
alt="Bloque de inicio con campos de formato de entrada"
|
||||
width={360}
|
||||
height={380}
|
||||
className="my-6"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Callout type="info">
|
||||
El bloque Inicio se sitúa en la posición inicial cuando creas un flujo de trabajo. Mantenlo allí cuando quieras que el mismo punto de entrada sirva para ejecuciones del editor, solicitudes de implementación de API y sesiones de chat. Cámbialo por disparadores de Webhook o Programación cuando solo necesites ejecución basada en eventos.
|
||||
</Callout>
|
||||
|
||||
## Campos expuestos por Inicio
|
||||
|
||||
El bloque Inicio emite diferentes datos dependiendo de la superficie de ejecución:
|
||||
|
||||
- **Campos de formato de entrada** — Cada campo que añadas estará disponible como <code><start.fieldName></code>. Por ejemplo, un campo `customerId` aparecerá como <code><start.customerId></code> en bloques y plantillas posteriores.
|
||||
- **Campos exclusivos de chat** — Cuando el flujo de trabajo se ejecuta desde el panel lateral de chat o una experiencia de chat implementada, Sim también proporciona <code><start.input></code> (último mensaje del usuario), <code><start.conversationId></code> (id de sesión activa), y <code><start.files></code> (archivos adjuntos del chat).
|
||||
|
||||
Mantén los campos de formato de entrada limitados a los nombres que esperas referenciar más tarde—esos valores son los únicos campos estructurados compartidos entre ejecuciones de editor, API y chat.
|
||||
|
||||
## Configurar el formato de entrada
|
||||
|
||||
Usa el sub-bloque de formato de entrada para definir el esquema que se aplica en todos los modos de ejecución:
|
||||
|
||||
1. Añade un campo para cada valor que quieras recopilar.
|
||||
2. Elige un tipo (`string`, `number`, `boolean`, `object`, `array`, o `files`). Los campos de archivo aceptan cargas desde chat y llamadas a la API.
|
||||
3. Proporciona valores predeterminados cuando quieras que el modal de ejecución manual complete automáticamente datos de prueba. Estos valores predeterminados se ignoran para ejecuciones implementadas.
|
||||
4. Reordena los campos para controlar cómo aparecen en el formulario del editor.
|
||||
|
||||
Haz referencia a valores estructurados posteriores con expresiones como <code><start.customerId></code> dependiendo del bloque que conectes.
|
||||
|
||||
## Cómo se comporta por punto de entrada
|
||||
|
||||
<Tabs items={['Ejecución en el editor', 'Despliegue a API', 'Despliegue a chat']}>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
Cuando haces clic en <strong>Ejecutar</strong> en el editor, el bloque Inicio muestra el Formato de Entrada como un formulario. Los valores predeterminados facilitan volver a probar sin tener que volver a escribir datos. Al enviar el formulario se activa el flujo de trabajo inmediatamente y los valores quedan disponibles en <code><start.fieldName></code> (por ejemplo <code><start.sampleField></code>).
|
||||
</p>
|
||||
<p>
|
||||
Los campos de archivo en el formulario se cargan directamente en el
|
||||
correspondiente <code><start.fieldName></code>; usa esos valores para
|
||||
alimentar herramientas posteriores o pasos de almacenamiento.
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
Desplegar a API convierte el Formato de Entrada en un contrato JSON para los clientes. Cada campo se convierte en parte del cuerpo de la solicitud, y Sim fuerza los tipos primitivos durante la ingesta. Los campos de archivo esperan objetos que hagan referencia a archivos cargados; utiliza el punto de conexión de carga de archivos de ejecución antes de invocar el flujo de trabajo.
|
||||
</p>
|
||||
<p>
|
||||
Los que llaman a la API pueden incluir propiedades opcionales adicionales.
|
||||
Estas se conservan dentro de las salidas <code><start.fieldName></code>
|
||||
para que puedas experimentar sin tener que redesplegar inmediatamente.
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
En los despliegues de chat, el bloque Inicio se vincula a la conversación activa. El último mensaje rellena <code><start.input></code>, el identificador de sesión está disponible en <code><start.conversationId></code>, y los archivos adjuntos del usuario aparecen en <code><start.files></code>, junto con cualquier campo del Formato de Entrada definido como <code><start.fieldName></code>.
|
||||
</p>
|
||||
<p>
|
||||
Si inicias el chat con contexto estructurado adicional (por ejemplo, desde una
|
||||
incrustación), este se fusiona con las salidas{' '}
|
||||
<code><start.fieldName></code> correspondientes, manteniendo los bloques
|
||||
posteriores consistentes con la API y las ejecuciones manuales.
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## Referenciando datos de Start en nodos posteriores
|
||||
|
||||
- Conecta <code><start.fieldName></code> directamente a agentes, herramientas o funciones que esperan cargas estructuradas.
|
||||
- Usa sintaxis de plantillas como <code><start.sampleField></code> o <code><start.files[0].url></code> (solo en chat) en campos de prompt.
|
||||
- Mantén <code><start.conversationId></code> a mano cuando necesites agrupar salidas, actualizar el historial de conversación o llamar de nuevo a la API de chat.
|
||||
|
||||
## Mejores prácticas
|
||||
|
||||
- Trata el bloque Start como el único punto de entrada cuando quieras dar soporte tanto a llamadas de API como de chat.
|
||||
- Prefiere campos con formato de entrada nombrados en lugar de analizar JSON sin procesar en nodos posteriores; la conversión de tipos ocurre automáticamente.
|
||||
- Añade validación o enrutamiento inmediatamente después de Start si ciertos campos son necesarios para que tu flujo de trabajo tenga éxito.
|
||||
@@ -1,67 +0,0 @@
|
||||
---
|
||||
title: Starter (Obsoleto)
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Tab, Tabs } from 'fumadocs-ui/components/tabs'
|
||||
import { Image } from '@/components/ui/image'
|
||||
import { Video } from '@/components/ui/video'
|
||||
|
||||
<Callout type="warning">
|
||||
El bloque Starter ha quedado obsoleto y ha sido reemplazado por Disparadores Core más especializados. Consulta la [documentación de Disparadores Core](/triggers) para conocer la nueva API y los disparadores de Chat, Formulario de entrada, Manual, Programación y Webhook.
|
||||
</Callout>
|
||||
|
||||
El bloque Starter te permite iniciar manualmente la ejecución del flujo de trabajo con parámetros de entrada, ofreciendo dos modos de entrada: parámetros estructurados o chat conversacional.
|
||||
|
||||
<div className="flex justify-center">
|
||||
<Image
|
||||
src="/static/starter.png"
|
||||
alt="Bloque Starter con opciones de modo Manual y Chat"
|
||||
width={500}
|
||||
height={400}
|
||||
className="my-6"
|
||||
/>
|
||||
</div>
|
||||
|
||||
## Modos de ejecución
|
||||
|
||||
Elige tu método de entrada desde el menú desplegable:
|
||||
|
||||
<Tabs items={['Modo Manual', 'Modo Chat']}>
|
||||
<Tab>
|
||||
<div className="space-y-4">
|
||||
<ul className="list-disc space-y-1 pl-6">
|
||||
<li><strong>Entradas estructuradas compatibles con API</strong>: Define parámetros específicos (texto, número, booleano, JSON, archivo, fecha)</li>
|
||||
<li><strong>Pruebas mientras construyes tu flujo de trabajo</strong>: Iteración rápida durante la depuración de flujos de trabajo</li>
|
||||
</ul>
|
||||
|
||||
<div className="mx-auto w-full overflow-hidden rounded-lg">
|
||||
<Video src="input-format.mp4" width={700} height={450} />
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-gray-600">Configura parámetros de entrada que estarán disponibles al implementar como un punto de conexión API.</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-4">
|
||||
<ul className="list-disc space-y-1 pl-6">
|
||||
<li><strong>Lenguaje natural</strong>: Los usuarios escriben preguntas o solicitudes</li>
|
||||
<li><strong>Conversacional</strong>: Ideal para flujos de trabajo impulsados por IA</li>
|
||||
</ul>
|
||||
|
||||
<div className="mx-auto w-full overflow-hidden rounded-lg">
|
||||
<Video src="chat-input.mp4" width={700} height={450} />
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-gray-600">Chatea con tu flujo de trabajo y accede al texto de entrada, ID de conversación y archivos subidos para respuestas contextualizadas.</p>
|
||||
</div>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## Uso de variables de Chat
|
||||
|
||||
En el modo Chat, accede a la entrada del usuario y al contexto de la conversación a través de variables especiales:
|
||||
|
||||
- **`<start.input>`** - Contiene el texto del mensaje del usuario
|
||||
- **`<start.conversationId>`** - Identificador único para el hilo de conversación
|
||||
- **`<start.files>`** - Array de archivos subidos por el usuario (si los hay)
|
||||
@@ -1,357 +0,0 @@
|
||||
---
|
||||
title: Esquema YAML del bloque Loop
|
||||
description: Referencia de configuración YAML para bloques Loop
|
||||
---
|
||||
|
||||
## Definición del esquema
|
||||
|
||||
```yaml
|
||||
type: object
|
||||
required:
|
||||
- type
|
||||
- name
|
||||
- connections
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
enum: [loop]
|
||||
description: Block type identifier
|
||||
name:
|
||||
type: string
|
||||
description: Display name for this loop block
|
||||
inputs:
|
||||
type: object
|
||||
description: Optional. If omitted, defaults will be applied.
|
||||
properties:
|
||||
loopType:
|
||||
type: string
|
||||
enum: [for, forEach]
|
||||
description: Type of loop to execute
|
||||
default: for
|
||||
iterations:
|
||||
type: number
|
||||
description: Number of iterations (for 'for' loops)
|
||||
default: 5
|
||||
minimum: 1
|
||||
maximum: 1000
|
||||
collection:
|
||||
type: string
|
||||
description: Collection to iterate over (for 'forEach' loops)
|
||||
default: ""
|
||||
maxConcurrency:
|
||||
type: number
|
||||
description: Maximum concurrent executions
|
||||
default: 1
|
||||
minimum: 1
|
||||
maximum: 10
|
||||
connections:
|
||||
type: object
|
||||
properties:
|
||||
# Nested format (recommended)
|
||||
loop:
|
||||
type: object
|
||||
properties:
|
||||
start:
|
||||
type: string
|
||||
description: Target block ID to execute inside the loop
|
||||
end:
|
||||
type: string
|
||||
description: Target block ID for loop completion (optional)
|
||||
# Direct handle format (alternative)
|
||||
loop-start-source:
|
||||
type: string | string[]
|
||||
description: Target block ID to execute inside the loop (direct format)
|
||||
loop-end-source:
|
||||
type: string | string[]
|
||||
description: Target block ID for loop completion (direct format, optional)
|
||||
error:
|
||||
type: string
|
||||
description: Target block ID for error handling
|
||||
note: Use either the nested 'loop' format OR the direct 'loop-start-source' format, not both
|
||||
```
|
||||
|
||||
## Configuración de conexión
|
||||
|
||||
Los bloques de bucle admiten dos formatos de conexión:
|
||||
|
||||
### Formato de manejador directo (alternativo)
|
||||
|
||||
```yaml
|
||||
connections:
|
||||
loop-start-source: <string> # Target block ID to execute inside the loop
|
||||
loop-end-source: <string> # Target block ID after loop completion (optional)
|
||||
error: <string> # Target block ID for error handling (optional)
|
||||
```
|
||||
|
||||
Ambos formatos funcionan de manera idéntica. Usa el que prefieras.
|
||||
|
||||
## Configuración de bloques secundarios
|
||||
|
||||
Los bloques dentro de un bucle deben tener su `parentId` configurado con el ID del bloque de bucle. La propiedad `extent` se establece automáticamente como `'parent'` y no necesita ser especificada:
|
||||
|
||||
```yaml
|
||||
loop-1:
|
||||
type: loop
|
||||
name: "Process Items"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.items>
|
||||
connections:
|
||||
loop:
|
||||
start: process-item
|
||||
end: final-results
|
||||
|
||||
# Child block inside the loop
|
||||
process-item:
|
||||
type: agent
|
||||
name: "Process Item"
|
||||
parentId: loop-1 # References the loop block
|
||||
inputs:
|
||||
systemPrompt: "Process this item"
|
||||
userPrompt: <loop.currentItem>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
## Ejemplos
|
||||
|
||||
### Bucle For (iteraciones fijas)
|
||||
|
||||
```yaml
|
||||
countdown-loop:
|
||||
type: loop
|
||||
name: "Countdown Loop"
|
||||
inputs:
|
||||
loopType: for
|
||||
iterations: 5
|
||||
connections:
|
||||
loop:
|
||||
start: countdown-agent
|
||||
end: countdown-complete
|
||||
|
||||
countdown-agent:
|
||||
type: agent
|
||||
name: "Countdown Agent"
|
||||
parentId: countdown-loop
|
||||
inputs:
|
||||
systemPrompt: "Generate a countdown message"
|
||||
userPrompt: "Count down from 5. Current number: <loop.index>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### Bucle ForEach (procesamiento de colecciones)
|
||||
|
||||
```yaml
|
||||
email-processor-loop:
|
||||
type: loop
|
||||
name: "Email Processor Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.emails>
|
||||
connections:
|
||||
loop:
|
||||
start: process-single-email
|
||||
end: all-emails-processed
|
||||
|
||||
process-single-email:
|
||||
type: agent
|
||||
name: "Process Single Email"
|
||||
parentId: email-processor-loop
|
||||
inputs:
|
||||
systemPrompt: "Classify and respond to this email"
|
||||
userPrompt: "Email content: <loop.currentItem>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### Bucle con múltiples bloques secundarios
|
||||
|
||||
```yaml
|
||||
data-analysis-loop:
|
||||
type: loop
|
||||
name: "Data Analysis Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <data-fetcher.records>
|
||||
maxConcurrency: 3
|
||||
connections:
|
||||
loop:
|
||||
start: validate-record
|
||||
end: generate-report
|
||||
error: handle-loop-error
|
||||
|
||||
validate-record:
|
||||
type: function
|
||||
name: "Validate Record"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
code: |
|
||||
const record = <loop.currentItem>;
|
||||
const index = <loop.index>;
|
||||
|
||||
// Validate the record
|
||||
if (!record.id || !record.data) {
|
||||
throw new Error(`Invalid record at index ${index}`);
|
||||
}
|
||||
|
||||
return {
|
||||
valid: true,
|
||||
recordId: record.id,
|
||||
processedAt: new Date().toISOString()
|
||||
};
|
||||
connections:
|
||||
success: analyze-record
|
||||
error: record-error
|
||||
|
||||
analyze-record:
|
||||
type: agent
|
||||
name: "Analyze Record"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
systemPrompt: "Analyze this data record and extract insights"
|
||||
userPrompt: |
|
||||
Record ID: <validaterecord.recordId>
|
||||
Data: <loop.currentItem.data>
|
||||
Position in collection: <loop.index>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
connections:
|
||||
success: store-analysis
|
||||
|
||||
store-analysis:
|
||||
type: function
|
||||
name: "Store Analysis"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
code: |
|
||||
const analysis = <analyzerecord.content>;
|
||||
const recordId = <validaterecord.recordId>;
|
||||
|
||||
// Store analysis result
|
||||
return {
|
||||
recordId,
|
||||
analysis,
|
||||
completedAt: new Date().toISOString()
|
||||
};
|
||||
```
|
||||
|
||||
### Bucle de procesamiento concurrente
|
||||
|
||||
```yaml
|
||||
parallel-processing-loop:
|
||||
type: loop
|
||||
name: "Parallel Processing Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.tasks>
|
||||
maxConcurrency: 5
|
||||
connections:
|
||||
loop:
|
||||
start: process-task
|
||||
end: aggregate-results
|
||||
|
||||
process-task:
|
||||
type: api
|
||||
name: "Process Task"
|
||||
parentId: parallel-processing-loop
|
||||
inputs:
|
||||
url: "https://api.example.com/process"
|
||||
method: POST
|
||||
headers:
|
||||
- key: "Authorization"
|
||||
value: "Bearer {{API_TOKEN}}"
|
||||
body: |
|
||||
{
|
||||
"taskId": "<loop.currentItem.id>",
|
||||
"data": "<loop.currentItem.data>"
|
||||
}
|
||||
connections:
|
||||
success: task-completed
|
||||
```
|
||||
|
||||
### Ejemplo de formato de manejador directo
|
||||
|
||||
El mismo bucle puede escribirse usando el formato de manejador directo:
|
||||
|
||||
```yaml
|
||||
my-loop:
|
||||
type: loop
|
||||
name: "Process Items"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.items>
|
||||
connections:
|
||||
loop-start-source: process-item # Direct handle format
|
||||
loop-end-source: final-results # Direct handle format
|
||||
error: handle-error
|
||||
|
||||
process-item:
|
||||
type: agent
|
||||
name: "Process Item"
|
||||
parentId: my-loop
|
||||
inputs:
|
||||
systemPrompt: "Process this item"
|
||||
userPrompt: <loop.currentItem>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### Ejemplo de bucle mínimo (usando valores predeterminados)
|
||||
|
||||
Puedes omitir completamente la sección `inputs`, y se aplicarán los valores predeterminados:
|
||||
|
||||
```yaml
|
||||
simple-loop:
|
||||
type: loop
|
||||
name: "Simple Loop"
|
||||
# No inputs section - defaults to loopType: 'for', iterations: 5
|
||||
connections:
|
||||
loop-start-source: process-step
|
||||
loop-end-source: complete
|
||||
|
||||
process-step:
|
||||
type: agent
|
||||
name: "Process Step"
|
||||
parentId: simple-loop
|
||||
inputs:
|
||||
systemPrompt: "Execute step"
|
||||
userPrompt: "Step <loop.index>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
Este bucle ejecutará 5 iteraciones por defecto.
|
||||
|
||||
## Variables de bucle
|
||||
|
||||
Dentro de los bloques secundarios del bucle, estas variables especiales están disponibles:
|
||||
|
||||
```yaml
|
||||
# Available in all child blocks of the loop
|
||||
<loop.index> # Current iteration number (0-based)
|
||||
<loop.currentItem> # Current item being processed (forEach loops)
|
||||
<loop.items> # Full collection (forEach loops)
|
||||
```
|
||||
|
||||
## Referencias de salida
|
||||
|
||||
Después de que un bucle se completa, puedes hacer referencia a sus resultados agregados:
|
||||
|
||||
```yaml
|
||||
# In blocks after the loop
|
||||
final-processor:
|
||||
inputs:
|
||||
all-results: <loop-name.results> # Array of all iteration results
|
||||
total-count: <loop-name.count> # Number of iterations completed
|
||||
```
|
||||
|
||||
## Mejores prácticas
|
||||
|
||||
- Establece límites de iteración razonables para evitar tiempos de ejecución largos
|
||||
- Usa forEach para procesar colecciones, bucles for para iteraciones fijas
|
||||
- Considera usar maxConcurrency para operaciones limitadas por E/S
|
||||
- Incluye manejo de errores para una ejecución robusta del bucle
|
||||
- Usa nombres descriptivos para los bloques secundarios del bucle
|
||||
- Prueba primero con colecciones pequeñas
|
||||
- Monitorea el tiempo de ejecución para colecciones grandes
|
||||
@@ -1,187 +0,0 @@
|
||||
---
|
||||
title: Déclencheur d'API
|
||||
description: Démarrez un flux de travail à partir d'une requête HTTP authentifiée
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Aperçu
|
||||
|
||||
Le déclencheur d'API expose votre flux de travail en tant que point de terminaison HTTP sécurisé. Envoyez des données JSON au point de terminaison et votre flux de travail les traite immédiatement. Les appels API s'exécutent toujours sur votre dernier déploiement.
|
||||
|
||||
## Configurer le format d'entrée
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/api-trigger-light.png'
|
||||
alt="Format d'entrée du déclencheur d'API"
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
Ajoutez un champ **Format d'entrée** pour chaque paramètre. Les clés de sortie d'exécution reflètent le schéma et sont également disponibles sous `<api.input>`.
|
||||
|
||||
Les exécutions manuelles dans l'éditeur utilisent la colonne `value` pour que vous puissiez tester sans envoyer de requête. Pendant l'exécution, le résolveur remplit à la fois `<api.userId>` et `<api.input.userId>`.
|
||||
|
||||
## Exemple de requête
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{"userId":"demo-user","maxTokens":1024}'
|
||||
```
|
||||
|
||||
Les réponses réussies renvoient le résultat d'exécution sérialisé de l'exécuteur. Les erreurs révèlent des problèmes de validation, d'authentification ou d'échec du workflow.
|
||||
|
||||
## Réponses en streaming
|
||||
|
||||
Activez le streaming en temps réel pour recevoir les résultats du workflow au fur et à mesure qu'ils sont générés, caractère par caractère. Cela est utile pour afficher progressivement les réponses de l'IA aux utilisateurs.
|
||||
|
||||
### Paramètres de requête
|
||||
|
||||
Ajoutez ces paramètres pour activer le streaming :
|
||||
|
||||
- `stream` - Définissez à `true` pour activer le streaming Server-Sent Events (SSE)
|
||||
- `selectedOutputs` - Tableau des sorties de blocs à diffuser en streaming (par exemple, `["agent1.content"]`)
|
||||
|
||||
### Format de sortie de bloc
|
||||
|
||||
Utilisez le format `blockName.attribute` pour spécifier quelles sorties de blocs diffuser en streaming :
|
||||
- Format : `"blockName.attribute"` (par exemple, si vous souhaitez diffuser en streaming le contenu du bloc Agent 1, vous utiliseriez `"agent1.content"`)
|
||||
- Les noms de blocs ne sont pas sensibles à la casse et les espaces sont ignorés
|
||||
|
||||
### Exemple de requête
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{
|
||||
"message": "Count to five",
|
||||
"stream": true,
|
||||
"selectedOutputs": ["agent1.content"]
|
||||
}'
|
||||
```
|
||||
|
||||
### Format de réponse
|
||||
|
||||
Les réponses en streaming utilisent le format Server-Sent Events (SSE) :
|
||||
|
||||
```
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"}
|
||||
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"}
|
||||
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", three"}
|
||||
|
||||
data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}}
|
||||
|
||||
data: [DONE]
|
||||
```
|
||||
|
||||
Chaque événement comprend :
|
||||
- **Fragments en streaming** : `{"blockId": "...", "chunk": "text"}` - Texte en temps réel au fur et à mesure qu'il est généré
|
||||
- **Événement final** : `{"event": "done", ...}` - Métadonnées d'exécution et résultats complets
|
||||
- **Terminateur** : `[DONE]` - Signale la fin du flux
|
||||
|
||||
### Streaming de plusieurs blocs
|
||||
|
||||
Lorsque `selectedOutputs` inclut plusieurs blocs, chaque fragment indique quel bloc l'a produit :
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{
|
||||
"message": "Process this request",
|
||||
"stream": true,
|
||||
"selectedOutputs": ["agent1.content", "agent2.content"]
|
||||
}'
|
||||
```
|
||||
|
||||
Le champ `blockId` dans chaque fragment vous permet d'acheminer la sortie vers l'élément d'interface utilisateur approprié :
|
||||
|
||||
```
|
||||
data: {"blockId":"agent1-uuid","chunk":"Processing..."}
|
||||
|
||||
data: {"blockId":"agent2-uuid","chunk":"Analyzing..."}
|
||||
|
||||
data: {"blockId":"agent1-uuid","chunk":" complete"}
|
||||
```
|
||||
|
||||
## Référence des sorties
|
||||
|
||||
| Référence | Description |
|
||||
|-----------|-------------|
|
||||
| `<api.field>` | Champ défini dans le format d'entrée |
|
||||
| `<api.input>` | Corps de requête structuré complet |
|
||||
|
||||
Si aucun format d'entrée n'est défini, l'exécuteur expose uniquement le JSON brut à `<api.input>`.
|
||||
|
||||
<Callout type="warning">
|
||||
Un workflow ne peut contenir qu'un seul déclencheur API. Publiez un nouveau déploiement après les modifications pour que le point de terminaison reste à jour.
|
||||
</Callout>
|
||||
|
||||
### Format de téléchargement de fichiers
|
||||
|
||||
L'API accepte les fichiers dans deux formats :
|
||||
|
||||
**1. Fichiers encodés en Base64** (recommandé pour les SDK) :
|
||||
|
||||
```json
|
||||
{
|
||||
"documents": [{
|
||||
"type": "file",
|
||||
"data": "data:application/pdf;base64,JVBERi0xLjQK...",
|
||||
"name": "document.pdf",
|
||||
"mime": "application/pdf"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
- Taille maximale de fichier : 20 Mo par fichier
|
||||
- Les fichiers sont téléchargés vers le stockage cloud et convertis en objets UserFile avec toutes les propriétés
|
||||
|
||||
**2. Références URL directes** :
|
||||
|
||||
```json
|
||||
{
|
||||
"documents": [{
|
||||
"type": "url",
|
||||
"data": "https://example.com/document.pdf",
|
||||
"name": "document.pdf",
|
||||
"mime": "application/pdf"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
- Le fichier n'est pas téléchargé, l'URL est transmise directement
|
||||
- Utile pour référencer des fichiers existants
|
||||
|
||||
### Propriétés des fichiers
|
||||
|
||||
Pour les fichiers, accédez à toutes les propriétés :
|
||||
|
||||
| Propriété | Description | Type |
|
||||
|----------|-------------|------|
|
||||
| `<api.fieldName[0].url>` | URL de téléchargement signée | chaîne |
|
||||
| `<api.fieldName[0].name>` | Nom de fichier original | chaîne |
|
||||
| `<api.fieldName[0].size>` | Taille du fichier en octets | nombre |
|
||||
| `<api.fieldName[0].type>` | Type MIME | chaîne |
|
||||
| `<api.fieldName[0].uploadedAt>` | Horodatage du téléchargement (ISO 8601) | chaîne |
|
||||
| `<api.fieldName[0].expiresAt>` | Horodatage d'expiration de l'URL (ISO 8601) | chaîne |
|
||||
|
||||
Pour les fichiers référencés par URL, les mêmes propriétés sont disponibles à l'exception de `uploadedAt` et `expiresAt` puisque le fichier n'est pas téléchargé vers notre stockage.
|
||||
|
||||
Si aucun format d'entrée n'est défini, l'exécuteur expose uniquement le JSON brut à `<api.input>`.
|
||||
|
||||
<Callout type="warning">
|
||||
Un flux de travail ne peut contenir qu'un seul déclencheur API. Publiez un nouveau déploiement après les modifications pour que le point de terminaison reste à jour.
|
||||
</Callout>
|
||||
@@ -1,51 +0,0 @@
|
||||
---
|
||||
title: Déclencheur de chat
|
||||
description: Démarrer un flux de travail à partir d'un déploiement de chat
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Aperçu
|
||||
|
||||
Le déclencheur de chat crée une interface conversationnelle pour votre flux de travail. Déployez votre flux de travail sous forme de chat et les utilisateurs peuvent interagir avec lui via une URL partageable. Chaque message démarre une nouvelle exécution du flux de travail en utilisant votre dernier déploiement.
|
||||
|
||||
## Sorties d'exécution
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/chat-trigger-light.png'
|
||||
alt='Conversation de déploiement de chat'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
Le déclencheur écrit trois champs que les blocs en aval peuvent référencer :
|
||||
|
||||
| Référence | Description |
|
||||
|-----------|-------------|
|
||||
| `<chat.input>` | Dernier message de l'utilisateur |
|
||||
| `<chat.conversationId>` | ID du fil de conversation |
|
||||
| `<chat.files>` | Fichiers téléchargés optionnels |
|
||||
|
||||
Les fichiers incluent `name`, `mimeType`, et un `url` signé.
|
||||
|
||||
## Notes d'utilisation
|
||||
|
||||
1. Ajoutez un bloc Déclencheur de chat par flux de travail.
|
||||
2. Déployez le flux de travail en mode chat.
|
||||
3. Partagez le lien de déploiement — chaque réponse réutilise l'ID de conversation pour que le flux de travail puisse conserver le contexte.
|
||||
|
||||
<Callout type="info">
|
||||
Le constructeur bloque plusieurs blocs Déclencheur de chat dans le même flux de travail.
|
||||
</Callout>
|
||||
|
||||
1. Ajoutez un bloc Déclencheur de Chat par workflow.
|
||||
2. Déployez le workflow en mode chat.
|
||||
3. Partagez le lien de déploiement—chaque réponse réutilise l'ID de conversation pour que le workflow puisse conserver le contexte.
|
||||
|
||||
<Callout type="info">
|
||||
Le constructeur bloque plusieurs blocs Déclencheur de Chat dans le même workflow.
|
||||
</Callout>
|
||||
@@ -7,26 +7,17 @@ import { Card, Cards } from 'fumadocs-ui/components/card'
|
||||
|
||||
## Déclencheurs principaux
|
||||
|
||||
Choisissez un déclencheur par workflow pour définir comment il démarre :
|
||||
Utilisez le bloc Start pour tout ce qui provient de l'éditeur, du déploiement vers l'API ou des expériences de déploiement vers le chat. D'autres déclencheurs restent disponibles pour les flux de travail pilotés par événements :
|
||||
|
||||
<Cards>
|
||||
<Card title="API" href="/triggers/api">
|
||||
Point de terminaison HTTP qui transforme les corps JSON en entrées de workflow
|
||||
</Card>
|
||||
<Card title="Chat" href="/triggers/chat">
|
||||
Interface de chat déployée avec réponses en streaming
|
||||
</Card>
|
||||
<Card title="Formulaire d'entrée" href="/triggers/input-form">
|
||||
Saisie manuelle typée utilisée dans les exécutions d'éditeur et les workflows enfants
|
||||
</Card>
|
||||
<Card title="Manuel" href="/triggers/manual">
|
||||
Exécutions à la demande sans données supplémentaires
|
||||
</Card>
|
||||
<Card title="Planification" href="/triggers/schedule">
|
||||
Exécution basée sur cron ou intervalle
|
||||
<Card title="Start" href="/triggers/start">
|
||||
Point d'entrée unifié qui prend en charge les exécutions de l'éditeur, les déploiements d'API et les déploiements de chat
|
||||
</Card>
|
||||
<Card title="Webhook" href="/triggers/webhook">
|
||||
Réception de charges utiles webhook externes
|
||||
Recevoir des charges utiles de webhook externes
|
||||
</Card>
|
||||
<Card title="Schedule" href="/triggers/schedule">
|
||||
Exécution basée sur cron ou intervalle
|
||||
</Card>
|
||||
</Cards>
|
||||
|
||||
@@ -34,19 +25,16 @@ Choisissez un déclencheur par workflow pour définir comment il démarre :
|
||||
|
||||
| Déclencheur | Condition de démarrage |
|
||||
|---------|-----------------|
|
||||
| **API** | POST HTTP authentifié |
|
||||
| **Chat** | Message de déploiement de chat |
|
||||
| **Formulaire d'entrée** | À la soumission manuelle dans l'éditeur ou le workflow parent |
|
||||
| **Manuel** | Bouton d'exécution dans l'éditeur |
|
||||
| **Planification** | Minuteur géré dans la fenêtre de planification |
|
||||
| **Webhook** | À la réception d'une requête HTTP entrante |
|
||||
| **Start** | Exécutions de l'éditeur, requêtes de déploiement vers l'API ou messages de chat |
|
||||
| **Schedule** | Minuteur géré dans la fenêtre modale de planification |
|
||||
| **Webhook** | Sur requête HTTP entrante |
|
||||
|
||||
> Le bloc Start expose toujours les champs `input`, `conversationId`, et `files`. Ajoutez des champs personnalisés au format d'entrée pour des données structurées supplémentaires.
|
||||
|
||||
## Utilisation des déclencheurs
|
||||
|
||||
1. Déposez le bloc déclencheur dans l'emplacement de départ.
|
||||
1. Déposez le bloc Start dans l'emplacement de départ (ou un déclencheur alternatif comme Webhook/Schedule).
|
||||
2. Configurez tout schéma ou authentification requis.
|
||||
3. Connectez le bloc au reste du workflow.
|
||||
3. Connectez le bloc au reste du flux de travail.
|
||||
|
||||
> Les déploiements alimentent chaque déclencheur. Mettez à jour le workflow, redéployez, et tous les points d'entrée des déclencheurs récupèrent le nouveau snapshot. En savoir plus dans [Exécution → Snapshots de déploiement](/execution).
|
||||
|
||||
Les anciens blocs de démarrage restent disponibles pour les flux existants mais n'apparaissent plus dans les nouvelles versions.
|
||||
> Les déploiements alimentent chaque déclencheur. Mettez à jour le flux de travail, redéployez, et tous les points d'entrée des déclencheurs récupèrent le nouveau snapshot. En savoir plus dans [Exécution → Snapshots de déploiement](/execution).
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
---
|
||||
title: Déclencheur de formulaire d'entrée
|
||||
description: Déclencheur manuel avec un schéma d'entrée structuré
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Aperçu
|
||||
|
||||
Utilisez un déclencheur de formulaire d'entrée lorsqu'un flux de travail doit démarrer depuis l'éditeur avec des champs typés. Le panneau d'exécution affiche exactement les champs que vous définissez, ainsi le flux de travail reçoit toujours des données propres.
|
||||
|
||||
## Ce que vous définissez
|
||||
|
||||
Ajoutez des champs dans le constructeur de format d'entrée (texte, nombre, booléen, JSON, etc.). Pour chaque champ :
|
||||
|
||||
- La valeur apparaît comme `<blockName.field>` dans le flux de travail.
|
||||
- La charge utile complète est reflétée à `<blockName.input>` pour plus de commodité.
|
||||
|
||||
Si vous laissez le formulaire vide, le déclencheur n'a pas de sorties.
|
||||
|
||||
## Exécutions manuelles
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/input-form-panel-light.png'
|
||||
alt="Panneau d'exécution du formulaire d'entrée"
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
Lorsque vous appuyez sur Exécuter dans l'éditeur, le panneau affiche le formulaire. Les valeurs soumises alimentent directement la sortie du déclencheur, ainsi les blocs en aval peuvent y faire référence sans analyse supplémentaire. Les nombres sont convertis en nombres, les booléens deviennent vrai/faux, et les champs JSON sont analysés avant que le flux de travail ne les voie.
|
||||
|
||||
## Flux de travail enfants
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/workflow-input-mapping-light.png'
|
||||
alt='Mappage des entrées du flux de travail'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
Les déclencheurs de formulaire d'entrée alimentent également le bloc Flux de travail. Lorsque vous intégrez un flux de travail enfant, l'étape de mappage affiche les champs du formulaire enfant afin que vous puissiez connecter des variables depuis le parent. Tout ce que vous mappez devient la soumission du formulaire d'entrée du flux de travail enfant.
|
||||
|
||||
<Callout>
|
||||
Besoin d'un bouton d'exécution rapide sans champs ? Utilisez un déclencheur manuel. Choisissez le formulaire d'entrée lorsque vous voulez une validation et une structure prévisible.
|
||||
</Callout>
|
||||
@@ -1,41 +0,0 @@
|
||||
---
|
||||
title: Déclenchement manuel
|
||||
description: Exécuter un workflow à la demande sans entrées
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## Aperçu
|
||||
|
||||
Le déclencheur manuel ajoute un simple bouton Exécuter en haut de votre workflow. Utilisez-le lorsque vous souhaitez exécuter le workflow immédiatement sans collecter de données supplémentaires.
|
||||
|
||||
## Comment ça fonctionne
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/manual-run-light.png'
|
||||
alt="Bouton d'exécution du déclencheur manuel"
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
- Lance le workflow en utilisant l'instantané du déploiement actif
|
||||
- N'envoie aucune charge utile — les blocs en aval ne voient que ce qu'ils ont déjà configuré
|
||||
- Parfait pour des vérifications rapides, des tests de fumée ou des flux qui ne dépendent que de variables internes
|
||||
|
||||
## Quand l'utiliser
|
||||
|
||||
- Démarrer un workflow après avoir publié un nouveau déploiement pour confirmer que tout fonctionne toujours
|
||||
- Exécuter des tâches de maintenance qui ne nécessitent pas d'entrée externe
|
||||
- Déclencher des workflows enfants qui lisent uniquement l'état ou les variables d'environnement
|
||||
|
||||
## Comparé au formulaire d'entrée
|
||||
|
||||
Besoin de valeurs structurées ou de validation de type à l'exécution ? Passez plutôt à un déclencheur de formulaire d'entrée — le panneau d'exécution collectera ces champs avant le démarrage du workflow.
|
||||
|
||||
<Callout>
|
||||
Les exécutions de déclenchement manuel ne remplacent pas votre historique de déploiement. Mettez à jour et redéployez chaque fois que des modifications du canevas doivent être mises en production.
|
||||
</Callout>
|
||||
96
apps/docs/content/docs/fr/triggers/start.mdx
Normal file
96
apps/docs/content/docs/fr/triggers/start.mdx
Normal file
@@ -0,0 +1,96 @@
|
||||
---
|
||||
title: Démarrer
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Tab, Tabs } from 'fumadocs-ui/components/tabs'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
Le bloc Démarrer est le déclencheur par défaut pour les flux de travail créés dans Sim. Il collecte des entrées structurées et les distribue au reste de votre graphe pour les tests d'éditeur, les déploiements d'API et les expériences de chat.
|
||||
|
||||
<div className="flex justify-center">
|
||||
<Image
|
||||
src="/static/start.png"
|
||||
alt="Bloc de démarrage avec champs de format d'entrée"
|
||||
width={360}
|
||||
height={380}
|
||||
className="my-6"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Callout type="info">
|
||||
Le bloc Démarrer se trouve dans l'emplacement de départ lorsque vous créez un flux de travail. Gardez-le à cet endroit lorsque vous souhaitez que le même point d'entrée serve aux exécutions de l'éditeur, aux requêtes de déploiement d'API et aux sessions de chat. Remplacez-le par des déclencheurs Webhook ou Planification lorsque vous n'avez besoin que d'une exécution basée sur des événements.
|
||||
</Callout>
|
||||
|
||||
## Champs exposés par Démarrer
|
||||
|
||||
Le bloc Démarrer émet différentes données selon la surface d'exécution :
|
||||
|
||||
- **Champs de format d'entrée** — Chaque champ que vous ajoutez devient disponible comme <code><start.fieldName></code>. Par exemple, un champ `customerId` apparaît comme <code><start.customerId></code> dans les blocs et modèles en aval.
|
||||
- **Champs spécifiques au chat** — Lorsque le flux de travail s'exécute depuis le panneau latéral de chat ou une expérience de chat déployée, Sim fournit également <code><start.input></code> (dernier message de l'utilisateur), <code><start.conversationId></code> (ID de session active) et <code><start.files></code> (pièces jointes du chat).
|
||||
|
||||
Limitez les champs de format d'entrée aux noms que vous prévoyez de référencer ultérieurement — ces valeurs sont les seuls champs structurés partagés entre les exécutions de l'éditeur, de l'API et du chat.
|
||||
|
||||
## Configurer le format d'entrée
|
||||
|
||||
Utilisez le sous-bloc Format d'entrée pour définir le schéma qui s'applique à tous les modes d'exécution :
|
||||
|
||||
1. Ajoutez un champ pour chaque valeur que vous souhaitez collecter.
|
||||
2. Choisissez un type (`string`, `number`, `boolean`, `object`, `array`, ou `files`). Les champs de fichier acceptent les téléchargements depuis le chat et les appelants API.
|
||||
3. Fournissez des valeurs par défaut lorsque vous souhaitez que la fenêtre d'exécution manuelle remplisse automatiquement les données de test. Ces valeurs par défaut sont ignorées pour les exécutions déployées.
|
||||
4. Réorganisez les champs pour contrôler leur apparence dans le formulaire de l'éditeur.
|
||||
|
||||
Référencez les valeurs structurées en aval avec des expressions telles que <code><start.customerId></code> selon le bloc que vous connectez.
|
||||
|
||||
## Comment il se comporte selon le point d'entrée
|
||||
|
||||
<Tabs items={['Exécution dans l\'éditeur', 'Déploiement vers API', 'Déploiement vers chat']}>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
Lorsque vous cliquez sur <strong>Exécuter</strong> dans l'éditeur, le bloc Start affiche le format d'entrée sous forme de formulaire. Les valeurs par défaut facilitent les tests répétés sans avoir à retaper les données. La soumission du formulaire déclenche immédiatement le flux de travail et les valeurs deviennent disponibles sur <code><start.fieldName></code> (par exemple <code><start.sampleField></code>).
|
||||
</p>
|
||||
<p>
|
||||
Les champs de fichiers dans le formulaire sont directement téléchargés dans le{' '}
|
||||
<code><start.fieldName></code> correspondant ; utilisez ces valeurs pour alimenter
|
||||
les outils en aval ou les étapes de stockage.
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
Le déploiement vers l'API transforme le format d'entrée en un contrat JSON pour les clients. Chaque champ devient une partie du corps de la requête, et Sim convertit les types primitifs lors de l'ingestion. Les champs de fichiers attendent des objets qui référencent des fichiers téléchargés ; utilisez le point de terminaison de téléchargement de fichiers d'exécution avant d'invoquer le flux de travail.
|
||||
</p>
|
||||
<p>
|
||||
Les appelants de l'API peuvent inclure des propriétés optionnelles supplémentaires.
|
||||
Elles sont préservées dans les sorties <code><start.fieldName></code> pour que
|
||||
vous puissiez expérimenter sans avoir à redéployer immédiatement.
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
Dans les déploiements de chat, le bloc Start se lie à la conversation active. Le dernier message remplit <code><start.input></code>, l'identifiant de session est disponible à <code><start.conversationId></code>, et les pièces jointes de l'utilisateur apparaissent sur <code><start.files></code>, ainsi que tous les champs du format d'entrée définis comme <code><start.fieldName></code>.
|
||||
</p>
|
||||
<p>
|
||||
Si vous lancez le chat avec un contexte structuré supplémentaire (par exemple à partir
|
||||
d'une intégration), il fusionne dans les sorties <code><start.fieldName></code>
|
||||
correspondantes, gardant les blocs en aval cohérents avec l'API et les exécutions manuelles.
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## Référencement des données Start en aval
|
||||
|
||||
- Connectez <code><start.fieldName></code> directement aux agents, outils ou fonctions qui attendent des charges utiles structurées.
|
||||
- Utilisez la syntaxe de modèle comme <code><start.sampleField></code> ou <code><start.files[0].url></code> (chat uniquement) dans les champs de prompt.
|
||||
- Gardez <code><start.conversationId></code> à portée de main lorsque vous devez regrouper des sorties, mettre à jour l'historique de conversation ou rappeler l'API de chat.
|
||||
|
||||
## Bonnes pratiques
|
||||
|
||||
- Considérez le bloc Start comme le point d'entrée unique lorsque vous souhaitez prendre en charge à la fois les appelants API et chat.
|
||||
- Préférez les champs de format d'entrée nommés plutôt que d'analyser du JSON brut dans les nœuds en aval ; la conversion de type se fait automatiquement.
|
||||
- Ajoutez une validation ou un routage immédiatement après Start si certains champs sont nécessaires pour que votre flux de travail réussisse.
|
||||
@@ -1,67 +0,0 @@
|
||||
---
|
||||
title: Starter (Obsolète)
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Tab, Tabs } from 'fumadocs-ui/components/tabs'
|
||||
import { Image } from '@/components/ui/image'
|
||||
import { Video } from '@/components/ui/video'
|
||||
|
||||
<Callout type="warning">
|
||||
Le bloc Starter est obsolète et a été remplacé par des déclencheurs Core plus spécialisés. Veuillez consulter la [documentation des déclencheurs Core](/triggers) pour les nouveaux déclencheurs API, Chat, Formulaire d'entrée, Manuel, Planification et Webhook.
|
||||
</Callout>
|
||||
|
||||
Le bloc Starter vous permet de lancer manuellement l'exécution d'un flux de travail avec des paramètres d'entrée, offrant deux modes d'entrée : des paramètres structurés ou une conversation par chat.
|
||||
|
||||
<div className="flex justify-center">
|
||||
<Image
|
||||
src="/static/starter.png"
|
||||
alt="Bloc Starter avec options de mode manuel et chat"
|
||||
width={500}
|
||||
height={400}
|
||||
className="my-6"
|
||||
/>
|
||||
</div>
|
||||
|
||||
## Modes d'exécution
|
||||
|
||||
Choisissez votre méthode d'entrée dans le menu déroulant :
|
||||
|
||||
<Tabs items={['Mode manuel', 'Mode chat']}>
|
||||
<Tab>
|
||||
<div className="space-y-4">
|
||||
<ul className="list-disc space-y-1 pl-6">
|
||||
<li><strong>Entrées structurées compatibles API</strong> : définissez des paramètres spécifiques (texte, nombre, booléen, JSON, fichier, date)</li>
|
||||
<li><strong>Test pendant la construction de votre flux de travail</strong> : itération rapide lors du débogage des flux de travail</li>
|
||||
</ul>
|
||||
|
||||
<div className="mx-auto w-full overflow-hidden rounded-lg">
|
||||
<Video src="input-format.mp4" width={700} height={450} />
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-gray-600">Configurez les paramètres d'entrée qui seront disponibles lors du déploiement en tant que point de terminaison API.</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-4">
|
||||
<ul className="list-disc space-y-1 pl-6">
|
||||
<li><strong>Langage naturel</strong> : les utilisateurs tapent des questions ou des demandes</li>
|
||||
<li><strong>Conversationnel</strong> : idéal pour les flux de travail alimentés par l'IA</li>
|
||||
</ul>
|
||||
|
||||
<div className="mx-auto w-full overflow-hidden rounded-lg">
|
||||
<Video src="chat-input.mp4" width={700} height={450} />
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-gray-600">Discutez avec votre flux de travail et accédez au texte saisi, à l'identifiant de conversation et aux fichiers téléchargés pour des réponses contextuelles.</p>
|
||||
</div>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## Utilisation des variables de chat
|
||||
|
||||
En mode Chat, accédez aux entrées utilisateur et au contexte de conversation via des variables spéciales :
|
||||
|
||||
- **`<start.input>`** - Contient le texte du message de l'utilisateur
|
||||
- **`<start.conversationId>`** - Identifiant unique pour le fil de conversation
|
||||
- **`<start.files>`** - Tableau des fichiers téléchargés par l'utilisateur (le cas échéant)
|
||||
@@ -1,357 +0,0 @@
|
||||
---
|
||||
title: Schéma YAML du bloc Loop
|
||||
description: Référence de configuration YAML pour les blocs Loop
|
||||
---
|
||||
|
||||
## Définition du schéma
|
||||
|
||||
```yaml
|
||||
type: object
|
||||
required:
|
||||
- type
|
||||
- name
|
||||
- connections
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
enum: [loop]
|
||||
description: Block type identifier
|
||||
name:
|
||||
type: string
|
||||
description: Display name for this loop block
|
||||
inputs:
|
||||
type: object
|
||||
description: Optional. If omitted, defaults will be applied.
|
||||
properties:
|
||||
loopType:
|
||||
type: string
|
||||
enum: [for, forEach]
|
||||
description: Type of loop to execute
|
||||
default: for
|
||||
iterations:
|
||||
type: number
|
||||
description: Number of iterations (for 'for' loops)
|
||||
default: 5
|
||||
minimum: 1
|
||||
maximum: 1000
|
||||
collection:
|
||||
type: string
|
||||
description: Collection to iterate over (for 'forEach' loops)
|
||||
default: ""
|
||||
maxConcurrency:
|
||||
type: number
|
||||
description: Maximum concurrent executions
|
||||
default: 1
|
||||
minimum: 1
|
||||
maximum: 10
|
||||
connections:
|
||||
type: object
|
||||
properties:
|
||||
# Nested format (recommended)
|
||||
loop:
|
||||
type: object
|
||||
properties:
|
||||
start:
|
||||
type: string
|
||||
description: Target block ID to execute inside the loop
|
||||
end:
|
||||
type: string
|
||||
description: Target block ID for loop completion (optional)
|
||||
# Direct handle format (alternative)
|
||||
loop-start-source:
|
||||
type: string | string[]
|
||||
description: Target block ID to execute inside the loop (direct format)
|
||||
loop-end-source:
|
||||
type: string | string[]
|
||||
description: Target block ID for loop completion (direct format, optional)
|
||||
error:
|
||||
type: string
|
||||
description: Target block ID for error handling
|
||||
note: Use either the nested 'loop' format OR the direct 'loop-start-source' format, not both
|
||||
```
|
||||
|
||||
## Configuration de connexion
|
||||
|
||||
Les blocs de boucle prennent en charge deux formats de connexion :
|
||||
|
||||
### Format de gestion directe (alternative)
|
||||
|
||||
```yaml
|
||||
connections:
|
||||
loop-start-source: <string> # Target block ID to execute inside the loop
|
||||
loop-end-source: <string> # Target block ID after loop completion (optional)
|
||||
error: <string> # Target block ID for error handling (optional)
|
||||
```
|
||||
|
||||
Les deux formats fonctionnent de manière identique. Utilisez celui que vous préférez.
|
||||
|
||||
## Configuration des blocs enfants
|
||||
|
||||
Les blocs à l'intérieur d'une boucle doivent avoir leur `parentId` défini sur l'ID du bloc de boucle. La propriété `extent` est automatiquement définie sur `'parent'` et n'a pas besoin d'être spécifiée :
|
||||
|
||||
```yaml
|
||||
loop-1:
|
||||
type: loop
|
||||
name: "Process Items"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.items>
|
||||
connections:
|
||||
loop:
|
||||
start: process-item
|
||||
end: final-results
|
||||
|
||||
# Child block inside the loop
|
||||
process-item:
|
||||
type: agent
|
||||
name: "Process Item"
|
||||
parentId: loop-1 # References the loop block
|
||||
inputs:
|
||||
systemPrompt: "Process this item"
|
||||
userPrompt: <loop.currentItem>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
## Exemples
|
||||
|
||||
### Boucle For (itérations fixes)
|
||||
|
||||
```yaml
|
||||
countdown-loop:
|
||||
type: loop
|
||||
name: "Countdown Loop"
|
||||
inputs:
|
||||
loopType: for
|
||||
iterations: 5
|
||||
connections:
|
||||
loop:
|
||||
start: countdown-agent
|
||||
end: countdown-complete
|
||||
|
||||
countdown-agent:
|
||||
type: agent
|
||||
name: "Countdown Agent"
|
||||
parentId: countdown-loop
|
||||
inputs:
|
||||
systemPrompt: "Generate a countdown message"
|
||||
userPrompt: "Count down from 5. Current number: <loop.index>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### Boucle ForEach (traitement de collection)
|
||||
|
||||
```yaml
|
||||
email-processor-loop:
|
||||
type: loop
|
||||
name: "Email Processor Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.emails>
|
||||
connections:
|
||||
loop:
|
||||
start: process-single-email
|
||||
end: all-emails-processed
|
||||
|
||||
process-single-email:
|
||||
type: agent
|
||||
name: "Process Single Email"
|
||||
parentId: email-processor-loop
|
||||
inputs:
|
||||
systemPrompt: "Classify and respond to this email"
|
||||
userPrompt: "Email content: <loop.currentItem>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### Boucle avec plusieurs blocs enfants
|
||||
|
||||
```yaml
|
||||
data-analysis-loop:
|
||||
type: loop
|
||||
name: "Data Analysis Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <data-fetcher.records>
|
||||
maxConcurrency: 3
|
||||
connections:
|
||||
loop:
|
||||
start: validate-record
|
||||
end: generate-report
|
||||
error: handle-loop-error
|
||||
|
||||
validate-record:
|
||||
type: function
|
||||
name: "Validate Record"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
code: |
|
||||
const record = <loop.currentItem>;
|
||||
const index = <loop.index>;
|
||||
|
||||
// Validate the record
|
||||
if (!record.id || !record.data) {
|
||||
throw new Error(`Invalid record at index ${index}`);
|
||||
}
|
||||
|
||||
return {
|
||||
valid: true,
|
||||
recordId: record.id,
|
||||
processedAt: new Date().toISOString()
|
||||
};
|
||||
connections:
|
||||
success: analyze-record
|
||||
error: record-error
|
||||
|
||||
analyze-record:
|
||||
type: agent
|
||||
name: "Analyze Record"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
systemPrompt: "Analyze this data record and extract insights"
|
||||
userPrompt: |
|
||||
Record ID: <validaterecord.recordId>
|
||||
Data: <loop.currentItem.data>
|
||||
Position in collection: <loop.index>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
connections:
|
||||
success: store-analysis
|
||||
|
||||
store-analysis:
|
||||
type: function
|
||||
name: "Store Analysis"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
code: |
|
||||
const analysis = <analyzerecord.content>;
|
||||
const recordId = <validaterecord.recordId>;
|
||||
|
||||
// Store analysis result
|
||||
return {
|
||||
recordId,
|
||||
analysis,
|
||||
completedAt: new Date().toISOString()
|
||||
};
|
||||
```
|
||||
|
||||
### Boucle de traitement concurrent
|
||||
|
||||
```yaml
|
||||
parallel-processing-loop:
|
||||
type: loop
|
||||
name: "Parallel Processing Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.tasks>
|
||||
maxConcurrency: 5
|
||||
connections:
|
||||
loop:
|
||||
start: process-task
|
||||
end: aggregate-results
|
||||
|
||||
process-task:
|
||||
type: api
|
||||
name: "Process Task"
|
||||
parentId: parallel-processing-loop
|
||||
inputs:
|
||||
url: "https://api.example.com/process"
|
||||
method: POST
|
||||
headers:
|
||||
- key: "Authorization"
|
||||
value: "Bearer {{API_TOKEN}}"
|
||||
body: |
|
||||
{
|
||||
"taskId": "<loop.currentItem.id>",
|
||||
"data": "<loop.currentItem.data>"
|
||||
}
|
||||
connections:
|
||||
success: task-completed
|
||||
```
|
||||
|
||||
### Exemple de format de gestion directe
|
||||
|
||||
La même boucle peut être écrite en utilisant le format de gestion directe :
|
||||
|
||||
```yaml
|
||||
my-loop:
|
||||
type: loop
|
||||
name: "Process Items"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.items>
|
||||
connections:
|
||||
loop-start-source: process-item # Direct handle format
|
||||
loop-end-source: final-results # Direct handle format
|
||||
error: handle-error
|
||||
|
||||
process-item:
|
||||
type: agent
|
||||
name: "Process Item"
|
||||
parentId: my-loop
|
||||
inputs:
|
||||
systemPrompt: "Process this item"
|
||||
userPrompt: <loop.currentItem>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### Exemple de boucle minimale (utilisant les valeurs par défaut)
|
||||
|
||||
Vous pouvez omettre entièrement la section `inputs`, et les valeurs par défaut seront appliquées :
|
||||
|
||||
```yaml
|
||||
simple-loop:
|
||||
type: loop
|
||||
name: "Simple Loop"
|
||||
# No inputs section - defaults to loopType: 'for', iterations: 5
|
||||
connections:
|
||||
loop-start-source: process-step
|
||||
loop-end-source: complete
|
||||
|
||||
process-step:
|
||||
type: agent
|
||||
name: "Process Step"
|
||||
parentId: simple-loop
|
||||
inputs:
|
||||
systemPrompt: "Execute step"
|
||||
userPrompt: "Step <loop.index>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
Cette boucle exécutera 5 itérations par défaut.
|
||||
|
||||
## Variables de boucle
|
||||
|
||||
À l'intérieur des blocs enfants de boucle, ces variables spéciales sont disponibles :
|
||||
|
||||
```yaml
|
||||
# Available in all child blocks of the loop
|
||||
<loop.index> # Current iteration number (0-based)
|
||||
<loop.currentItem> # Current item being processed (forEach loops)
|
||||
<loop.items> # Full collection (forEach loops)
|
||||
```
|
||||
|
||||
## Références de sortie
|
||||
|
||||
Une fois qu'une boucle est terminée, vous pouvez référencer ses résultats agrégés :
|
||||
|
||||
```yaml
|
||||
# In blocks after the loop
|
||||
final-processor:
|
||||
inputs:
|
||||
all-results: <loop-name.results> # Array of all iteration results
|
||||
total-count: <loop-name.count> # Number of iterations completed
|
||||
```
|
||||
|
||||
## Bonnes pratiques
|
||||
|
||||
- Définir des limites d'itération raisonnables pour éviter des temps d'exécution longs
|
||||
- Utiliser forEach pour le traitement des collections, les boucles for pour les itérations fixes
|
||||
- Envisager d'utiliser maxConcurrency pour les opérations limitées par les E/S
|
||||
- Inclure la gestion des erreurs pour une exécution robuste des boucles
|
||||
- Utiliser des noms descriptifs pour les blocs enfants de boucle
|
||||
- Tester d'abord avec de petites collections
|
||||
- Surveiller le temps d'exécution pour les grandes collections
|
||||
@@ -1,187 +0,0 @@
|
||||
---
|
||||
title: API トリガー
|
||||
description: 認証済みHTTPリクエストからワークフローを開始する
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## 概要
|
||||
|
||||
APIトリガーは、ワークフローを安全なHTTPエンドポイントとして公開します。JSONデータをエンドポイントに送信すると、ワークフローがすぐにそれを処理します。API呼び出しは常に最新のデプロイメントに対して実行されます。
|
||||
|
||||
## 入力フォーマットの設定
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/api-trigger-light.png'
|
||||
alt='APIトリガー入力フォーマット'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
各パラメータに**入力フォーマット**フィールドを追加します。実行時の出力キーはスキーマを反映し、`<api.input>`でも利用できます。
|
||||
|
||||
エディタでの手動実行は `value` 列を使用するため、リクエストを送信せずにテストできます。実行中、リゾルバーは `<api.userId>` と `<api.input.userId>` の両方に値を設定します。
|
||||
|
||||
## リクエスト例
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{"userId":"demo-user","maxTokens":1024}'
|
||||
```
|
||||
|
||||
成功したレスポンスはエグゼキュータからシリアル化された実行結果を返します。エラーは検証、認証、またはワークフローの失敗を表示します。
|
||||
|
||||
## ストリーミングレスポンス
|
||||
|
||||
リアルタイムストリーミングを有効にすると、ワークフローの出力が生成されるたびに文字単位で受信できます。これはAIの応答をユーザーに段階的に表示するのに役立ちます。
|
||||
|
||||
### リクエストパラメータ
|
||||
|
||||
ストリーミングを有効にするには、これらのパラメータを追加してください:
|
||||
|
||||
- `stream` - Server-Sent Events (SSE)ストリーミングを有効にするには `true` に設定します
|
||||
- `selectedOutputs` - ストリーミングするブロック出力の配列(例:`["agent1.content"]`)
|
||||
|
||||
### ブロック出力フォーマット
|
||||
|
||||
`blockName.attribute` フォーマットを使用して、ストリーミングするブロック出力を指定します:
|
||||
- フォーマット:`"blockName.attribute"`(例:Agent 1ブロックの内容をストリーミングしたい場合は、`"agent1.content"` を使用します)
|
||||
- ブロック名は大文字小文字を区別せず、スペースは無視されます
|
||||
|
||||
### リクエスト例
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{
|
||||
"message": "Count to five",
|
||||
"stream": true,
|
||||
"selectedOutputs": ["agent1.content"]
|
||||
}'
|
||||
```
|
||||
|
||||
### レスポンスフォーマット
|
||||
|
||||
ストリーミングレスポンスはServer-Sent Events (SSE)フォーマットを使用します:
|
||||
|
||||
```
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"}
|
||||
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"}
|
||||
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", three"}
|
||||
|
||||
data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}}
|
||||
|
||||
data: [DONE]
|
||||
```
|
||||
|
||||
各イベントには以下が含まれます:
|
||||
- **ストリーミングチャンク**:`{"blockId": "...", "chunk": "text"}` - 生成されるリアルタイムテキスト
|
||||
- **最終イベント**:`{"event": "done", ...}` - 実行メタデータと完全な結果
|
||||
- **ターミネーター**:`[DONE]` - ストリーム終了を示す信号
|
||||
|
||||
### 複数ブロックのストリーミング
|
||||
|
||||
`selectedOutputs` に複数のブロックが含まれる場合、各チャンクはどのブロックから生成されたかを示します:
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{
|
||||
"message": "Process this request",
|
||||
"stream": true,
|
||||
"selectedOutputs": ["agent1.content", "agent2.content"]
|
||||
}'
|
||||
```
|
||||
|
||||
各チャンクの `blockId` フィールドを使用して、出力を正しいUI要素にルーティングできます:
|
||||
|
||||
```
|
||||
data: {"blockId":"agent1-uuid","chunk":"Processing..."}
|
||||
|
||||
data: {"blockId":"agent2-uuid","chunk":"Analyzing..."}
|
||||
|
||||
data: {"blockId":"agent1-uuid","chunk":" complete"}
|
||||
```
|
||||
|
||||
## 出力リファレンス
|
||||
|
||||
| リファレンス | 説明 |
|
||||
|-----------|-------------|
|
||||
| `<api.field>` | 入力フォーマットで定義されたフィールド |
|
||||
| `<api.input>` | 構造化されたリクエスト本文全体 |
|
||||
|
||||
入力フォーマットが定義されていない場合、エグゼキューターは `<api.input>` でのみ生のJSONを公開します。
|
||||
|
||||
<Callout type="warning">
|
||||
ワークフローには1つのAPIトリガーのみ含めることができます。変更後は新しいデプロイメントを公開して、エンドポイントを最新の状態に保ってください。
|
||||
</Callout>
|
||||
|
||||
### ファイルアップロードフォーマット
|
||||
|
||||
APIは2つのフォーマットでファイルを受け付けます:
|
||||
|
||||
**1. Base64エンコードされたファイル**(SDKでの使用推奨):
|
||||
|
||||
```json
|
||||
{
|
||||
"documents": [{
|
||||
"type": "file",
|
||||
"data": "data:application/pdf;base64,JVBERi0xLjQK...",
|
||||
"name": "document.pdf",
|
||||
"mime": "application/pdf"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
- 最大ファイルサイズ:ファイルあたり20MB
|
||||
- ファイルはクラウドストレージにアップロードされ、すべてのプロパティを持つUserFileオブジェクトに変換されます
|
||||
|
||||
**2. 直接URLリファレンス**:
|
||||
|
||||
```json
|
||||
{
|
||||
"documents": [{
|
||||
"type": "url",
|
||||
"data": "https://example.com/document.pdf",
|
||||
"name": "document.pdf",
|
||||
"mime": "application/pdf"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
- ファイルはアップロードされず、URLが直接渡されます
|
||||
- 既存のファイルを参照する場合に便利です
|
||||
|
||||
### ファイルプロパティ
|
||||
|
||||
ファイルについては、すべてのプロパティにアクセスできます:
|
||||
|
||||
| プロパティ | 説明 | 型 |
|
||||
|----------|-------------|------|
|
||||
| `<api.fieldName[0].url>` | 署名付きダウンロードURL | string |
|
||||
| `<api.fieldName[0].name>` | 元のファイル名 | string |
|
||||
| `<api.fieldName[0].size>` | ファイルサイズ(バイト) | number |
|
||||
| `<api.fieldName[0].type>` | MIMEタイプ | string |
|
||||
| `<api.fieldName[0].uploadedAt>` | アップロードタイムスタンプ(ISO 8601) | string |
|
||||
| `<api.fieldName[0].expiresAt>` | URL有効期限タイムスタンプ(ISO 8601) | string |
|
||||
|
||||
URL参照ファイルの場合、ファイルは当社のストレージにアップロードされないため、`uploadedAt`と`expiresAt`を除く同じプロパティが利用可能です。
|
||||
|
||||
入力フォーマットが定義されていない場合、エグゼキューターは`<api.input>`でのみ生のJSONを公開します。
|
||||
|
||||
<Callout type="warning">
|
||||
ワークフローには1つのAPIトリガーしか含めることができません。変更後は新しいデプロイメントを公開して、エンドポイントを最新の状態に保ってください。
|
||||
</Callout>
|
||||
@@ -1,51 +0,0 @@
|
||||
---
|
||||
title: チャットトリガー
|
||||
description: チャットデプロイメントからワークフローを開始する
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## 概要
|
||||
|
||||
チャットトリガーはワークフロー用の会話インターフェースを作成します。ワークフローをチャットとしてデプロイすると、ユーザーは共有可能なURLを通じてそれと対話できます。各メッセージは最新のデプロイメントを使用して新しいワークフロー実行を開始します。
|
||||
|
||||
## ランタイム出力
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/chat-trigger-light.png'
|
||||
alt='チャットデプロイメントの会話'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
このトリガーは、下流のブロックが参照できる3つのフィールドを書き込みます:
|
||||
|
||||
| 参照 | 説明 |
|
||||
|-----------|-------------|
|
||||
| `<chat.input>` | 最新のユーザーメッセージ |
|
||||
| `<chat.conversationId>` | 会話スレッドID |
|
||||
| `<chat.files>` | オプションのアップロードファイル |
|
||||
|
||||
ファイルには `name`、`mimeType`、および署名付きダウンロード `url` が含まれます。
|
||||
|
||||
## 使用上の注意
|
||||
|
||||
1. ワークフローごとにチャットトリガーブロックを1つ追加します。
|
||||
2. ワークフローをチャットモードでデプロイします。
|
||||
3. デプロイメントリンクを共有します—各返信は同じ会話IDを再利用するため、ワークフローはコンテキストを保持できます。
|
||||
|
||||
<Callout type="info">
|
||||
ビルダーは同じワークフロー内の複数のチャットトリガーブロックをブロックします。
|
||||
</Callout>
|
||||
|
||||
1. ワークフローごとに1つのチャットトリガーブロックを追加します。
|
||||
2. チャットモードでワークフローをデプロイします。
|
||||
3. デプロイメントリンクを共有します—すべての返信は同じ会話IDを再利用するため、ワークフローはコンテキストを保持できます。
|
||||
|
||||
<Callout type="info">
|
||||
ビルダーは同じワークフロー内に複数のチャットトリガーブロックを配置することを防止します。
|
||||
</Callout>
|
||||
@@ -7,46 +7,34 @@ import { Card, Cards } from 'fumadocs-ui/components/card'
|
||||
|
||||
## 主要なトリガー
|
||||
|
||||
ワークフローごとに1つのトリガーを選択して、開始方法を定義します:
|
||||
エディタから始まるすべてのもの、APIへのデプロイ、またはチャットへのデプロイエクスペリエンスにはStartブロックを使用してください。イベント駆動型ワークフローには他のトリガーも引き続き利用可能です:
|
||||
|
||||
<Cards>
|
||||
<Card title="API" href="/triggers/api">
|
||||
JSONボディをワークフロー入力にマッピングするHTTPエンドポイント
|
||||
</Card>
|
||||
<Card title="チャット" href="/triggers/chat">
|
||||
ストリーミングレスポンスを備えたデプロイ済みチャットインターフェース
|
||||
</Card>
|
||||
<Card title="入力フォーム" href="/triggers/input-form">
|
||||
エディタ実行と子ワークフローで使用される型付き手動入力
|
||||
</Card>
|
||||
<Card title="手動" href="/triggers/manual">
|
||||
追加データなしのオンデマンド実行
|
||||
</Card>
|
||||
<Card title="スケジュール" href="/triggers/schedule">
|
||||
Cronまたは間隔ベースの実行
|
||||
<Card title="Start" href="/triggers/start">
|
||||
エディタ実行、APIデプロイメント、チャットデプロイメントをサポートする統合エントリーポイント
|
||||
</Card>
|
||||
<Card title="Webhook" href="/triggers/webhook">
|
||||
外部のWebhookペイロードを受信
|
||||
</Card>
|
||||
<Card title="Schedule" href="/triggers/schedule">
|
||||
Cronまたは間隔ベースの実行
|
||||
</Card>
|
||||
</Cards>
|
||||
|
||||
## クイック比較
|
||||
|
||||
| トリガー | 開始条件 |
|
||||
|---------|-----------------|
|
||||
| **API** | 認証されたHTTP POST |
|
||||
| **チャット** | チャットデプロイメントメッセージ |
|
||||
| **入力フォーム** | エディタまたは親ワークフローでの手動送信時 |
|
||||
| **手動** | エディタの実行ボタン |
|
||||
| **スケジュール** | スケジュールモーダルで管理されるタイマー |
|
||||
| **Webhook** | 受信HTTPリクエスト時 |
|
||||
| **Start** | エディタ実行、APIへのデプロイリクエスト、またはチャットメッセージ |
|
||||
| **Schedule** | スケジュールモーダルで管理されるタイマー |
|
||||
| **Webhook** | インバウンドHTTPリクエスト時 |
|
||||
|
||||
> Startブロックは常に `input`、`conversationId`、および `files` フィールドを公開します。追加の構造化データには、入力フォーマットにカスタムフィールドを追加してください。
|
||||
|
||||
## トリガーの使用方法
|
||||
|
||||
1. トリガーブロックを開始スロットにドロップします。
|
||||
2. 必要なスキーマや認証を設定します。
|
||||
1. Startブロックを開始スロットに配置します(またはWebhook/Scheduleなどの代替トリガーを使用)。
|
||||
2. 必要なスキーマまたは認証を設定します。
|
||||
3. ブロックをワークフローの残りの部分に接続します。
|
||||
|
||||
> デプロイメントはすべてのトリガーを動作させます。ワークフローを更新し、再デプロイすると、すべてのトリガーエントリーポイントが新しいスナップショットを取得します。詳細は[実行 → デプロイメントスナップショット](/execution)をご覧ください。
|
||||
|
||||
既存のフロー用にレガシースタータブロックは残っていますが、新しいビルドには表示されなくなりました。
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
---
|
||||
title: 入力フォームトリガー
|
||||
description: 構造化された入力スキーマを持つ手動トリガー
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## 概要
|
||||
|
||||
ワークフローがエディターから型付きフィールドで開始される必要がある場合は、入力フォームトリガーを使用します。実行パネルには定義したフィールドが正確に表示されるため、ワークフローは常にクリーンなデータを受け取ります。
|
||||
|
||||
## 定義するもの
|
||||
|
||||
入力フォーマットビルダーにフィールド(テキスト、数値、ブール値、JSONなど)を追加します。各フィールドについて:
|
||||
|
||||
- 値はワークフロー内で `<blockName.field>` として表示されます。
|
||||
- 完全なペイロードは便宜上 `<blockName.input>` にミラーリングされます。
|
||||
|
||||
フォームを空のままにすると、トリガーは出力を持ちません。
|
||||
|
||||
## 手動実行
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/input-form-panel-light.png'
|
||||
alt='入力フォーム実行パネル'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
エディターで実行ボタンを押すと、パネルにフォームがレンダリングされます。送信された値はトリガー出力に直接送られるため、下流のブロックは追加の解析なしにそれらを参照できます。数値は数値型に変換され、ブール値はtrue/falseになり、JSONフィールドはワークフローが処理する前に解析されます。
|
||||
|
||||
## 子ワークフロー
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/workflow-input-mapping-light.png'
|
||||
alt='ワークフロー入力マッピング'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
入力フォームトリガーはワークフローブロックも強化します。子ワークフローを埋め込むと、マッピングステップで子フォームフィールドが表示され、親から変数を接続できます。マッピングしたものは子ワークフローの入力フォーム送信になります。
|
||||
|
||||
<Callout>
|
||||
フィールドのない簡単な実行ボタンが必要ですか?手動トリガーを使用してください。検証と予測可能な構造が必要な場合は、入力フォームを選択してください。
|
||||
</Callout>
|
||||
@@ -1,41 +0,0 @@
|
||||
---
|
||||
title: 手動トリガー
|
||||
description: 入力なしでオンデマンドでワークフローを実行する
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## 概要
|
||||
|
||||
手動トリガーはワークフローの上部に単純な実行ボタンを追加します。追加データを収集せずにワークフローをすぐに実行したい場合に使用します。
|
||||
|
||||
## 仕組み
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/manual-run-light.png'
|
||||
alt='手動トリガー実行ボタン'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
- アクティブなデプロイメントスナップショットを使用してワークフローを起動します
|
||||
- ペイロードを送信しません—下流のブロックは既に設定されているものだけを参照します
|
||||
- 簡単な動作確認、スモークテスト、または内部変数のみに依存するフローに最適です
|
||||
|
||||
## 使用するタイミング
|
||||
|
||||
- 新しいデプロイメントを公開した後、すべてがまだ正常に動作することを確認するためにワークフローを開始する
|
||||
- 外部入力を必要としないメンテナンスジョブを実行する
|
||||
- 状態や環境変数のみを読み取る子ワークフローをトリガーする
|
||||
|
||||
## 入力フォームとの比較
|
||||
|
||||
実行時に構造化された値や型の検証が必要ですか?代わりに入力フォームトリガーに切り替えると、実行パネルはワークフローが開始する前にそれらのフィールドを収集します。
|
||||
|
||||
<Callout>
|
||||
手動トリガーの実行はデプロイメント履歴を上書きしません。キャンバスの変更を反映させるには、更新して再デプロイしてください。
|
||||
</Callout>
|
||||
90
apps/docs/content/docs/ja/triggers/start.mdx
Normal file
90
apps/docs/content/docs/ja/triggers/start.mdx
Normal file
@@ -0,0 +1,90 @@
|
||||
---
|
||||
title: スタート
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Tab, Tabs } from 'fumadocs-ui/components/tabs'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
スタートブロックは、Simで構築されたワークフローのデフォルトトリガーです。構造化された入力を収集し、エディターテスト、APIデプロイメント、チャット体験のためにグラフの残りの部分に分岐します。
|
||||
|
||||
<div className="flex justify-center">
|
||||
<Image
|
||||
src="/static/start.png"
|
||||
alt="入力フォーマットフィールドを持つスタートブロック"
|
||||
width={360}
|
||||
height={380}
|
||||
className="my-6"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Callout type="info">
|
||||
スタートブロックは、ワークフローを作成するときに開始スロットに配置されます。エディター実行、APIへのデプロイリクエスト、チャットセッションに同じエントリーポイントを提供したい場合は、そのままにしておきます。イベント駆動の実行のみが必要な場合は、WebhookまたはScheduleトリガーと交換してください。
|
||||
</Callout>
|
||||
|
||||
## スタートによって公開されるフィールド
|
||||
|
||||
スタートブロックは、実行環境に応じて異なるデータを出力します:
|
||||
|
||||
- **入力フォーマットフィールド** — 追加した各フィールドは <code><start.fieldName></code> として利用可能になります。例えば、`customerId` フィールドは、下流のブロックとテンプレートで <code><start.customerId></code> として表示されます。
|
||||
- **チャット専用フィールド** — ワークフローがチャットサイドパネルまたはデプロイされたチャット体験から実行される場合、Simは <code><start.input></code>(最新のユーザーメッセージ)、<code><start.conversationId></code>(アクティブなセッションID)、および <code><start.files></code>(チャットの添付ファイル)も提供します。
|
||||
|
||||
入力フォーマットフィールドは、後で参照する予定の名前に限定してください—これらの値は、エディター、API、およびチャット実行間で共有される唯一の構造化フィールドです。
|
||||
|
||||
## 入力フォーマットの設定
|
||||
|
||||
入力フォーマットのサブブロックを使用して、実行モード全体に適用されるスキーマを定義します:
|
||||
|
||||
1. 収集したい各値のフィールドを追加します。
|
||||
2. タイプを選択します(`string`、`number`、`boolean`、`object`、`array`、または `files`)。ファイルフィールドは、チャットとAPIの呼び出し元からのアップロードを受け付けます。
|
||||
3. 手動実行モーダルにテストデータを自動的に入力させたい場合は、デフォルト値を提供します。これらのデフォルト値はデプロイされた実行では無視されます。
|
||||
4. フィールドを並べ替えて、エディターフォームでの表示方法を制御します。
|
||||
|
||||
接続するブロックに応じて、<code><start.customerId></code>のような式を使用して、下流の構造化された値を参照できます。
|
||||
|
||||
## エントリーポイントごとの動作
|
||||
|
||||
<Tabs items={['エディタ実行', 'APIにデプロイ', 'チャットにデプロイ']}>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
エディタで<strong>実行</strong>をクリックすると、スタートブロックは入力フォーマットをフォームとしてレンダリングします。デフォルト値により、データを再入力せずに簡単に再テストできます。フォームを送信するとワークフローが即座にトリガーされ、値は<code><start.fieldName></code>(例えば<code><start.sampleField></code>)で利用可能になります。
|
||||
</p>
|
||||
<p>
|
||||
フォーム内のファイルフィールドは対応する<code><start.fieldName></code>に直接アップロードされます。これらの値を使用して、下流のツールやストレージステップにデータを供給します。
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
APIにデプロイすると、入力フォーマットはクライアント向けのJSON契約に変換されます。各フィールドはリクエストボディの一部となり、Simは取り込み時にプリミティブ型を強制変換します。ファイルフィールドはアップロードされたファイルを参照するオブジェクトを想定しています。ワークフローを呼び出す前に、実行ファイルアップロードエンドポイントを使用してください。
|
||||
</p>
|
||||
<p>
|
||||
API呼び出し元は追加のオプションプロパティを含めることができます。これらは<code><start.fieldName></code>出力内に保持されるため、すぐに再デプロイせずに実験できます。
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
チャットデプロイメントでは、スタートブロックはアクティブな会話にバインドされます。最新のメッセージは<code><start.input></code>に入力され、セッション識別子は<code><start.conversationId></code>で利用可能になり、ユーザーの添付ファイルは<code><start.files></code>に表示されます。また、<code><start.fieldName></code>としてスコープされた入力フォーマットフィールドも同様です。
|
||||
</p>
|
||||
<p>
|
||||
追加の構造化されたコンテキスト(例えば埋め込みから)でチャットを起動すると、それは対応する<code><start.fieldName></code>出力にマージされ、下流のブロックがAPIや手動実行と一貫性を保ちます。
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## 下流でのStart(開始)データの参照
|
||||
|
||||
- <code><start.fieldName></code>を構造化されたペイロードを期待するエージェント、ツール、または関数に直接接続します。
|
||||
- プロンプトフィールドで<code><start.sampleField></code>や<code><start.files[0].url></code>(チャットのみ)などのテンプレート構文を使用します。
|
||||
- 出力のグループ化、会話履歴の更新、またはチャットAPIへのコールバックが必要な場合は、<code><start.conversationId></code>を手元に置いておきます。
|
||||
|
||||
## ベストプラクティス
|
||||
|
||||
- APIとチャットの両方の呼び出し元をサポートしたい場合は、Startブロックを単一のエントリーポイントとして扱います。
|
||||
- 下流のノードで生のJSONを解析するよりも、名前付き入力フォーマットフィールドを優先します。型の強制変換は自動的に行われます。
|
||||
- ワークフローが成功するために特定のフィールドが必要な場合は、Startの直後に検証またはルーティングを追加します。
|
||||
@@ -1,67 +0,0 @@
|
||||
---
|
||||
title: スターター(非推奨)
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Tab, Tabs } from 'fumadocs-ui/components/tabs'
|
||||
import { Image } from '@/components/ui/image'
|
||||
import { Video } from '@/components/ui/video'
|
||||
|
||||
<Callout type="warning">
|
||||
スターターブロックは非推奨となり、より専門的なコアトリガーに置き換えられました。新しいAPI、チャット、入力フォーム、手動、スケジュール、Webhookトリガーについては[コアトリガーのドキュメント](/triggers)をご覧ください。
|
||||
</Callout>
|
||||
|
||||
スターターブロックでは、入力パラメータを使用してワークフローの実行を手動で開始することができ、構造化されたパラメータまたは会話型チャットという2つの入力モードを提供しています。
|
||||
|
||||
<div className="flex justify-center">
|
||||
<Image
|
||||
src="/static/starter.png"
|
||||
alt="手動モードとチャットモードのオプションを備えたスターターブロック"
|
||||
width={500}
|
||||
height={400}
|
||||
className="my-6"
|
||||
/>
|
||||
</div>
|
||||
|
||||
## 実行モード
|
||||
|
||||
ドロップダウンから入力方法を選択してください:
|
||||
|
||||
<Tabs items={['手動モード', 'チャットモード']}>
|
||||
<Tab>
|
||||
<div className="space-y-4">
|
||||
<ul className="list-disc space-y-1 pl-6">
|
||||
<li><strong>API対応の構造化入力</strong>:特定のパラメータ(テキスト、数値、ブール値、JSON、ファイル、日付)を定義</li>
|
||||
<li><strong>ワークフロー構築中のテスト</strong>:ワークフローのデバッグ中に素早く反復</li>
|
||||
</ul>
|
||||
|
||||
<div className="mx-auto w-full overflow-hidden rounded-lg">
|
||||
<Video src="input-format.mp4" width={700} height={450} />
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-gray-600">APIエンドポイントとしてデプロイする際に利用可能な入力パラメータを設定します。</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-4">
|
||||
<ul className="list-disc space-y-1 pl-6">
|
||||
<li><strong>自然言語</strong>:ユーザーが質問やリクエストを入力</li>
|
||||
<li><strong>会話型</strong>:AI駆動のワークフローに最適</li>
|
||||
</ul>
|
||||
|
||||
<div className="mx-auto w-full overflow-hidden rounded-lg">
|
||||
<Video src="chat-input.mp4" width={700} height={450} />
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-gray-600">ワークフローとチャットし、入力テキスト、会話ID、アップロードされたファイルにアクセスして、文脈を考慮した応答を得られます。</p>
|
||||
</div>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## チャット変数の使用
|
||||
|
||||
チャットモードでは、特別な変数を通じてユーザー入力と会話コンテキストにアクセスできます:
|
||||
|
||||
- **`<start.input>`** - ユーザーのメッセージテキストが含まれます
|
||||
- **`<start.conversationId>`** - 会話スレッドの一意の識別子
|
||||
- **`<start.files>`** - ユーザーがアップロードしたファイルの配列(ある場合)
|
||||
@@ -1,357 +0,0 @@
|
||||
---
|
||||
title: ループブロックYAMLスキーマ
|
||||
description: ループブロックのYAML設定リファレンス
|
||||
---
|
||||
|
||||
## スキーマ定義
|
||||
|
||||
```yaml
|
||||
type: object
|
||||
required:
|
||||
- type
|
||||
- name
|
||||
- connections
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
enum: [loop]
|
||||
description: Block type identifier
|
||||
name:
|
||||
type: string
|
||||
description: Display name for this loop block
|
||||
inputs:
|
||||
type: object
|
||||
description: Optional. If omitted, defaults will be applied.
|
||||
properties:
|
||||
loopType:
|
||||
type: string
|
||||
enum: [for, forEach]
|
||||
description: Type of loop to execute
|
||||
default: for
|
||||
iterations:
|
||||
type: number
|
||||
description: Number of iterations (for 'for' loops)
|
||||
default: 5
|
||||
minimum: 1
|
||||
maximum: 1000
|
||||
collection:
|
||||
type: string
|
||||
description: Collection to iterate over (for 'forEach' loops)
|
||||
default: ""
|
||||
maxConcurrency:
|
||||
type: number
|
||||
description: Maximum concurrent executions
|
||||
default: 1
|
||||
minimum: 1
|
||||
maximum: 10
|
||||
connections:
|
||||
type: object
|
||||
properties:
|
||||
# Nested format (recommended)
|
||||
loop:
|
||||
type: object
|
||||
properties:
|
||||
start:
|
||||
type: string
|
||||
description: Target block ID to execute inside the loop
|
||||
end:
|
||||
type: string
|
||||
description: Target block ID for loop completion (optional)
|
||||
# Direct handle format (alternative)
|
||||
loop-start-source:
|
||||
type: string | string[]
|
||||
description: Target block ID to execute inside the loop (direct format)
|
||||
loop-end-source:
|
||||
type: string | string[]
|
||||
description: Target block ID for loop completion (direct format, optional)
|
||||
error:
|
||||
type: string
|
||||
description: Target block ID for error handling
|
||||
note: Use either the nested 'loop' format OR the direct 'loop-start-source' format, not both
|
||||
```
|
||||
|
||||
## 接続設定
|
||||
|
||||
ループブロックは2つの接続形式をサポートしています:
|
||||
|
||||
### 直接ハンドル形式(代替)
|
||||
|
||||
```yaml
|
||||
connections:
|
||||
loop-start-source: <string> # Target block ID to execute inside the loop
|
||||
loop-end-source: <string> # Target block ID after loop completion (optional)
|
||||
error: <string> # Target block ID for error handling (optional)
|
||||
```
|
||||
|
||||
両方の形式は同じように機能します。お好みの方を使用してください。
|
||||
|
||||
## 子ブロックの設定
|
||||
|
||||
ループ内のブロックは、その `parentId` をループブロックIDに設定する必要があります。`extent` プロパティは自動的に `'parent'` に設定されるため、指定する必要はありません:
|
||||
|
||||
```yaml
|
||||
loop-1:
|
||||
type: loop
|
||||
name: "Process Items"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.items>
|
||||
connections:
|
||||
loop:
|
||||
start: process-item
|
||||
end: final-results
|
||||
|
||||
# Child block inside the loop
|
||||
process-item:
|
||||
type: agent
|
||||
name: "Process Item"
|
||||
parentId: loop-1 # References the loop block
|
||||
inputs:
|
||||
systemPrompt: "Process this item"
|
||||
userPrompt: <loop.currentItem>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
## 例
|
||||
|
||||
### Forループ(固定反復)
|
||||
|
||||
```yaml
|
||||
countdown-loop:
|
||||
type: loop
|
||||
name: "Countdown Loop"
|
||||
inputs:
|
||||
loopType: for
|
||||
iterations: 5
|
||||
connections:
|
||||
loop:
|
||||
start: countdown-agent
|
||||
end: countdown-complete
|
||||
|
||||
countdown-agent:
|
||||
type: agent
|
||||
name: "Countdown Agent"
|
||||
parentId: countdown-loop
|
||||
inputs:
|
||||
systemPrompt: "Generate a countdown message"
|
||||
userPrompt: "Count down from 5. Current number: <loop.index>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### ForEachループ(コレクション処理)
|
||||
|
||||
```yaml
|
||||
email-processor-loop:
|
||||
type: loop
|
||||
name: "Email Processor Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.emails>
|
||||
connections:
|
||||
loop:
|
||||
start: process-single-email
|
||||
end: all-emails-processed
|
||||
|
||||
process-single-email:
|
||||
type: agent
|
||||
name: "Process Single Email"
|
||||
parentId: email-processor-loop
|
||||
inputs:
|
||||
systemPrompt: "Classify and respond to this email"
|
||||
userPrompt: "Email content: <loop.currentItem>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### 複数の子ブロックを持つループ
|
||||
|
||||
```yaml
|
||||
data-analysis-loop:
|
||||
type: loop
|
||||
name: "Data Analysis Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <data-fetcher.records>
|
||||
maxConcurrency: 3
|
||||
connections:
|
||||
loop:
|
||||
start: validate-record
|
||||
end: generate-report
|
||||
error: handle-loop-error
|
||||
|
||||
validate-record:
|
||||
type: function
|
||||
name: "Validate Record"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
code: |
|
||||
const record = <loop.currentItem>;
|
||||
const index = <loop.index>;
|
||||
|
||||
// Validate the record
|
||||
if (!record.id || !record.data) {
|
||||
throw new Error(`Invalid record at index ${index}`);
|
||||
}
|
||||
|
||||
return {
|
||||
valid: true,
|
||||
recordId: record.id,
|
||||
processedAt: new Date().toISOString()
|
||||
};
|
||||
connections:
|
||||
success: analyze-record
|
||||
error: record-error
|
||||
|
||||
analyze-record:
|
||||
type: agent
|
||||
name: "Analyze Record"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
systemPrompt: "Analyze this data record and extract insights"
|
||||
userPrompt: |
|
||||
Record ID: <validaterecord.recordId>
|
||||
Data: <loop.currentItem.data>
|
||||
Position in collection: <loop.index>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
connections:
|
||||
success: store-analysis
|
||||
|
||||
store-analysis:
|
||||
type: function
|
||||
name: "Store Analysis"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
code: |
|
||||
const analysis = <analyzerecord.content>;
|
||||
const recordId = <validaterecord.recordId>;
|
||||
|
||||
// Store analysis result
|
||||
return {
|
||||
recordId,
|
||||
analysis,
|
||||
completedAt: new Date().toISOString()
|
||||
};
|
||||
```
|
||||
|
||||
### 並行処理ループ
|
||||
|
||||
```yaml
|
||||
parallel-processing-loop:
|
||||
type: loop
|
||||
name: "Parallel Processing Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.tasks>
|
||||
maxConcurrency: 5
|
||||
connections:
|
||||
loop:
|
||||
start: process-task
|
||||
end: aggregate-results
|
||||
|
||||
process-task:
|
||||
type: api
|
||||
name: "Process Task"
|
||||
parentId: parallel-processing-loop
|
||||
inputs:
|
||||
url: "https://api.example.com/process"
|
||||
method: POST
|
||||
headers:
|
||||
- key: "Authorization"
|
||||
value: "Bearer {{API_TOKEN}}"
|
||||
body: |
|
||||
{
|
||||
"taskId": "<loop.currentItem.id>",
|
||||
"data": "<loop.currentItem.data>"
|
||||
}
|
||||
connections:
|
||||
success: task-completed
|
||||
```
|
||||
|
||||
### 直接ハンドル形式の例
|
||||
|
||||
同じループは直接ハンドル形式を使用して記述することもできます:
|
||||
|
||||
```yaml
|
||||
my-loop:
|
||||
type: loop
|
||||
name: "Process Items"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.items>
|
||||
connections:
|
||||
loop-start-source: process-item # Direct handle format
|
||||
loop-end-source: final-results # Direct handle format
|
||||
error: handle-error
|
||||
|
||||
process-item:
|
||||
type: agent
|
||||
name: "Process Item"
|
||||
parentId: my-loop
|
||||
inputs:
|
||||
systemPrompt: "Process this item"
|
||||
userPrompt: <loop.currentItem>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### 最小限のループ例(デフォルトを使用)
|
||||
|
||||
`inputs` セクションを完全に省略することができ、デフォルト値が適用されます:
|
||||
|
||||
```yaml
|
||||
simple-loop:
|
||||
type: loop
|
||||
name: "Simple Loop"
|
||||
# No inputs section - defaults to loopType: 'for', iterations: 5
|
||||
connections:
|
||||
loop-start-source: process-step
|
||||
loop-end-source: complete
|
||||
|
||||
process-step:
|
||||
type: agent
|
||||
name: "Process Step"
|
||||
parentId: simple-loop
|
||||
inputs:
|
||||
systemPrompt: "Execute step"
|
||||
userPrompt: "Step <loop.index>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
このループはデフォルトで5回の反復を実行します。
|
||||
|
||||
## ループ変数
|
||||
|
||||
ループ子ブロック内では、以下の特殊変数が利用可能です:
|
||||
|
||||
```yaml
|
||||
# Available in all child blocks of the loop
|
||||
<loop.index> # Current iteration number (0-based)
|
||||
<loop.currentItem> # Current item being processed (forEach loops)
|
||||
<loop.items> # Full collection (forEach loops)
|
||||
```
|
||||
|
||||
## 出力参照
|
||||
|
||||
ループが完了した後、その集計結果を参照できます:
|
||||
|
||||
```yaml
|
||||
# In blocks after the loop
|
||||
final-processor:
|
||||
inputs:
|
||||
all-results: <loop-name.results> # Array of all iteration results
|
||||
total-count: <loop-name.count> # Number of iterations completed
|
||||
```
|
||||
|
||||
## ベストプラクティス
|
||||
|
||||
- 長い実行時間を避けるため、適切な繰り返し制限を設定する
|
||||
- コレクション処理にはforEachを、固定回数の繰り返しにはforループを使用する
|
||||
- I/O処理が多い操作にはmaxConcurrencyの使用を検討する
|
||||
- 堅牢なループ実行のためにエラー処理を含める
|
||||
- ループ子ブロックには説明的な名前を使用する
|
||||
- 最初に小さなコレクションでテストする
|
||||
- 大きなコレクションの実行時間を監視する
|
||||
@@ -1,187 +0,0 @@
|
||||
---
|
||||
title: API 触发器
|
||||
description: 通过经过身份验证的 HTTP 请求启动工作流
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## 概述
|
||||
|
||||
API 触发器将您的工作流公开为一个安全的 HTTP 端点。将 JSON 数据发送到该端点,您的工作流会立即处理它。API 调用始终针对您的最新部署执行。
|
||||
|
||||
## 配置输入格式
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/api-trigger-light.png'
|
||||
alt='API 触发器输入格式'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
为每个参数添加一个 **输入格式** 字段。运行时输出键会镜像该模式,并且也可以在 `<api.input>` 下使用。
|
||||
|
||||
在编辑器中手动运行使用 `value` 列,因此您可以在不发送请求的情况下进行测试。在执行过程中,解析器会填充 `<api.userId>` 和 `<api.input.userId>`。
|
||||
|
||||
## 请求示例
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{"userId":"demo-user","maxTokens":1024}'
|
||||
```
|
||||
|
||||
成功的响应会返回来自执行器的序列化执行结果。错误会显示验证、认证或工作流失败的信息。
|
||||
|
||||
## 流式响应
|
||||
|
||||
启用实时流式传输以在生成时逐字符接收工作流输出。这对于向用户逐步显示 AI 响应非常有用。
|
||||
|
||||
### 请求参数
|
||||
|
||||
添加以下参数以启用流式传输:
|
||||
|
||||
- `stream` - 设置为 `true` 以启用服务器发送事件 (SSE) 流式传输
|
||||
- `selectedOutputs` - 要流式传输的块输出数组(例如,`["agent1.content"]`)
|
||||
|
||||
### 块输出格式
|
||||
|
||||
使用 `blockName.attribute` 格式指定要流式传输的块输出:
|
||||
- 格式:`"blockName.attribute"`(例如,如果您想流式传输 Agent 1 块的内容,可以使用 `"agent1.content"`)
|
||||
- 块名称不区分大小写,空格会被忽略
|
||||
|
||||
### 示例请求
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{
|
||||
"message": "Count to five",
|
||||
"stream": true,
|
||||
"selectedOutputs": ["agent1.content"]
|
||||
}'
|
||||
```
|
||||
|
||||
### 响应格式
|
||||
|
||||
流式响应使用服务器发送事件 (SSE) 格式:
|
||||
|
||||
```
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"}
|
||||
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"}
|
||||
|
||||
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", three"}
|
||||
|
||||
data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}}
|
||||
|
||||
data: [DONE]
|
||||
```
|
||||
|
||||
每个事件包括:
|
||||
- **流式块**:`{"blockId": "...", "chunk": "text"}` - 实时生成的文本
|
||||
- **最终事件**:`{"event": "done", ...}` - 执行元数据和完整结果
|
||||
- **终止符**:`[DONE]` - 表示流结束
|
||||
|
||||
### 多块流式传输
|
||||
|
||||
当 `selectedOutputs` 包含多个块时,每个块会指示其来源:
|
||||
|
||||
```bash
|
||||
curl -X POST \
|
||||
https://sim.ai/api/workflows/WORKFLOW_ID/execute \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'X-API-Key: YOUR_KEY' \
|
||||
-d '{
|
||||
"message": "Process this request",
|
||||
"stream": true,
|
||||
"selectedOutputs": ["agent1.content", "agent2.content"]
|
||||
}'
|
||||
```
|
||||
|
||||
每个块中的 `blockId` 字段可让您将输出路由到正确的 UI 元素:
|
||||
|
||||
```
|
||||
data: {"blockId":"agent1-uuid","chunk":"Processing..."}
|
||||
|
||||
data: {"blockId":"agent2-uuid","chunk":"Analyzing..."}
|
||||
|
||||
data: {"blockId":"agent1-uuid","chunk":" complete"}
|
||||
```
|
||||
|
||||
## 输出参考
|
||||
|
||||
| 参考 | 描述 |
|
||||
|-----------|-------------|
|
||||
| `<api.field>` | 输入格式中定义的字段 |
|
||||
| `<api.input>` | 整个结构化请求体 |
|
||||
|
||||
如果未定义输入格式,执行器仅在 `<api.input>` 处暴露原始 JSON。
|
||||
|
||||
<Callout type="warning">
|
||||
一个工作流只能包含一个 API 触发器。更改后发布新部署,以确保端点保持最新。
|
||||
</Callout>
|
||||
|
||||
### 文件上传格式
|
||||
|
||||
API 接受两种格式的文件:
|
||||
|
||||
**1. Base64 编码文件**(推荐用于 SDK):
|
||||
|
||||
```json
|
||||
{
|
||||
"documents": [{
|
||||
"type": "file",
|
||||
"data": "data:application/pdf;base64,JVBERi0xLjQK...",
|
||||
"name": "document.pdf",
|
||||
"mime": "application/pdf"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
- 单个文件的最大大小:20MB
|
||||
- 文件会上传到云存储,并转换为具有所有属性的 UserFile 对象
|
||||
|
||||
**2. 直接 URL 引用**:
|
||||
|
||||
```json
|
||||
{
|
||||
"documents": [{
|
||||
"type": "url",
|
||||
"data": "https://example.com/document.pdf",
|
||||
"name": "document.pdf",
|
||||
"mime": "application/pdf"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
- 文件不会上传,URL 会直接传递
|
||||
- 适用于引用现有文件
|
||||
|
||||
### 文件属性
|
||||
|
||||
对于文件,可以访问所有属性:
|
||||
|
||||
| 属性 | 描述 | 类型 |
|
||||
|----------|-------------|------|
|
||||
| `<api.fieldName[0].url>` | 签名下载 URL | string |
|
||||
| `<api.fieldName[0].name>` | 原始文件名 | string |
|
||||
| `<api.fieldName[0].size>` | 文件大小(字节) | number |
|
||||
| `<api.fieldName[0].type>` | MIME 类型 | string |
|
||||
| `<api.fieldName[0].uploadedAt>` | 上传时间戳(ISO 8601) | string |
|
||||
| `<api.fieldName[0].expiresAt>` | URL 过期时间戳(ISO 8601) | string |
|
||||
|
||||
对于 URL 引用的文件,除了 `uploadedAt` 和 `expiresAt` 外,其他属性均可用,因为文件未上传到我们的存储中。
|
||||
|
||||
如果未定义输入格式,执行器将仅在 `<api.input>` 处暴露原始 JSON。
|
||||
|
||||
<Callout type="warning">
|
||||
一个工作流只能包含一个 API 触发器。更改后发布新的部署,以确保端点保持最新。
|
||||
</Callout>
|
||||
@@ -1,51 +0,0 @@
|
||||
---
|
||||
title: 聊天触发器
|
||||
description: 从聊天部署中启动工作流
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## 概述
|
||||
|
||||
聊天触发器为您的工作流创建了一个对话界面。将您的工作流部署为聊天,用户可以通过一个可分享的 URL 与其交互。每条消息都会使用您最新的部署启动一个新的工作流执行。
|
||||
|
||||
## 运行时输出
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/chat-trigger-light.png'
|
||||
alt='聊天部署对话'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
触发器会写入三个字段,供下游模块引用:
|
||||
|
||||
| 引用 | 描述 |
|
||||
|-----------|-------------|
|
||||
| `<chat.input>` | 最新的用户消息 |
|
||||
| `<chat.conversationId>` | 对话线程 ID |
|
||||
| `<chat.files>` | 可选的上传文件 |
|
||||
|
||||
文件包括 `name`、`mimeType`,以及一个带签名的下载链接 `url`。
|
||||
|
||||
## 使用说明
|
||||
|
||||
1. 每个工作流添加一个聊天触发器模块。
|
||||
2. 以聊天模式部署工作流。
|
||||
3. 分享部署链接——每次回复都会重用对话 ID,以便工作流保持上下文。
|
||||
|
||||
<Callout type="info">
|
||||
构建器会阻止在同一工作流中添加多个聊天触发器模块。
|
||||
</Callout>
|
||||
|
||||
1. 为每个工作流添加一个聊天触发器模块。
|
||||
2. 以聊天模式部署工作流。
|
||||
3. 分享部署链接——每次回复都会重用会话 ID,因此工作流可以保持上下文。
|
||||
|
||||
<Callout type="info">
|
||||
构建器会阻止在同一工作流中使用多个聊天触发器模块。
|
||||
</Callout>
|
||||
@@ -7,46 +7,34 @@ import { Card, Cards } from 'fumadocs-ui/components/card'
|
||||
|
||||
## 核心触发器
|
||||
|
||||
为每个工作流选择一个触发器以定义其启动方式:
|
||||
使用 Start 块处理所有从编辑器、部署到 API 或部署到聊天的体验中发起的操作。其他触发器仍可用于事件驱动的工作流:
|
||||
|
||||
<Cards>
|
||||
<Card title="API" href="/triggers/api">
|
||||
将 JSON 数据映射到工作流输入的 HTTP 端点
|
||||
<Card title="Start" href="/triggers/start">
|
||||
支持编辑器运行、API 部署和聊天部署的统一入口点
|
||||
</Card>
|
||||
<Card title="Chat" href="/triggers/chat">
|
||||
部署的聊天界面,支持流式响应
|
||||
</Card>
|
||||
<Card title="Input Form" href="/triggers/input-form">
|
||||
在编辑器运行和子工作流中使用的手动输入
|
||||
</Card>
|
||||
<Card title="Manual" href="/triggers/manual">
|
||||
无需额外数据的按需运行
|
||||
<Card title="Webhook" href="/triggers/webhook">
|
||||
接收外部 webhook 负载
|
||||
</Card>
|
||||
<Card title="Schedule" href="/triggers/schedule">
|
||||
基于 Cron 或间隔的执行
|
||||
</Card>
|
||||
<Card title="Webhook" href="/triggers/webhook">
|
||||
接收外部 Webhook 负载
|
||||
</Card>
|
||||
</Cards>
|
||||
|
||||
## 快速对比
|
||||
|
||||
| 触发器 | 启动条件 |
|
||||
|---------|-----------------|
|
||||
| **API** | 经过身份验证的 HTTP POST |
|
||||
| **Chat** | 聊天部署消息 |
|
||||
| **Input Form** | 在编辑器或父工作流中手动提交 |
|
||||
| **Manual** | 编辑器中的运行按钮 |
|
||||
| **Start** | 编辑器运行、部署到 API 请求或聊天消息 |
|
||||
| **Schedule** | 在计划模式中管理的计时器 |
|
||||
| **Webhook** | 入站 HTTP 请求 |
|
||||
| **Webhook** | 收到入站 HTTP 请求时 |
|
||||
|
||||
> Start 块始终会暴露 `input`、`conversationId` 和 `files` 字段。可以向输入格式添加自定义字段以获取额外的结构化数据。
|
||||
|
||||
## 使用触发器
|
||||
|
||||
1. 将触发器模块放入启动槽中。
|
||||
1. 将 Start 块放入起始槽(或其他触发器如 Webhook/Schedule)。
|
||||
2. 配置任何所需的模式或认证。
|
||||
3. 将模块连接到工作流的其余部分。
|
||||
3. 将该块连接到工作流的其余部分。
|
||||
|
||||
> 部署为每个触发器提供支持。更新工作流,重新部署,所有触发器入口点将获取新的快照。了解更多信息,请参阅[执行 → 部署快照](/execution)。
|
||||
|
||||
旧版启动模块仍适用于现有流程,但不再出现在新构建中。
|
||||
> 部署为每个触发器提供支持。更新工作流,重新部署,所有触发器入口点都会获取新的快照。在[执行 → 部署快照](/execution)中了解更多信息。
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
---
|
||||
title: 输入表单触发器
|
||||
description: 具有结构化输入模式的手动触发器
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## 概述
|
||||
|
||||
当工作流需要从编辑器中以类型化字段开始时,请使用输入表单触发器。运行面板会准确显示您定义的字段,因此工作流始终接收干净的数据。
|
||||
|
||||
## 您需要定义的内容
|
||||
|
||||
在输入格式构建器中添加字段(文本、数字、布尔值、JSON 等)。对于每个字段:
|
||||
|
||||
- 该值会作为 `<blockName.field>` 出现在工作流中。
|
||||
- 为方便起见,完整的有效负载会镜像在 `<blockName.input>`。
|
||||
|
||||
如果您将表单留空,触发器将没有输出。
|
||||
|
||||
## 手动运行
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/input-form-panel-light.png'
|
||||
alt='输入表单运行面板'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
当您在编辑器中按下运行按钮时,面板会渲染表单。提交的值会直接输入到触发器输出中,因此下游模块可以直接引用它们而无需额外解析。数字会被转换为数字,布尔值会变为 true/false,JSON 字段在工作流看到它们之前会被解析。
|
||||
|
||||
## 子工作流
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/workflow-input-mapping-light.png'
|
||||
alt='工作流输入映射'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
输入表单触发器还支持工作流模块。当您嵌入子工作流时,映射步骤会显示子表单字段,以便您可以将变量从父级连接到子级。您映射的内容将成为子工作流的输入表单提交。
|
||||
|
||||
<Callout>
|
||||
需要一个没有字段的快速运行按钮?使用手动触发器。当您需要验证和可预测的结构时,请选择输入表单。
|
||||
</Callout>
|
||||
@@ -1,41 +0,0 @@
|
||||
---
|
||||
title: 手动触发器
|
||||
description: 无需输入即可按需运行工作流
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
## 概述
|
||||
|
||||
手动触发器会在工作流顶部添加一个简单的运行按钮。当您希望立即执行工作流而无需收集额外数据时,可以使用它。
|
||||
|
||||
## 工作原理
|
||||
|
||||
<div className='flex justify-center my-6'>
|
||||
<Image
|
||||
src='/static/triggers/manual-run-light.png'
|
||||
alt='手动触发器运行按钮'
|
||||
width={400}
|
||||
height={250}
|
||||
className='rounded-xl border border-border shadow-sm'
|
||||
/>
|
||||
</div>
|
||||
|
||||
- 使用活动的部署快照启动工作流
|
||||
- 不发送任何有效负载——下游模块仅看到它们已配置的内容
|
||||
- 非常适合快速检查、冒烟测试或仅依赖内部变量的流程
|
||||
|
||||
## 使用场景
|
||||
|
||||
- 在发布新部署后启动工作流,以确认一切仍然正常运行
|
||||
- 运行不需要外部输入的维护任务
|
||||
- 触发仅读取状态或环境变量的子工作流
|
||||
|
||||
## 与输入表单的比较
|
||||
|
||||
需要在运行时提供结构化值或类型验证?改用输入表单触发器——运行面板将在工作流开始前收集这些字段。
|
||||
|
||||
<Callout>
|
||||
手动触发器运行不会覆盖您的部署历史记录。每当需要上线画布更改时,请更新并重新部署。
|
||||
</Callout>
|
||||
90
apps/docs/content/docs/zh/triggers/start.mdx
Normal file
90
apps/docs/content/docs/zh/triggers/start.mdx
Normal file
@@ -0,0 +1,90 @@
|
||||
---
|
||||
title: 开始
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Tab, Tabs } from 'fumadocs-ui/components/tabs'
|
||||
import { Image } from '@/components/ui/image'
|
||||
|
||||
“开始”模块是 Sim 中构建工作流的默认触发器。它收集结构化输入,并将其分发到您的图表的其余部分,用于编辑器测试、API 部署和聊天体验。
|
||||
|
||||
<div className="flex justify-center">
|
||||
<Image
|
||||
src="/static/start.png"
|
||||
alt="带有输入格式字段的开始模块"
|
||||
width={360}
|
||||
height={380}
|
||||
className="my-6"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Callout type="info">
|
||||
“开始”模块在您创建工作流时位于起始位置。当您希望同一个入口点服务于编辑器运行、API 部署请求和聊天会话时,请将其保留在那里。如果只需要事件驱动的执行,可以将其替换为 Webhook 或 Schedule 触发器。
|
||||
</Callout>
|
||||
|
||||
## 开始模块暴露的字段
|
||||
|
||||
“开始”模块根据执行环境发出不同的数据:
|
||||
|
||||
- **输入格式字段** — 您添加的每个字段都会作为 <code><start.fieldName></code> 提供。例如,`customerId` 字段会在下游模块和模板中显示为 <code><start.customerId></code>。
|
||||
- **仅限聊天的字段** — 当工作流从聊天侧边栏或已部署的聊天体验中运行时,Sim 还会提供 <code><start.input></code>(最新用户消息)、<code><start.conversationId></code>(活动会话 ID)和 <code><start.files></code>(聊天附件)。
|
||||
|
||||
请将输入格式字段限定为您期望稍后引用的名称——这些值是编辑器、API 和聊天运行中唯一共享的结构化字段。
|
||||
|
||||
## 配置输入格式
|
||||
|
||||
使用输入格式子模块定义适用于所有执行模式的架构:
|
||||
|
||||
1. 为您想要收集的每个值添加一个字段。
|
||||
2. 选择一个类型(`string`、`number`、`boolean`、`object`、`array` 或 `files`)。文件字段接受来自聊天和 API 调用者的上传。
|
||||
3. 当您希望手动运行模式自动填充测试数据时,提供默认值。这些默认值在已部署的执行中会被忽略。
|
||||
4. 重新排序字段以控制它们在编辑器表单中的显示顺序。
|
||||
|
||||
根据您连接的模块,通过类似 <code><start.customerId></code> 的表达式引用结构化值。
|
||||
|
||||
## 每个入口点的行为
|
||||
|
||||
<Tabs items={['编辑器运行', '部署到 API', '部署到聊天']}>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
当您在编辑器中点击 <strong>运行</strong> 时,开始模块会将输入格式呈现为一个表单。默认值使您无需重新输入数据即可轻松重新测试。提交表单会立即触发工作流,这些值将可用在 <code><start.fieldName></code>(例如 <code><start.sampleField></code>)中。
|
||||
</p>
|
||||
<p>
|
||||
表单中的文件字段会直接上传到相应的 <code><start.fieldName></code>;使用这些值为下游工具或存储步骤提供数据。
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
部署到 API 会将输入格式转换为客户端的 JSON 合约。每个字段都会成为请求体的一部分,Sim 在接收时会强制转换基本类型。文件字段需要引用已上传文件的对象;在调用工作流之前,请使用执行文件上传端点。
|
||||
</p>
|
||||
<p>
|
||||
API 调用者可以包含其他可选属性。这些属性会保存在 <code><start.fieldName></code> 输出中,因此您可以在不立即重新部署的情况下进行实验。
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-3">
|
||||
<p>
|
||||
在聊天部署中,开始模块绑定到活动会话。最新消息填充 <code><start.input></code>,会话标识符可通过 <code><start.conversationId></code> 获取,用户附件会出现在 <code><start.files></code> 中,以及任何范围为 <code><start.fieldName></code> 的输入格式字段。
|
||||
</p>
|
||||
<p>
|
||||
如果您通过附加结构化上下文(例如嵌入)启动聊天,它会合并到相应的 <code><start.fieldName></code> 输出中,确保下游模块与 API 和手动运行保持一致。
|
||||
</p>
|
||||
</div>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## 在下游引用 Start 数据
|
||||
|
||||
- 将 <code><start.fieldName></code> 直接连接到需要结构化负载的代理、工具或函数中。
|
||||
- 在提示字段中使用模板语法,例如 <code><start.sampleField></code> 或 <code><start.files[0].url></code>(仅限聊天)。
|
||||
- 当需要对输出进行分组、更新会话历史记录或回调到聊天 API 时,请随时使用 <code><start.conversationId></code>。
|
||||
|
||||
## 最佳实践
|
||||
|
||||
- 当您希望同时支持 API 和聊天调用者时,将 Start 块视为单一入口点。
|
||||
- 优先使用命名的输入格式字段,而不是在下游节点中解析原始 JSON;类型强制会自动发生。
|
||||
- 如果您的工作流需要某些字段才能成功,请在 Start 之后立即添加验证或路由。
|
||||
@@ -1,67 +0,0 @@
|
||||
---
|
||||
title: Starter(已弃用)
|
||||
---
|
||||
|
||||
import { Callout } from 'fumadocs-ui/components/callout'
|
||||
import { Tab, Tabs } from 'fumadocs-ui/components/tabs'
|
||||
import { Image } from '@/components/ui/image'
|
||||
import { Video } from '@/components/ui/video'
|
||||
|
||||
<Callout type="warning">
|
||||
Starter 模块已被弃用,并由更专业的核心触发器取代。请参阅[核心触发器文档](/triggers),了解新的 API、聊天、输入表单、手动、计划和 Webhook 触发器。
|
||||
</Callout>
|
||||
|
||||
Starter 模块允许您通过输入参数手动启动工作流执行,提供两种输入模式:结构化参数或对话式聊天。
|
||||
|
||||
<div className="flex justify-center">
|
||||
<Image
|
||||
src="/static/starter.png"
|
||||
alt="带有手动和聊天模式选项的 Starter 模块"
|
||||
width={500}
|
||||
height={400}
|
||||
className="my-6"
|
||||
/>
|
||||
</div>
|
||||
|
||||
## 执行模式
|
||||
|
||||
从下拉菜单中选择您的输入方法:
|
||||
|
||||
<Tabs items={['手动模式', '聊天模式']}>
|
||||
<Tab>
|
||||
<div className="space-y-4">
|
||||
<ul className="list-disc space-y-1 pl-6">
|
||||
<li><strong>API 友好的结构化输入</strong>:定义特定参数(文本、数字、布尔值、JSON、文件、日期)</li>
|
||||
<li><strong>构建工作流时的测试</strong>:调试工作流时快速迭代</li>
|
||||
</ul>
|
||||
|
||||
<div className="mx-auto w-full overflow-hidden rounded-lg">
|
||||
<Video src="input-format.mp4" width={700} height={450} />
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-gray-600">配置在作为 API 端点部署时可用的输入参数。</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
<div className="space-y-4">
|
||||
<ul className="list-disc space-y-1 pl-6">
|
||||
<li><strong>自然语言</strong>:用户输入问题或请求</li>
|
||||
<li><strong>对话式</strong>:适用于 AI 驱动的工作流</li>
|
||||
</ul>
|
||||
|
||||
<div className="mx-auto w-full overflow-hidden rounded-lg">
|
||||
<Video src="chat-input.mp4" width={700} height={450} />
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-gray-600">与您的工作流对话,并访问输入文本、会话 ID 和上传的文件,以实现上下文感知的响应。</p>
|
||||
</div>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## 使用聊天变量
|
||||
|
||||
在聊天模式下,可以通过特殊变量访问用户输入和会话上下文:
|
||||
|
||||
- **`<start.input>`** - 包含用户的消息文本
|
||||
- **`<start.conversationId>`** - 会话线程的唯一标识符
|
||||
- **`<start.files>`** - 用户上传的文件数组(如果有)
|
||||
@@ -1,357 +0,0 @@
|
||||
---
|
||||
title: Loop Block YAML 架构
|
||||
description: Loop 块的 YAML 配置参考
|
||||
---
|
||||
|
||||
## 架构定义
|
||||
|
||||
```yaml
|
||||
type: object
|
||||
required:
|
||||
- type
|
||||
- name
|
||||
- connections
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
enum: [loop]
|
||||
description: Block type identifier
|
||||
name:
|
||||
type: string
|
||||
description: Display name for this loop block
|
||||
inputs:
|
||||
type: object
|
||||
description: Optional. If omitted, defaults will be applied.
|
||||
properties:
|
||||
loopType:
|
||||
type: string
|
||||
enum: [for, forEach]
|
||||
description: Type of loop to execute
|
||||
default: for
|
||||
iterations:
|
||||
type: number
|
||||
description: Number of iterations (for 'for' loops)
|
||||
default: 5
|
||||
minimum: 1
|
||||
maximum: 1000
|
||||
collection:
|
||||
type: string
|
||||
description: Collection to iterate over (for 'forEach' loops)
|
||||
default: ""
|
||||
maxConcurrency:
|
||||
type: number
|
||||
description: Maximum concurrent executions
|
||||
default: 1
|
||||
minimum: 1
|
||||
maximum: 10
|
||||
connections:
|
||||
type: object
|
||||
properties:
|
||||
# Nested format (recommended)
|
||||
loop:
|
||||
type: object
|
||||
properties:
|
||||
start:
|
||||
type: string
|
||||
description: Target block ID to execute inside the loop
|
||||
end:
|
||||
type: string
|
||||
description: Target block ID for loop completion (optional)
|
||||
# Direct handle format (alternative)
|
||||
loop-start-source:
|
||||
type: string | string[]
|
||||
description: Target block ID to execute inside the loop (direct format)
|
||||
loop-end-source:
|
||||
type: string | string[]
|
||||
description: Target block ID for loop completion (direct format, optional)
|
||||
error:
|
||||
type: string
|
||||
description: Target block ID for error handling
|
||||
note: Use either the nested 'loop' format OR the direct 'loop-start-source' format, not both
|
||||
```
|
||||
|
||||
## 连接配置
|
||||
|
||||
循环块支持两种连接格式:
|
||||
|
||||
### 直接句柄格式(替代方案)
|
||||
|
||||
```yaml
|
||||
connections:
|
||||
loop-start-source: <string> # Target block ID to execute inside the loop
|
||||
loop-end-source: <string> # Target block ID after loop completion (optional)
|
||||
error: <string> # Target block ID for error handling (optional)
|
||||
```
|
||||
|
||||
两种格式的功能完全相同,可根据您的喜好选择使用。
|
||||
|
||||
## 子块配置
|
||||
|
||||
循环中的块必须将其 `parentId` 设置为循环块的 ID。`extent` 属性会自动设置为 `'parent'`,无需手动指定:
|
||||
|
||||
```yaml
|
||||
loop-1:
|
||||
type: loop
|
||||
name: "Process Items"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.items>
|
||||
connections:
|
||||
loop:
|
||||
start: process-item
|
||||
end: final-results
|
||||
|
||||
# Child block inside the loop
|
||||
process-item:
|
||||
type: agent
|
||||
name: "Process Item"
|
||||
parentId: loop-1 # References the loop block
|
||||
inputs:
|
||||
systemPrompt: "Process this item"
|
||||
userPrompt: <loop.currentItem>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### For 循环(固定迭代次数)
|
||||
|
||||
```yaml
|
||||
countdown-loop:
|
||||
type: loop
|
||||
name: "Countdown Loop"
|
||||
inputs:
|
||||
loopType: for
|
||||
iterations: 5
|
||||
connections:
|
||||
loop:
|
||||
start: countdown-agent
|
||||
end: countdown-complete
|
||||
|
||||
countdown-agent:
|
||||
type: agent
|
||||
name: "Countdown Agent"
|
||||
parentId: countdown-loop
|
||||
inputs:
|
||||
systemPrompt: "Generate a countdown message"
|
||||
userPrompt: "Count down from 5. Current number: <loop.index>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### ForEach 循环(集合处理)
|
||||
|
||||
```yaml
|
||||
email-processor-loop:
|
||||
type: loop
|
||||
name: "Email Processor Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.emails>
|
||||
connections:
|
||||
loop:
|
||||
start: process-single-email
|
||||
end: all-emails-processed
|
||||
|
||||
process-single-email:
|
||||
type: agent
|
||||
name: "Process Single Email"
|
||||
parentId: email-processor-loop
|
||||
inputs:
|
||||
systemPrompt: "Classify and respond to this email"
|
||||
userPrompt: "Email content: <loop.currentItem>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### 包含多个子块的循环
|
||||
|
||||
```yaml
|
||||
data-analysis-loop:
|
||||
type: loop
|
||||
name: "Data Analysis Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <data-fetcher.records>
|
||||
maxConcurrency: 3
|
||||
connections:
|
||||
loop:
|
||||
start: validate-record
|
||||
end: generate-report
|
||||
error: handle-loop-error
|
||||
|
||||
validate-record:
|
||||
type: function
|
||||
name: "Validate Record"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
code: |
|
||||
const record = <loop.currentItem>;
|
||||
const index = <loop.index>;
|
||||
|
||||
// Validate the record
|
||||
if (!record.id || !record.data) {
|
||||
throw new Error(`Invalid record at index ${index}`);
|
||||
}
|
||||
|
||||
return {
|
||||
valid: true,
|
||||
recordId: record.id,
|
||||
processedAt: new Date().toISOString()
|
||||
};
|
||||
connections:
|
||||
success: analyze-record
|
||||
error: record-error
|
||||
|
||||
analyze-record:
|
||||
type: agent
|
||||
name: "Analyze Record"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
systemPrompt: "Analyze this data record and extract insights"
|
||||
userPrompt: |
|
||||
Record ID: <validaterecord.recordId>
|
||||
Data: <loop.currentItem.data>
|
||||
Position in collection: <loop.index>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
connections:
|
||||
success: store-analysis
|
||||
|
||||
store-analysis:
|
||||
type: function
|
||||
name: "Store Analysis"
|
||||
parentId: data-analysis-loop
|
||||
inputs:
|
||||
code: |
|
||||
const analysis = <analyzerecord.content>;
|
||||
const recordId = <validaterecord.recordId>;
|
||||
|
||||
// Store analysis result
|
||||
return {
|
||||
recordId,
|
||||
analysis,
|
||||
completedAt: new Date().toISOString()
|
||||
};
|
||||
```
|
||||
|
||||
### 并发处理循环
|
||||
|
||||
```yaml
|
||||
parallel-processing-loop:
|
||||
type: loop
|
||||
name: "Parallel Processing Loop"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.tasks>
|
||||
maxConcurrency: 5
|
||||
connections:
|
||||
loop:
|
||||
start: process-task
|
||||
end: aggregate-results
|
||||
|
||||
process-task:
|
||||
type: api
|
||||
name: "Process Task"
|
||||
parentId: parallel-processing-loop
|
||||
inputs:
|
||||
url: "https://api.example.com/process"
|
||||
method: POST
|
||||
headers:
|
||||
- key: "Authorization"
|
||||
value: "Bearer {{API_TOKEN}}"
|
||||
body: |
|
||||
{
|
||||
"taskId": "<loop.currentItem.id>",
|
||||
"data": "<loop.currentItem.data>"
|
||||
}
|
||||
connections:
|
||||
success: task-completed
|
||||
```
|
||||
|
||||
### 直接句柄格式示例
|
||||
|
||||
同一个循环可以使用直接句柄格式编写:
|
||||
|
||||
```yaml
|
||||
my-loop:
|
||||
type: loop
|
||||
name: "Process Items"
|
||||
inputs:
|
||||
loopType: forEach
|
||||
collection: <start.items>
|
||||
connections:
|
||||
loop-start-source: process-item # Direct handle format
|
||||
loop-end-source: final-results # Direct handle format
|
||||
error: handle-error
|
||||
|
||||
process-item:
|
||||
type: agent
|
||||
name: "Process Item"
|
||||
parentId: my-loop
|
||||
inputs:
|
||||
systemPrompt: "Process this item"
|
||||
userPrompt: <loop.currentItem>
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
### 最小循环示例(使用默认值)
|
||||
|
||||
您可以完全省略 `inputs` 部分,系统将应用默认值:
|
||||
|
||||
```yaml
|
||||
simple-loop:
|
||||
type: loop
|
||||
name: "Simple Loop"
|
||||
# No inputs section - defaults to loopType: 'for', iterations: 5
|
||||
connections:
|
||||
loop-start-source: process-step
|
||||
loop-end-source: complete
|
||||
|
||||
process-step:
|
||||
type: agent
|
||||
name: "Process Step"
|
||||
parentId: simple-loop
|
||||
inputs:
|
||||
systemPrompt: "Execute step"
|
||||
userPrompt: "Step <loop.index>"
|
||||
model: gpt-4o
|
||||
apiKey: '{{OPENAI_API_KEY}}'
|
||||
```
|
||||
|
||||
此循环默认将执行 5 次迭代。
|
||||
|
||||
## 循环变量
|
||||
|
||||
在循环子块中,可以使用以下特殊变量:
|
||||
|
||||
```yaml
|
||||
# Available in all child blocks of the loop
|
||||
<loop.index> # Current iteration number (0-based)
|
||||
<loop.currentItem> # Current item being processed (forEach loops)
|
||||
<loop.items> # Full collection (forEach loops)
|
||||
```
|
||||
|
||||
## 输出引用
|
||||
|
||||
循环完成后,您可以引用其聚合结果:
|
||||
|
||||
```yaml
|
||||
# In blocks after the loop
|
||||
final-processor:
|
||||
inputs:
|
||||
all-results: <loop-name.results> # Array of all iteration results
|
||||
total-count: <loop-name.count> # Number of iterations completed
|
||||
```
|
||||
|
||||
## 最佳实践
|
||||
|
||||
- 设置合理的迭代限制以避免长时间执行
|
||||
- 使用 forEach 处理集合,使用 for 循环进行固定迭代
|
||||
- 考虑对 I/O 密集型操作使用 maxConcurrency
|
||||
- 包含错误处理以确保循环执行的健壮性
|
||||
- 为循环子块使用描述性名称
|
||||
- 先用小集合进行测试
|
||||
- 对于大集合,监控执行时间
|
||||
@@ -4179,14 +4179,14 @@ checksums:
|
||||
meta/description: 68d1bebfdbae67a09276884b58231c40
|
||||
content/0: 0d82f8784f312f9ac51da136fd47e94a
|
||||
content/1: da2b445db16c149f56558a4ea876a5f0
|
||||
content/2: 34fecbe521c3ea53e9f288437c36b9c3
|
||||
content/3: 3e192851df5121e4ee83754ce34be18d
|
||||
content/2: cec18f48b2cd7974eb556880e6604f7f
|
||||
content/3: c187ae3362455acfe43282399f0d163a
|
||||
content/4: 4c3a5708af82c1ee42a12d14fd34e950
|
||||
content/5: 196439ec46589bfee391896e4792f046
|
||||
content/6: cffe5b901d78ebf2000d07dc7579533e
|
||||
content/7: 7627b5948da98a1c939540dcdbdac0d3
|
||||
content/8: 05aed1f03c5717f3bcb10de2935332e8
|
||||
content/9: 0093cc341f8b972ae8f69eec3452a501
|
||||
content/5: aaf9d62dd579a14cc5142a7692edcd04
|
||||
content/6: a28151eeb5ba3518b33809055b04f0f6
|
||||
content/7: cffe5b901d78ebf2000d07dc7579533e
|
||||
content/8: 73486253d24eeff7ac44dfd0c8868d87
|
||||
content/9: 05aed1f03c5717f3bcb10de2935332e8
|
||||
0bf172ef4ee9a2c94a2967d7d320b81b:
|
||||
meta/title: 330265974a03ee22a09f42fa4ece25f6
|
||||
meta/description: e3d54cbedf551315cf9e8749228c2d1c
|
||||
@@ -4470,3 +4470,23 @@ checksums:
|
||||
content/25: bfd457397ec2c8033475c7c7a89a4d5d
|
||||
content/26: b2a4a0c279f47d58a2456f25a1e1c6f9
|
||||
content/27: 7e48b5958215f904462276e31cb8cc10
|
||||
06e1d1e074395604d39e3cdcb7f2a97f:
|
||||
meta/title: dbe56303d9a6d3fad1a8d4cbcc97f365
|
||||
content/0: e4684b7201c2aed215c82606e9eaa293
|
||||
content/1: 9a47584b95495f0267d8bb6b3eced682
|
||||
content/2: be0f0bf52ac5d095a8c2c8d2fd36ed4b
|
||||
content/3: 5fbcfc4d4dde738efc2b0af0d8dec6e8
|
||||
content/4: 19f52c4c197b2fafa8ff580f1557e0cc
|
||||
content/5: aebcc466d6091df9ae874362886faba9
|
||||
content/6: 65ae2ef2f30d89f3d81c76f3379a5e18
|
||||
content/7: c60706361d349821ce980f403347f883
|
||||
content/8: c02c224c7e29f7d12ab823e1b81e1f35
|
||||
content/9: 144ea38b402a784f7fe5edc71fe3c84f
|
||||
content/10: b0592d6370a39a4e3b366b224b95fc1a
|
||||
content/11: 7264401248fe9c8289dd58abe900f9be
|
||||
content/12: eff16e179bd105e8dce3186022a178b6
|
||||
content/13: 1d9e73cddbd843264fdb1420bd052da1
|
||||
content/14: 78907b2956cbc59eb995332d6fa8adf9
|
||||
content/15: 1200f37171b1c18959fe0974141c3dec
|
||||
content/16: 07c2a244efa2d697ea8a7015e8bda7b9
|
||||
content/17: 5195f6e7ec97e7787a5cf05c38f81ce6
|
||||
|
||||
Reference in New Issue
Block a user