Spaces:
Running
Running
File size: 3,424 Bytes
9d5af77 00235a3 9d5af77 08b98ed 9d5af77 c1c5ecb 9d5af77 c1c5ecb 9d5af77 c1c5ecb 9d5af77 216837a 00235a3 216837a c1c5ecb 9d5af77 c1c5ecb 323c8ef c1c5ecb 323c8ef c1c5ecb fd5b9aa c1c5ecb 216837a c1c5ecb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | ---
title: Vera Engine
emoji: π
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 8080
pinned: false
---
# π Vera Engine v1.0
[](https://fastapi.tiangolo.com/)
[](https://www.docker.com/)
[](https://www.python.org/)
[](https://github.com/ggerganov/llama.cpp)
> **High-Performance AI Orchestrator optimized for the magicpin Vera AI Challenge.**
---
## ποΈ 1. The Architecture
The system operates on a highly optimized, deterministic fail-fast fallback cascade to guarantee sub-30-second responses on constrained Hugging Face Spaces (2vCPU / 16GB RAM) without compromising reasoning quality.
### π 4-Tier Fail-Fast Cascade
Instead of relying on a single point of failure, the engine delegates composition to a highly available 4-tier chain:
1. **Tier 1 (Speed & Intelligence)**: NVIDIA NIM (`nvidia/nemotron-3-ultra-550b-a55b`) - 5s timeout.
2. **Tier 2 (Fast Failover)**: Groq (`openai/gpt-oss-20b`) - 4s timeout.
3. **Tier 3 (Secondary Failover)**: Gemini (`gemini-2.5-flash`) - 4s timeout.
4. **Tier 4 (Local Airgap)**: Natively executed `qwen2.5-7b-instruct` or `qwen2.5-3b-instruct` (based on system latency) via `llama-cpp-python` with **strict LlamaGrammar enforcement**.
> [!TIP]
> **Dynamic Time Budgeting**
> If an API returns a `401` or `429`, the orchestrator immediately short-circuits to the next tier. Cloud timeouts are strictly capped at 13 seconds cumulative worst-case, reserving a guaranteed 14-second budget for the local airgapped model.
---
## β‘ 2. Pipeline Strategy
1. **Context Distiller**: Instantly processes 500KB+ JSON payloads into dense factual bullet points in `< 0.001s`.
2. **LLM Expander**: Takes strict facts and expands them into compelling, natively conversational WhatsApp replies (supporting Hinglish code-mixing).
3. **Auto-Repair Loop**: Automatically intercepts taboo violations, word-count breaches, and CTA proliferation, dynamically calculating time budgets to fire an intra-tier self-correction prompt before failing over.
4. **Strict Schema Constraints**: Hardware-level `LlamaGrammar` (Local) and `json_object` format (Cloud) guarantee zero JSON parsing failures.
---
## π 3. API Contract
| Endpoint | Method | Purpose | Response Schema |
| :--- | :--- | :--- | :--- |
| `/v1/healthz` | **GET** | Compliant Liveness Probe | `{"status": "ok", "uptime_seconds": 100}` |
| `/v1/metadata` | **GET** | System Identity | `{"version": "1.0", "model": "..."}` |
| `/v1/context` | **POST** | Elastic Context Ingestion | `{"accepted": true}` |
| `/v1/tick` | **POST** | Atomic Trigger Processing | `{"actions": [...]}` |
| `/v1/reply` | **POST** | Escalated Shield Handling | `{"action": "send|wait|end"}` |
---
## π οΈ 4. Technical Stack
* **Framework**: FastAPI / Uvicorn (Port `8080`)
* **Local SLM Execution**: `llama-cpp-python` (Pre-compiled CPU Wheels)
* **Models**: `Nemotron 3 Ultra 550B`, `GPT OSS 20B`, `Gemini 2.5 Flash`, `Qwen2.5 7B/3B`
* **Infrastructure**: Dockerized `python:3.10-slim` on Hugging Face Spaces
|