Status: 🚀 Phase 13 (v0.13.x) - Adaptive memory, context engineering, and 21 preset profiles
Lua scripting examples for LLMSpell - from basics to production applications
🔗 Navigation: ← Examples | Project Home | Getting Started | Applications
- 6 Getting Started Examples - Learn the basics step-by-step
- 5 Feature Demonstrations - Explore specific capabilities
- 16 Cookbook Patterns - Production-ready patterns (including 3 RAG patterns)
- 4 Advanced Patterns - Complex orchestration and integration
- 11 Complete Applications - Full production examples (2 RAG apps)
- 3 RAG Test Suites - Comprehensive RAG testing
- 1 RAG Benchmark - Performance measurement
- 21 Builtin Profiles - Zero-config quick start
- Custom Config Examples - For unique patterns
All examples work with builtin profiles - no configuration files needed:
# Tools and workflows (no LLM needed)
llmspell -p minimal run getting-started/00-hello-world.lua
# Agent examples (requires OpenAI/Anthropic API keys)
llmspell -p providers run getting-started/02-first-agent.lua
# State persistence examples
llmspell -p state run features/state-persistence.lua
# Memory & RAG examples (requires API key)
llmspell -p memory run getting-started/05-memory-rag-advanced.lua
# Local LLM examples (requires Ollama installed)
llmspell -p ollama run features/local-llm-status.lua- minimal - Tools only, no LLM providers
- development - Dev settings with OpenAI/Anthropic + debug logging
- providers - Simple OpenAI/Anthropic setup for agents
- state - State persistence enabled
- sessions - Sessions + state + hooks + events
- memory - Adaptive memory system (Phase 13)
- memory-development - Memory + RAG debugging
- ollama - Local Ollama LLM backend
- candle - Local Candle LLM backend (CPU/GPU)
- rag-dev - RAG development with debug features
- rag-prod - RAG production settings
See Profile Guide for all 21 profiles.
For advanced use cases, create a custom config file:
llmspell -c path/to/custom-config.toml run script.luascript-users/
├── getting-started/ # 6 beginner examples (00-05)
├── features/ # 5 feature demonstrations
├── cookbook/ # 16 production patterns (13 core + 3 RAG)
├── advanced-patterns/ # 4 complex orchestration examples
├── applications/ # 11 complete applications (9 base + 2 RAG)
├── tests/ # 3 RAG test suites
├── benchmarks/ # 1 performance benchmark
└── configs/ # Custom configuration examples (unique patterns)
Getting Started - 6 Examples
Progressive examples from hello world to RAG systems. Start here if you're new to LLMSpell.
Learning Path:
00-hello-world.lua- Simplest possible example01-first-tool.lua- Using your first tool (file operations)02-first-agent.lua- Creating your first agent03-first-workflow.lua- Building your first workflow04-handle-errors.lua- Proper error handling05-memory-rag-advanced.lua- Memory & RAG system (Phase 13)
Features - 5 Demonstrations
Comprehensive demonstrations of LLMSpell capabilities.
Available Demonstrations:
agent-basics.lua- Agent creation and managementtool-basics.lua- Using the 34+ built-in toolsworkflow-basics.lua- Workflow patterns and orchestrationstate-persistence.lua- State management with scopesprovider-info.lua- Provider configuration and detection
Cookbook - 11 Production Patterns
Battle-tested patterns and best practices for production use.
Core Patterns (v0.7.0):
01-error-handling.lua- Comprehensive error recovery strategies02-rate-limiting.lua- API quota and throttling management03-caching.lua- High-performance caching strategies04-multi-agent-coordination.lua- Agent collaboration patterns05-webhook-integration.lua- External system integration06-performance-monitoring.lua- Observability and metrics07-security-patterns.lua- Input validation and secure handling08-state-management.lua- Versioning and persistence
RAG Patterns:
RAG-01-rag-multi-tenant.lua- Isolated vector stores per tenantRAG-02-rag-session.lua- Conversational memory with contextRAG-03-rag-cost-optimization.lua- Reduce embedding costs by 70%
Applications - 9 Complete Applications
Complete, production-ready example applications.
Available Applications:
webapp-creator- Multi-agent web application generatorcode-review-assistant- Automated code review systemcontent-creator- Multi-format content generationcommunication-manager- Email and notification orchestrationfile-organizer- Intelligent file organization systemprocess-orchestrator- Complex workflow automationresearch-collector- v2.0 with RAG integrationknowledge-base- Personal knowledge managementpersonal-assistant- AI productivity companion
Advanced Patterns - 4 Complex Examples
Production-ready patterns bridging features and applications.
Advanced Patterns:
multi-agent-orchestration.lua- Complex agent coordinationcomplex-workflows.lua- Advanced workflow orchestrationtool-integration-patterns.lua- Tool chaining and integrationmonitoring-security.lua- Production monitoring and security
Tests - RAG Testing Suite
Comprehensive test suites for RAG functionality.
Test Files:
test-rag-basic.lua- Basic RAG operationstest-rag-e2e.lua- End-to-end RAG testingtest-rag-errors.lua- Error handling and edge cases
Benchmarks - Performance Measurement
rag-benchmark.lua- RAG performance benchmarking
Configs - Custom Configuration Examples
Custom configuration files for unique patterns and advanced scenarios.
Demonstration Configs:
- RAG configurations (basic, production, multi-tenant)
- Multi-provider setups
- Advanced session management
- Application-specific settings
Note: Most examples work with builtin profiles (-p profile-name). These configs demonstrate custom patterns for advanced use cases.
# Run with appropriate builtin profile
llmspell -p minimal run examples/script-users/getting-started/00-hello-world.lua
llmspell -p providers run examples/script-users/features/agent-basics.lua
llmspell -p rag-dev run examples/script-users/getting-started/05-memory-rag-advanced.lua
llmspell -p development run examples/script-users/applications/knowledge-base/main.luaFor unique patterns not covered by builtin profiles:
# With custom RAG configuration
llmspell -c examples/script-users/configs/rag-multi-tenant.toml \
run examples/script-users/cookbook/rag-multi-tenant.lua
# With application-specific configuration
llmspell -c examples/script-users/applications/webapp-creator/config.toml \
run examples/script-users/applications/webapp-creator/main.lua- LLMSpell installed (
cargo install llmspellor build from source) - No API keys required for basic examples
- API key for at least one provider:
- OpenAI: Set
OPENAI_API_KEYenvironment variable - Anthropic: Set
ANTHROPIC_API_KEYenvironment variable - Local models: Use
-p ollama-production(or see configs/ for custom patterns)
- OpenAI: Set
- Understanding of Lua basics
- Familiarity with async patterns
- Knowledge of error handling
This release introduces comprehensive adaptive memory and context engineering:
- Adaptive Memory: 3-tier memory system (episodic, semantic, procedural)
- Context Engineering: Strategy-based context assembly
- Vector Storage: HNSW algorithm for fast similarity search
- Multi-Tenancy: Complete isolation between tenant knowledge bases
- Session Management: Conversational memory with automatic cleanup
- 21 Preset Profiles: Zero-config deployment for any use case
- Production Ready: Battle-tested patterns for enterprise deployment
- Start with getting-started examples in order
- Try modifying examples to understand concepts
- Move to features for specific capabilities
- Study cookbook for production patterns
- Skim getting-started for LLMSpell specifics
- Jump to features for your use case
- Review cookbook for best practices
- Study applications for architecture patterns
- Start with cookbook patterns
- Review applications for complete examples
- Focus on error handling, monitoring, and performance
- Test thoroughly with your specific use case
All examples follow these standards:
- Clear Documentation: Comprehensive header with purpose, prerequisites, and usage
- Expected Output: Documented output for verification
- Error Handling: Production-ready error recovery patterns
- Security: No hardcoded secrets or credentials
- Self-Contained: Runnable without external dependencies (unless documented)
- Version Tagged: Examples marked with version (v0.7.0, v0.8.0)
- Complexity Levels: BEGINNER, INTERMEDIATE, PRODUCTION
- Time Estimates: Expected runtime documented
- Rust Developer Examples - For embedding LLMSpell
- User Guide - Comprehensive documentation
- Lua API Reference - Lua API documentation
- Tool Catalog - All 34+ tools
- Architecture Guide - System architecture