Examples
Beispiele
Real pipelines. Real AI. See what Pipe can do.
Echte Pipelines. Echte KI. Was Pipe kann.
Pipe (SPR) is a Semantic Pipeline Runtime — AI operations as language primitives.
Pipe (SPR) ist eine Semantic Pipeline Runtime — KI-Operationen als Sprachbestandteile.
Log Analysis → Incident Report
Log-Analyse → Incident-Report
Reads error logs, classifies each line by AI, filters for critical entries only, summarizes them into a coherent report, translates it to German, and saves the result.
Liest Fehlerlogs, klassifiziert jede Zeile per KI, filtert kritische Einträge, fasst sie in einem Report zusammen, übersetzt ihn ins Deutsche und speichert das Ergebnis.
-- Read error logs, filter critical lines, summarize findings is_critical: fn line contains line "critical" read_file "/var/log/app/errors.log" > split "\n" > filter is_critical > summarize > translate "de" > save "incident_report.txt"
Pipeline Flow
Pipeline-Ablauf
A named is_critical function filters log lines containing "critical". AI summarizes the critical entries into a coherent incident report, translates it to German, and saves to disk — all in a single pipeline with no intermediate files.
Eine benannte is_critical-Funktion filtert Log-Zeilen, die "critical" enthalten. Die KI fasst die kritischen Einträge in einem kohärenten Incident-Report zusammen, übersetzt ihn ins Deutsche und speichert — alles in einer einzigen Pipeline ohne Zwischendateien.
Multi-Step RAG Pipeline
Mehrstufige RAG-Pipeline
Semantic search over a knowledge base using embeddings. Documents are vectorized, the question is embedded, and the nearest documents are retrieved by meaning — not keywords. The AI answers using only the relevant context.
Semantische Suche über eine Wissensbasis mit Embeddings. Dokumente werden vektorisiert, die Frage wird eingebettet und die ähnlichsten Dokumente werden nach Bedeutung gefunden — nicht nach Stichwörtern. Die KI antwortet nur mit dem relevanten Kontext.
-- Semantic search over a knowledge base docs: read_lines "knowledge_base.txt" vectors: embed_batch docs question: "How does the bytecode VM work?" q_vec: embed question top: nearest q_vec vectors 3 context: "" for idx in top context: context ++ (at docs idx) ++ "\n---\n" ask ("Based on this context:\n" ++ context ++ "\n\nQuestion: " ++ question) > print
Pipeline Flow
Pipeline-Ablauf
All documents are embedded into vectors in a single batch call. The question is also embedded. nearest finds the top 3 documents by cosine similarity — these are semantically related, not just keyword matches. The matched documents are concatenated as context and passed to ask, which answers the question using only that context. True retrieval-augmented generation in 11 lines.
Alle Dokumente werden in einem Batch-Call in Vektoren umgewandelt. Die Frage wird ebenfalls eingebettet. nearest findet die Top 3 Dokumente nach Kosinus-Ähnlichkeit — semantisch verwandt, nicht nur Stichwort-Treffer. Die gefundenen Dokumente werden als Kontext zusammengefügt und an ask übergeben, das die Frage nur mit diesem Kontext beantwortet. Echte Retrieval-Augmented Generation in 11 Zeilen.
Parallel Batch Processing
Parallele Batch-Verarbeitung
Process 100 articles in parallel using AI batch processing with built-in rate limiting. Results are sorted and saved — no async/await, no Promise.all, just data flowing.
100 Artikel parallel mit KI-Batch-Verarbeitung und eingebautem Rate-Limiting verarbeiten. Ergebnisse werden sortiert und gespeichert — kein async/await, kein Promise.all, nur fließende Daten.
-- Process 100 articles in parallel with rate limiting ai_rate_limit 10 texts: read_lines "articles.txt" ai_batch "Summarize this article in one sentence." texts > sort > join "\n" > save "digest.txt"
Pipeline Flow
Pipeline-Ablauf
100 articles are read from disk. ai_batch fires off concurrent LLM calls under the hood using Go goroutines. The rate limit of 10 caps simultaneous API requests to avoid throttling. All summaries are collected, sorted alphabetically, joined with newlines, and saved as a single digest file.
100 Artikel werden von der Festplatte gelesen. ai_batch feuert unter der Haube parallele LLM-Calls mit Go-Goroutines ab. Das Rate-Limit von 10 begrenzt gleichzeitige API-Requests, um Throttling zu vermeiden. Alle Zusammenfassungen werden gesammelt, alphabetisch sortiert, mit Zeilenumbrüchen verbunden und als eine Digest-Datei gespeichert.
AI Agent with Tool Calling
KI-Agent mit Tool-Calling
Define a Pipe function, register it as an LLM tool with a JSON schema. The model autonomously decides when to call it — making two separate calls for two cities — and synthesizes a natural response.
Definiere eine Pipe-Funktion und registriere sie als LLM-Tool mit einem JSON-Schema. Das Modell entscheidet autonom, wann es die Funktion aufruft — zwei separate Calls für zwei Städte — und synthetisiert eine natürliche Antwort.
-- Define a weather tool, let the LLM call it autonomously fn get_weather city match city | "Berlin" -> "22°C, sunny" | "London" -> "15°C, rainy" | "Paris" -> "25°C, clear" | _ -> city ++ ": no data" schema: {city: "Name of the city"} ai_tool "get_weather" "Get current weather for a city" schema get_weather ai_with_tools "You are a weather assistant." "What's the weather in Berlin and Paris?" > print
Pipeline Flow
Pipeline-Ablauf
A Pipe function get_weather is defined with pattern matching for known cities. It is registered as an LLM tool with a JSON schema describing its parameter. ai_with_tools gives the model access to this tool. When asked about two cities, the model makes two autonomous function calls — one for Berlin, one for Paris — receives the results, and synthesizes a natural language weather report.
Eine Pipe-Funktion get_weather wird mit Pattern-Matching für bekannte Städte definiert. Sie wird als LLM-Tool mit einem JSON-Schema registriert. ai_with_tools gibt dem Modell Zugriff auf dieses Tool. Auf die Frage nach zwei Städten führt das Modell zwei autonome Funktionsaufrufe aus — einen für Berlin, einen für Paris — erhält die Ergebnisse und synthetisiert einen natürlichsprachlichen Wetterbericht.
Live Translation with Streaming
Live-Übersetzung mit Streaming
Translate text and see the output appear in real time as tokens arrive. The collected text is then uppercased and printed — streaming and post-processing in one pipeline.
Text übersetzen und die Ausgabe in Echtzeit erscheinen sehen, während Tokens ankommen. Der gesammelte Text wird dann in Großbuchstaben umgewandelt und ausgegeben — Streaming und Nachverarbeitung in einer Pipeline.
-- Translate text and see output in real time text: "Artificial intelligence is reshaping how we interact with computers." ai_stream "You are a translator. Translate precisely." text > upper > print
Pipeline Flow
Pipeline-Ablauf
ai_stream sends the prompt to the LLM and prints tokens to the terminal as they arrive — you see the translation appear word by word. Once streaming completes, the full translated text is passed down the pipeline to upper (which converts it to uppercase) and then print. Streaming output is a side effect; the return value continues through the pipeline for further processing.
ai_stream sendet den Prompt an das LLM und gibt Tokens im Terminal aus, sobald sie ankommen — die Übersetzung erscheint Wort für Wort. Nach Abschluss des Streamings wird der vollständige übersetzte Text an upper (Umwandlung in Großbuchstaben) und dann an print weitergereicht. Die Streaming-Ausgabe ist ein Seiteneffekt; der Rückgabewert fließt zur Weiterverarbeitung durch die Pipeline.
Email Classifier with Structured Output
E-Mail-Klassifizierer mit strukturierter Ausgabe
Classify emails by urgency, extract structured data (sender, subject, deadline), and highlight urgent messages — combining classification, extraction, and conditional logic in one flow.
E-Mails nach Dringlichkeit klassifizieren, strukturierte Daten (Absender, Betreff, Frist) extrahieren und dringende Nachrichten hervorheben — Klassifizierung, Extraktion und bedingte Logik in einem Ablauf.
-- Classify emails and extract structured data emails: read_lines "inbox.txt" for email in emails category: classify email (["urgent", "important", "newsletter", "spam"]) info: extract email "{sender, subject, deadline}" if category == "urgent" print ("[URGENT] " ++ (get info "subject") ++ " — from " ++ (get info "sender"))
Pipeline Flow
Pipeline-Ablauf
Each email is read and processed in a loop. classify categorizes it as urgent, important, newsletter, or spam using AI. extract pulls structured JSON with sender, subject, and deadline fields. A conditional check highlights urgent emails with a [URGENT] prefix and prints key details. This pattern combines classification, structured extraction, and branching — a full email triage system.
Jede E-Mail wird in einer Schleife gelesen und verarbeitet. classify kategorisiert sie per KI als urgent, important, newsletter oder spam. extract zieht strukturierte JSON-Daten mit Absender, Betreff und Frist. Eine Bedingung hebt dringende E-Mails mit einem [URGENT]-Präfix hervor und gibt die wichtigsten Details aus. Dieses Muster kombiniert Klassifizierung, strukturierte Extraktion und Verzweigungen — ein vollständiges E-Mail-Triage-System.
Self-Hosted Lexer (Meta)
Selbst-gehosteter Lexer (Meta)
Pipe's own lexer, written in Pipe (346 lines). Import it and tokenize Pipe source code — demonstrating that the language is Turing-complete and self-describing.
Pipes eigener Lexer, geschrieben in Pipe (346 Zeilen). Importiere ihn und tokenisiere Pipe-Quellcode — ein Beweis, dass die Sprache Turing-vollständig und selbstbeschreibend ist.
-- Pipe's own lexer written in Pipe (346 lines) import "examples/selfhost/lexer.pipe" tokens: tokenize "print (2 + 2)" for t in tokens print (get t "type")
Pipeline Flow
Pipeline-Ablauf
The self-hosted lexer is imported from a 346-line Pipe file — no C, no Go, pure Pipe. tokenize takes a string of Pipe source code and returns a list of token objects with type, value, and position. The loop iterates over each token and prints its type (e.g., PRINT, NUMBER, PLUS). This is the same lexer used by Pipe's parser — the language can parse itself.
Der selbst-gehostete Lexer wird aus einer 346-zeiligen Pipe-Datei importiert — kein C, kein Go, reines Pipe. tokenize nimmt einen Pipe-Quelltext-String und gibt eine Liste von Token-Objekten mit Typ, Wert und Position zurück. Die Schleife iteriert über jedes Token und gibt seinen Typ aus (z. B. PRINT, NUMBER, PLUS). Dies ist derselbe Lexer, den Pipes Parser verwendet — die Sprache kann sich selbst parsen.
CI/CD Status Reporter
CI/CD-Status-Reporter
Fetches GitHub Actions workflow status via API, filters for failed runs, and uses AI to summarize the failures into a readable report. A real DevOps automation pipeline.
Holt GitHub-Actions-Workflow-Status per API, filtert nach fehlgeschlagenen Runs und nutzt KI, um die Fehler in einem lesbaren Report zusammenzufassen. Eine echte DevOps-Automatisierungspipeline.
-- Check GitHub Actions status and report failures ci_data: http_get_json "https://api.github.com/repos/MachuraHarry/pipe/actions/runs" is_failed: fn run (get run "conclusion") == "failure" failed: filter (get ci_data "workflow_runs") is_failed if (len failed) > 0 report: summarize (to_json failed) print "Failed workflows detected:" print report else print "All checks passing."
Pipeline Flow
Pipeline-Ablauf
http_get_json fetches the GitHub Actions API response and parses it into a Pipe object. filter with a named is_failed function selects only workflow runs whose conclusion is "failure". If any failed runs exist, to_json serializes them, summarize uses AI to produce a human-readable summary, and it's printed. Otherwise, an all-clear message is shown. This replaces brittle scripts that grep log output with an intelligent CI monitor.
http_get_json holt die GitHub-Actions-API-Antwort und parst sie in ein Pipe-Objekt. filter mit einer benannten is_failed-Funktion wählt nur Workflow-Runs aus, deren conclusion "failure" ist. Falls fehlgeschlagene Runs existieren, serialisiert to_json sie, summarize erstellt per KI eine lesbare Zusammenfassung, die ausgegeben wird. Andernfalls erscheint eine Entwarnung. Dies ersetzt fehleranfällige Skripte, die Log-Ausgaben parsen, durch einen intelligenten CI-Monitor.
Zero-Setup Test Framework
Test-Framework ohne Setup
Grouped test blocks with built-in assertions — no test runner, no config file, no dependency. Just pipe -test.
Gruppierte test-Blöcke mit eingebauten Assertions — kein Test-Runner, keine Config-Datei, keine Abhängigkeit. Einfach pipe -test.
-- math_test.pipe — run with: pipe -test test "math" fn add a b a + b assert_eq (add 2 3) 5 assert_lt 1 2 assert_gt 5 2 test "error handling" fn boom "str" * 3 assert_error boom
Pipeline Flow
Pipeline-Ablauf
test "name" opens a grouped assertion block. Each assert_* builtin fails the whole file on a broken invariant — assert_error even verifies that a function raises. The runner auto-discovers *_test.pipe files, so pipe -test is the entire CI test story. No framework lock-in, no YAML test config.
test "name" öffnet einen gruppierten Assertion-Block. Jedes assert_*-Builtin lässt die gesamte Datei bei einer verletzten Invariante fehlschlagen — assert_error prüft sogar, dass eine Funktion einen Fehler wirft. Der Runner findet *_test.pipe-Dateien automatisch, also ist pipe -test die komplette CI-Test-Story. Kein Framework-Lock-in, keine YAML-Test-Config.
Modern Control Flow
Moderne Kontrollstrukturen
C-style for loops, multi-pattern match, and a not keyword — small language, everyday scripting comfort.
C-Style-for-Schleifen, Multi-Pattern-match und ein not-Keyword — kleine Sprache, komfortables Alltags-Scripting.
-- C-style for loop for i: 0; i < 5; i: i + 1 print i -- Multi-pattern match match 3 | 1 | 2 -> print "low" | 3 | 4 -> print "mid" | _ -> print "other" -- 'not' keyword instead of '!' if not (2 > 3) print "clearly true"
Pipeline Flow
Pipeline-Ablauf
The C-style for takes three parts — init, condition, update — separated by semicolons, with the loop variable declared in the init. match collapses several patterns (| 1 | 2) into one body instead of repeating code. not reads naturally in conditions. All three compile to the bytecode VM with proper continue/break support.
Die C-Style-for-Schleife besteht aus drei Teilen — Init, Bedingung, Update — durch Semikolons getrennt, wobei die Schleifenvariable im Init deklariert wird. match fasst mehrere Patterns (| 1 | 2) zu einem Body zusammen, statt Code zu wiederholen. not liest sich in Bedingungen natürlich. Alle drei werden mit voller continue/break-Unterstützung in die Bytecode-VM kompiliert.
Pipe in GitHub Actions
Pipe in GitHub Actions
The official pipe-action runs any Pipe script or test suite in CI — no setup, AI-enabled on demand, sandbox on demand via flags.
Die offizielle pipe-action führt jedes Pipe-Skript oder jede Test-Suite in der CI aus — ohne Setup, KI bei Bedarf, Sandbox bei Bedarf über Flags.
# .github/workflows/pipe.yml on: [push] jobs: pipe: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: MachuraHarry/pipe/pipe-action@master with: flags: "-vm -q --sandbox" script: | test "ci" assert_eq (1 + 1) 2 print "CI passed"
Pipeline Flow
Pipeline-Ablauf
The action downloads a prebuilt Pipe binary and runs your code via the script/file inputs (extra args via flags, default -vm -q), failing the job on any assertion error. Adding --sandbox blocks AI, exec, network, and filesystem writes; --allow-ai or the action's provider input re-enables AI builtins. The same action powers this project's own live-demo.yml — Pipe's CI is written in Pipe.
Die Action lädt eine vorgefertigte Pipe-Binary herunter und führt deinen Code über die script-/file-Inputs aus (weitere Argumente via flags, Default -vm -q) und lässt den Job bei jedem Assertion-Fehler fehlschlagen. --sandbox blockiert KI, exec, Netzwerk und Dateisystem-Schreibzugriffe; --allow-ai oder der provider-Input aktiviert die KI-Builtins wieder. Dieselbe Action betreibt auch das eigene live-demo.yml — Pipes CI ist in Pipe geschrieben.
AI Summarize API
KI-Zusammenfassungs-API
Serve an HTTP API and a web form from the same script. pipe-web provides routing, JSON handling, and a built-in server — the summarize AI builtin does the rest. One binary, zero dependencies.
Eine HTTP-API und ein Web-Formular aus demselben Skript servieren. pipe-web liefert Routing, JSON-Handling und einen eingebauten Server — das KI-Builtin summarize erledigt den Rest. Eine Binary, null Abhängigkeiten.
-- AI Summarize API — pipe-web + AI builtins import "../pipe-modules/pipe-web/module.pipe" ai_provider "deepseek" fn summarize_handler req data: json_body req text: get data "text" if text == nil json 400 {error: "Missing 'text'"} else ok {summary: (summarize text)} fn health req ok {status: "ok", framework: "pipe-web"} api: app "AISummarize" route_get api "/health" health post api "/summarize" summarize_handler serve api "0.0.0.0:8080" 300000
Pipeline Flow
Pipeline-Ablauf
pipe-web turns a handful of functions into a running HTTP server. app creates the app, route_get and post map URLs to handlers, and serve binds the port — no framework, no config, no container. The summarize AI builtin turns the request body into a summary in a single call. A landing page with a form and a JSON API are served by the same binary.
pipe-web macht aus ein paar Funktionen einen laufenden HTTP-Server. app erzeugt die App, route_get und post mappen URLs auf Handler, serve bindet den Port — kein Framework, keine Config, kein Container. Das KI-Builtin summarize macht aus dem Request-Body in einem Call eine Zusammenfassung. Eine Landingpage mit Formular und eine JSON-API werden von derselben Binary ausgeliefert.
RAG Knowledge Base
RAG-Wissensbasis
A full web app on top of rag-pipe and sqlite: add documents by text or URL, search them semantically, and ask questions answered only from your indexed knowledge — sources included, persisted across restarts.
Eine vollständige Web-App auf Basis von rag-pipe und sqlite: Dokumente per Text oder URL hinzufügen, semantisch durchsuchen und Fragen beantworten lassen — nur aus deinem indexierten Wissen, inklusive Quellen und über Neustarts hinweg persistiert.
-- RAG Knowledge Base — rag-pipe + sqlite + pipe-web import "sqlite.pipe" import "../pipe-modules/rag-pipe/module.pipe" import "../pipe-modules/pipe-web/module.pipe" fn ask_page req q: get (get req "query") "q" idx: get __kb_state "index" results: index_search idx q 3 context: "" for r in results context: context ++ (get r "text") context: context ++ "\n---\n" answer: ask ("Context:\n" ++ context ++ "\nQuestion: " ++ q) out: page_top "Ask" ("RAG answer for: " ++ (esc_html q)) out: out ++ "<div class=answer>" ++ (esc_html answer) ++ "</div>" html 200 out api: app "RAGKnowledge" route_get api "/" landing_page route_get api "/documents" add_doc route_get api "/ask" ask_page route_get api "/search" search_page serve api "0.0.0.0:8090" 3600000
Pipeline Flow
Pipeline-Ablauf
Documents are embedded and stored in a local sqlite database by rag-pipe. index_search finds the top 3 documents by cosine similarity — meaning, not keywords. The matched text becomes the context for ask, so the AI answers only from your own knowledge base, with the sources rendered on the page.
Dokumente werden von rag-pipe in einer lokalen sqlite-Datenbank eingebettet und gespeichert. index_search findet die Top 3 Dokumente nach Kosinus-Ähnlichkeit — Bedeutung, nicht Stichwörter. Der Treffertext wird zum Kontext für ask, sodass die KI nur aus deiner eigenen Wissensbasis antwortet — mit den Quellen auf der Seite.
More Examples
Weitere Beispiele
Find 87 example programs in the repository: github.com/MachuraHarry/pipe/examples
87 Beispielprogramme im Repository: github.com/MachuraHarry/pipe/examples