Main Components

Core building blocks for AI agents and pipelines in BoxLang - your guide to mastering AI development

Welcome to the heart of BoxLang AI! This section introduces the essential building blocks you'll use to create intelligent applications. Whether you're building chatbots, autonomous agents, or complex AI workflows, these components are your toolkit.

🎯 What You'll Learn

BoxLang AI uses a runnable pipeline architecture - think of it as composable LEGO blocks for AI:

┌─────────────┐    ┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│  Messages   │───▶│  AI Model   │───▶│ Transform   │───▶│   Result    │
│  Template   │    │  (OpenAI)   │    │  (Extract)  │    │             │
└─────────────┘    └─────────────┘    └─────────────┘    └─────────────┘

Each component:

  • 🔗 Chains easily - Connect pieces with .to()

  • ♻️ Reuses workflows - Define once, run many times

  • 🧩 Composes freely - Mix and match as needed

  • 🎯 Stays flexible - Swap providers without refactoring


📚 Learning Path

We recommend learning the components in this order for the best experience:

START HERE

┌──────────────────────────────────────────────────────────────┐
│ 1️⃣ Models - Connect to AI providers (OpenAI, Claude, etc.)   │
└──────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────┐
│ 2️⃣ Messages - Build conversations with templates             │
└──────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────┐
│ 3️⃣ Streaming - Real-time responses for better UX             │
└──────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────┐
│ 4️⃣ Structured Output - Extract typed data from responses     │
└──────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────┐
│ 5️⃣ Tools - Enable AI to call your functions                  │
└──────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────┐
│ 6️⃣ Memory - Maintain conversation context                    │
└──────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────┐
│ 7️⃣ Agents - Autonomous AI with memory & tools                │
└──────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────┐
│ 8️⃣ Pipelines - Build composable AI workflows                 │
└──────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────┐
│ 9️⃣ Transformers - Data processing in pipelines               │
└──────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────┐
│ 🔟 Vector Memory - Semantic search for RAG apps              │
└──────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────┐
│ 1️⃣1️⃣ Document Loaders - Import content from any source       │
└──────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────┐
│ 1️⃣2️⃣ RAG - Complete retrieval-augmented generation workflow  │
└──────────────────────────────────────────────────────────────┘

Quick Paths:

  • 🚀 Building a chatbot? → Start with Models → Messages → Memory → Agents

  • 📊 Extracting data? → Start with Models → Structured Output → Transformers → Pipelines

  • 🔍 Building RAG? → Start with Document Loaders → Vector Memory → RAG → Agents

  • 🛠️ Creating workflows? → Start with Models → Transformers → Pipelines → Agents


🧱 Core Components

1️⃣ AI Models

What: Direct AI provider integrations (OpenAI, Claude, Gemini, Ollama, etc.)

When to use: Every AI application - this is your foundation

Quick example:

Key concepts:

  • Provider abstraction

  • Parameter configuration

  • Return formats (text, JSON, XML, raw)

  • Pipeline composition

Read Models Guide


2️⃣ Messages

What: Reusable message templates with dynamic placeholders and multi-modal content

When to use: Repeated prompts, variable content, organized conversations

Quick example:

Key concepts:

  • Role-based messages (system, user, assistant)

  • Variable binding with ${} placeholders

  • Multimodal content (images, audio, documents)

  • Message reusability

Read Messages Guide


3️⃣ Streaming

What: Real-time token-by-token response delivery

When to use: Interactive UIs, chatbots, long responses

Quick example:

Key concepts:

  • Callback functions

  • Progressive UI updates

  • Streaming with agents

  • Performance optimization

Read Streaming Guide


What: Extract typed data from AI responses into classes/structs

When to use: Form extraction, data parsing, type-safe results

Quick example:

Key concepts:

  • Class population

  • JSON schema generation

  • Array extraction

  • Validation

Read Structured Output Guide


5️⃣ Tools

What: Functions that AI can call to access data or perform actions

When to use: Real-time data, external APIs, database queries

Quick example:

Key concepts:

  • Function calling

  • Parameter schemas

  • Tool registration

  • Autonomous invocation

Read Tools Guide


6️⃣ Memory

What: Conversation context management strategies

When to use: Multi-turn conversations, context preservation

Quick example:

Key concepts:

  • Memory types (windowed, summary, session, file)

  • Context limits

  • Memory persistence

  • Multiple memory strategies

Read Memory Guide


7️⃣ Agents

What: Autonomous AI entities with memory, tools, and reasoning

When to use: Complex workflows, multi-step tasks, autonomous behavior

Quick example:

Key concepts:

  • Autonomous reasoning

  • Tool selection

  • Memory integration

  • Sub-agents

Read Agents Guide


8️⃣ Pipelines

What: Composable AI workflows - chain models, messages, and transformers

When to use: Complex multi-step workflows, reusable templates, data processing flows

Quick example:

Key concepts:

  • Runnable interface (IAiRunnable)

  • Fluent chaining with .to()

  • Template reusability

  • Multi-step workflows

  • Data flow and transformations

Read Pipelines Guide


9️⃣ Transformers

What: Data processing steps in pipelines

When to use: Format conversion, data extraction, custom logic

Quick example:

Key concepts:

  • Pipeline transformations

  • Data extraction

  • Format conversion

  • Custom processors

Read Transformers Guide


What: Semantic search through conversation history

When to use: RAG applications, knowledge bases, semantic retrieval

Quick example:

Key concepts:

  • Embedding generation

  • Similarity search

  • Vector stores (Chroma, Pinecone, etc.)

  • RAG workflows

Read Vector Memory Guide


1️⃣1️⃣ Document Loaders

What: Import content from files, directories, URLs, databases, and APIs

When to use: Building knowledge bases, RAG systems, data ingestion pipelines

Quick example:

Key concepts:

  • 12+ built-in loaders (Text, Markdown, CSV, JSON, XML, PDF, etc.)

  • Automatic metadata extraction

  • Chunking strategies

  • Directory traversal

  • Direct vector memory integration

Read Document Loaders Guide


What: Complete workflow for answering questions using your documents

When to use: Q&A systems, documentation search, knowledge bases, chatbots with domain expertise

Quick example:

Key concepts:

  • Document loading and chunking

  • Embedding generation

  • Vector similarity search

  • Context injection

  • Source attribution

  • Hybrid search (keyword + semantic)

Read RAG Guide


🔗 Understanding Pipelines

Pipelines are the foundation of BoxLang AI - they connect components into workflows:

Basic Pipeline Flow

The .to() Method

Chain components together:

Pipeline Benefits

Example - Reusable Pipeline:


🎨 Common Patterns

Pattern 1: Simple Q&A

Pattern 2: Templated Conversations

Pattern 3: Agent with Tools

Pattern 4: RAG (Retrieval Augmented Generation)

Pattern 5: Multi-Step Processing


🚀 Quick Start Examples

Example 1: Your First Pipeline (3 lines)

Example 2: Chatbot with Memory (5 lines)

Example 3: Function Calling (8 lines)

Example 4: Data Extraction (6 lines)


💡 Tips for Success

  1. Start simple - Master models and messages before agents

  2. Test incrementally - Build pipelines step by step

  3. Reuse components - Create libraries of templates and agents

  4. Monitor costs - Use appropriate models for each task

  5. Read the guides - Each component page has detailed examples

Ready to build? Start with AI Models →

Last updated