Natural Language → Spring Expression Language (SpEL) Generation Engine
>
       Four-layer hybrid architecture (Pattern Matching + Semantic Slots + LLM API + WebLLM Local), supporting Chinese & English
- You're building a no-code / low-code platform that needs expression generation from user text
- You want to bridge natural language and SpEL in a rules engine, workflow builder, or chatbot
- You need offline-first expression generation (Layers 0–1 require zero network calls)
- You want multi-LLM flexibility — swap between DeepSeek, OpenAI, GLM, Copilot, or run fully local in the browser
┌─────────────────────────────────┐
│ NL2SpEL Engine │
│ generate({ offlineOnly, ... }) │
│ generateBatch / explain │
└───────────────┬─────────────────┘
│
┌───────────────▼─────────────────┐
│ StrategyRouter │
│ Pattern → Template → LLM │
└───────┬───────┬───────┬─────────┘
│ │ │
┌─────────────▼─┐ ┌──▼───┐ ┌▼──────────┐
│ Layer 0 │ │Layer1│ │ Layer 2 │
│ Pattern Match │ │ Templ│ │ LLM API │
│ (63 patterns) │ │ (15 │ │ (7 presets│
│ < 1ms P99 │ │intents│ │ + custom) │
└────────────────┘ └──────┘ └────────────┘
│
┌─────────▼─────────┐
│ Layer 3 (optional)│
│ WebLLM + GBNF │
│ Browser-only │
└────────────────────┘
| Package | Description | Tests | Dependencies | ||
|---|---|---|---|---|---|
@agentix-e/nl2spel | Core Engine | 534 | Zero external deps | ||
@agentix-e/nl2spel-openai | LLM API Provider | 43 | core | ||
@agentix-e/nl2spel-webllm | Browser-local LLM | 73 | core | ||
| Metric | Target | Actual | |||
| Pattern match latency (P99) | ≤ 1ms | < 0.5ms | |||
| Template generation latency | ≤ 10ms | < 5ms | |||
| Intent classification | < 5ms | < 2ms | |||
| Difficulty | Tests | Pattern | Template | LLM (GPT-4o-mini) | Combined Target |
| - | - | - | |||
| Easy | 50 | 80% | 10% | 5% | ≥ 95% |
| Medium | 70 | — | 60% | 28% | ≥ 88% |
| Hard | 30 | — | — | 80% | ≥ 80% |
| Difficulty | Combined Target | ||||
| -- | |||||
| Easy (50 tests) | ≥ 95% | ||||
| Medium (70 tests) | ≥ 88% | ||||
| Hard (30 tests) | ≥ 80% |