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.

01

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, classify severity, summarize findings
read_file "/var/log/app/errors.log"
    > split "\n"
    > classify ["critical", "warning", "info"]
    > filter (fn l: l == "critical")
    > summarize
    > translate "de"
    > save "incident_report.txt"

Pipeline Flow

Pipeline-Ablauf

Each log line is classified by AI into critical, warning, or info. Critical entries are filtered out with a lambda predicate, then AI summarizes the remaining critical logs into a coherent incident report. The summary is translated to German and saved to disk — all in a single pipeline with no intermediate files.

Jede Log-Zeile wird per KI als critical, warning oder info klassifiziert. Kritische Einträge werden mit einem Lambda-Prädikat herausgefiltert, dann fasst die KI die verbleibenden Logs in einem kohärenten Incident-Report zusammen. Die Zusammenfassung wird ins Deutsche übersetzt und gespeichert — alles in einer einzigen Pipeline ohne Zwischendateien.

02

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.

03

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.

04

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.

05

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
ai_stream "You are a translator. Translate precisely."
    "Artificial intelligence is reshaping how we interact with computers."
    > 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.

06

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.

07

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 "fn hello x: x + 1"
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., FN, IDENT, PLUS, NUMBER). 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. FN, IDENT, PLUS, NUMBER). Dies ist derselbe Lexer, den Pipes Parser verwendet — die Sprache kann sich selbst parsen.

08

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/harry/pipe/actions/runs"

failed: filter (get ci_data "workflow_runs")
    (fn run: (get run "conclusion") == "failure")

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 lambda predicate 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 einem Lambda-Prädikat 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.

More Examples

Weitere Beispiele

Find 23 example programs in the repository: github.com/MachuraHarry/pipe/examples

23 Beispielprogramme im Repository: github.com/MachuraHarry/pipe/examples