AbapGit
A source-verified project description is not available yet. Open the detail page or wait for a manual refresh.
Source facts need a manual refresh
LangChain-lite for ABAP: Enterprise LLM orchestration framework with lazy execution, powerful templating, caching, and token prediction. Build complex AI workflows in SAP ERP, SAP S/4.
LangChain-lite for ABAP: Enterprise LLM orchestration framework with lazy execution, powerful templating, caching, and token prediction. Build complex AI workflows in SAP ERP, SAP S/4.
ZLLM is a sophisticated "LangChain-lite" framework that brings the power of Large Language Model (LLM) orchestration to SAP/ABAP systems. Think of it as LangChain's enterprise-ready cousin, specifically designed for ABAP developers who need to build complex AI-powered workflows within their SAP landscape.
Like LangChain, ZLLM provides:
But optimized for enterprise ABAP:
For a deep-dive into the framework and its capabilities, please see the GUIDE.md.
{T-CUSTOMER-NAME})ZLLM_CODEC parameter" Create LLM instance and execute a simple query
DATA(lo_llm) = zcl_llm=>new( 'DEFAULT.ENV' ).
DATA(lo_step) = zcl_llm_00_step_lazy=>new_from_string(
iv_usr = 'Explain cloud computing in simple terms'
io_llm = lo_llm
).
DATA(lr_result) = lo_step->exec( ).
" Create a two-step flow: generate content, then summarize it
DATA(lo_step1) = zcl_llm_00_step_lazy=>new_from_string(
iv_usr = 'Write a detailed explanation of quantum computing'
io_llm = lo_llm
).
DATA(lo_step2) = zcl_llm_00_step_lazy=>new_from_string(
iv_usr = 'Summarize this in 3 bullet points: {T}' " {T} contains result from step1
io_llm = lo_llm
).
DATA(lo_flow) = zcl_llm_00_flow_lazy=>new(
VALUE #( ( lo_step1 ) ( lo_step2 ) )
).
DATA(lo_result) = lo_flow->exec( ).
" Process structured data with templates
DATA: BEGIN OF ls_customer,
name TYPE string VALUE 'ACME Corp',
revenue TYPE p VALUE '1000000',
industry TYPE string VALUE 'Technology',
END OF ls_customer.
DATA(lo_pattern) = zcl_llm_00_pat=>new(
'Analyze this customer: Name: {T-NAME}, Revenue: ${T-REVENUE}, Industry: {T-INDUSTRY}'
).
DATA(lo_step) = zcl_llm_00_step_lazy=>new_from_pat(
io_pat_usr = lo_pattern
io_llm = lo_llm
).
DATA(lr_result) = lo_step->exec( REF #( ls_customer ) ).
" Process multiple documents in parallel
DATA(lo_parallel_step) = zcl_llm_00_step_lazy_parallel=>new(
io_step = lo_analysis_step
io_llm = lo_llm
).
DATA(lo_result) = lo_parallel_step->start( REF #( lt_documents ) ).
" Caching is ENABLED by default - all LLM responses are automatically cached
DATA(lo_llm) = zcl_llm=>new( 'DEFAULT.ENV' ). " Uses default cache
" To disable caching, inject a dummy cache:
DATA(lo_cache_never) = zcl_llm_00_cache_never=>new( ).
DATA(lo_llm_no_cache) = zcl_llm=>new(
iv_config = 'DEFAULT.ENV'
io_cache = lo_cache_never " This disables caching
).
" To use custom cache with specific seed:
DATA(lo_cache_custom) = zcl_llm_00_cache=>new( iv_seed = 42 ).
DATA(lo_llm_custom) = zcl_llm=>new(
iv_config = 'DEFAULT.ENV'
io_cache = lo_cache_custom
).
" Route to different models based on complexity
DATA(lo_llm_composite) = zcl_llm_00_llm_lazy_composite=>new(
io_llm = lo_llm_mini " For simple queries (<1000 tokens)
io_llm_exp = lo_llm_maxi " For complex queries
iv_threshold = 1000
).
ZLLM includes PREDICTOKEN, a sophisticated token prediction system that estimates token counts without API calls:
" Predict tokens before making expensive API calls
DATA(lv_predicted_tokens) = zcl_llm_00_predictoken=>predict_tokens_gpt4( lv_text ).
" Use prediction for smart routing
IF lv_predicted_tokens < 500.
lo_llm = lo_llm_mini. " Use cheaper model
ELSE.
lo_llm = lo_llm_maxi. " Use more capable model
ENDIF.
| Method | R² Score | Accuracy | Speed | Cost |
|---|---|---|---|---|
| Simple heuristics | 0.70-0.83 | ±15-23% | Instant | Free |
| PREDICTOKEN | 0.997 | ±3% | <1ms | Free |
| Actual tokenizer | 1.000 | Perfect | Network latency | API cost |
ZLLM supports multiple LLM providers through flexible .env configuration files:
# Local Ollama
API_MODEL=devstral
API_URL=http://192.168.8.107:11434/
API_KEY=ollama
API_MAX_TOKEN=64000
API_TOKEN_SPLIT_LIMIT=24000
# Azure OpenAI Configuration
API_AZURE_FULL_URL=https://yourdomain.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-01-01-preview
API_KEY=your-azure-api-key
#API_MAX_TOKEN=4000
#API_MODEL=gpt-4o # Optional: Override deployment name
API_MODEL=gpt-4o-mini
API_URL=https://api.openai.com/v1/
API_KEY=sk-your-api-key
API_MAX_TOKEN=16384
ZLLM_00_ONBOARD
ZLLM_00_FLOW_DEMO - See basic chaining in actionZLLM_00_REPL - Interactive development environmentZLLM is built on a sophisticated multi-layered architecture designed for enterprise-grade LLM orchestration:
┌─────────────────────────────────────────────────────────────┐
│ Application Layer │
│ • Demo Programs (ONBOARD, FLOW_DEMO, REPL, SYNC) │
│ • User Applications and Custom Workflows │
├─────────────────────────────────────────────────────────────┤
│ Flow Orchestration Layer │
│ • Steps (Lazy, Parallel) • Flows • Formulas • Patterns │
├─────────────────────────────────────────────────────────────┤
│ LLM Integration Layer │
│ • LLM Client • Load Balancer • Composite Router │
│ • Response Handler • Retry Logic • Throttling │
├─────────────────────────────────────────────────────────────┤
│ Support Services Layer │
│ • Cache System • File Abstraction • JSON Processing │
│ • Token Prediction • Markdown Rendering • Encoding │
├─────────────────────────────────────────────────────────────┤
│ Data Model Layer │
│ • Graph Storage (NODE/EDGE) • Binary Storage (BIN) │
│ • Cache Tables • Code Analytics • Documentation │
└─────────────────────────────────────────────────────────────┘
graph TB
subgraph User["User Layer"]
App[Application]
Demo[Demo Programs]
end
subgraph Core["Core Framework"]
Factory[ZCL_LLM<br/>Factory]
Step[Step Components]
Flow[Flow Engine]
Pattern[Pattern Engine]
end
subgraph Services["Services"]
Cache[Cache System]
Predictor[Token Predictor]
Files[File System]
end
subgraph Integration["LLM Integration"]
Client[LLM Client]
Balancer[Load Balancer]
Response[Response Handler]
end
App --> Factory
Demo --> Factory
Factory --> Step
Factory --> Flow
Step --> Pattern
Flow --> Step
Step --> Client
Client --> Cache
Client --> Balancer
Balancer --> Response
Client --> Predictor
The framework leverages custom tables for persistence and analytics:
| Table | Purpose | Typical Size |
|---|---|---|
| ZLLM_00_NODE | Graph nodes for code objects | 15,000+ rows |
| ZLLM_00_EDGE | Relationships between nodes | 500+ rows |
| ZLLM_00_CACHE | Persistent cache with encoding | 750+ rows |
| ZLLM_00_BIN | Binary file storage | 250+ rows |
| ZLLM_00_CCLM | Code lifecycle management | Analytics |
| ZLLM_00_DOC | Documentation storage | Metadata |
$ZLLM_00/ # Main package
├── Core/ # Core framework classes
│ ├── ZCL_LLM # Main factory
│ └── ZCL_LLM_00_* # Core components
├── Flow/ # Flow orchestration
│ ├── *_STEP_* # Step components
│ └── *_FLOW_* # Flow components
├── Pattern/ # Template system
│ ├── *_PAT* # Pattern engine
│ └── *_FORMULA* # Formula system
├── Infrastructure/ # Supporting services
│ ├── *_CACHE* # Cache system
│ ├── *_FILE_* # File abstraction
│ └── *_PREDICTOKEN* # Token prediction
└── Demo/ # Demo programs
├── ZLLM_00_ONBOARD # Setup wizard
├── ZLLM_00_FLOW_DEMO # Basic examples
├── ZLLM_00_REPL # Interactive env
└── ZLLM_00_SYNC # File sync utility
MIT License - see LICENSE file for details.