Real-Time Inference Pipelines, JSON-RPC & Streaming API Hooks
Architectural runbook on streaming token generation, JSON-RPC endpoints, and asynchronous Celery/cron task dispatch.
1. Overview & Technical Architecture#
SmartERP supports both synchronous streaming inference for interactive chat and asynchronous batch pipelines for bulk document processing.
1. Streaming Server-Sent Events (SSE) Protocol#
When users interact with the floating chat interface (chat_composer.js), the frontend establishes an SSE connection to /ashewa_ai/stream, rendering tokens as they are generated by the model.
Client (OWL) ββ> POST /ashewa_ai/stream ββ> Odoo Controller ββ> vLLM Stream
Client <ββ Token Chunk 1 <ββ Yield Chunk 1 <ββ SSE Stream
Client <ββ Token Chunk 2 <ββ Yield Chunk 2 <ββ SSE Stream
Client <ββ [DONE] <ββ Finalize <ββ Close
2. Python ORM Service Hooks#
Developers can invoke model inference directly from any Odoo model method using self.env['muk_ai.provider']:
# Example ORM Method Invocation
provider = self.env['muk_ai.provider'].search([('code', '=', 'sovereign')], limit=1)
response = provider.generate_text(
prompt="Audit vendor bill INV/2026/0014 for duplicate line items.",
temperature=0.1,
max_tokens=2048,
)
2. Prerequisites & Infrastructure Requirements#
- Runtime Environment: Python 3.12+, PostgreSQL 16 with
pgvectorextension. - Security Access Group:
Ashewa AI / Administrator(Technical ID:muk_ai.group_ai_manager) - Hardware Profile: Minimum 16 GB System RAM (CPU inference) or NVIDIA GPU with 8+ GB VRAM.
3. Step-by-Step Configuration & Verification#
Step 1: Navigating to Model Management#
- Access your SmartERP instance at
https://smarterp.et/odoo. - Open Settings β Technical β Ashewa AI β Model Registry.
- Select the custom model profile.
{screenshot:40-inference-pipelines-and-api-hooks-step1-navigation}
Step 2: Testing Endpoint Health & Response Verification#
- Click the Run Diagnostic Health Check button.
- Verify token generation speed (tokens/sec) and latency benchmarks.
- Review sample response in the diagnostic console.
{screenshot:40-inference-pipelines-and-api-hooks-step2-verification}
4. Advanced Configuration Points#
- Automated Tasks:
muk_ai.ir_cron_model_health_monitorruns every 15 minutes. - Multi-Tenant Boundaries: Custom model fine-tuning adapters are strictly segregated per tenant database.
5. Comprehensive Troubleshooting Matrix#
| Symptom / Error | Probable Root Cause | Resolution Action |
|---|---|---|
Connection refused: Model server unreachable | Inference daemon stopped or port blocked by firewall. | Restart model service (systemctl restart vllm) and verify firewall rules. |
Token limit exceeded on input prompt | Input context exceeded window size. | Enable context truncation in model profile settings. |
Last updated: 2026-10-30