Added AI damage helper

This commit is contained in:
SepehrYahyaee
2026-10-03 16:38:48 +03:30
parent 18ccfa81e4
commit 2f92766689
22 changed files with 1085 additions and 442 deletions
+12 -19
View File
@@ -422,28 +422,21 @@
</div>
<!-- ═══════════════════════════════════════════════════════════ -->
<h2 id="ai">7 — AI Service <span class="status-badge status-disabled">disabled (code present)</span></h2>
<h2 id="ai">7 — AI Damage Companion <span class="status-badge status-partial">opt-in development rollout</span></h2>
<p class="section-intro">
An image-based car damage detection service is integrated in the
codebase but its HTTP calls are <strong>fully commented out</strong>.
The module initialises on startup, attempts a login (silently swallowed
if it fails), and exposes an <code>aiRequestImage</code> method — but
the underlying axios calls are disabled. The service does not affect
any production flow.
Damaged-part uploads schedule persisted background analysis in <code>ai-damage-jobs</code>.
Expert review shows the original photo with client-drawn bounding boxes, per-detection severity,
confidence, side and Persian reports. The AI does not set prices, change selected parts,
advance workflow steps, or replace the expert decision.
</p>
<div class="card card-yellow">
<h3>Intended interface (when re-enabled)</h3>
<h3>Development pipeline</h3>
<table>
<tr><th style="width:70px">Method</th><th>Path</th><th>What it does</th></tr>
<tr><td><span class="method post">POST</span></td><td><code>{AI_URL_V2}/auth/login</code></td><td>Authenticate with username + password. Returns <code>accessToken</code>.</td></tr>
<tr><td><span class="method get">GET</span></td><td><code>{AI_URL_V2}/auth/profile</code></td><td>Fetch <code>apiKey.key</code> needed as the <code>gateway-api-key</code> request header.</td></tr>
<tr><td><span class="method post">POST</span></td><td><code>{AI_URL_V2}/services/car-damage/detector?version=ai-v7</code></td><td>Submit a car part image (multipart). Returns <code>downloadLink</code> with annotated result.</td></tr>
<tr><td><span class="method post">POST</span></td><td><code>{AI_DAMAGE_URL}/pipeline/detect_parts_with_damages?side=true&amp;segments=true&amp;bounding_box=true&amp;severity=true&amp;confidence=true</code></td><td>One JPEG per multipart <code>images</code> request. Returns JSON detections and reports; no image URL or pricing.</td></tr>
</table>
<p class="warn" style="margin-top:8px;">
Status: all three calls are wrapped in commented-out <code>axios.request(…)</code> blocks.
<code>CW_URL</code> is not in <code>.env.example</code>. To re-enable, uncomment the login, getApiKey, and aiRequestImage axios calls, and configure <code>AI_URL_V2</code>, <code>AI_USERNAME</code>, <code>AI_PASSWORD</code>.
</p>
<p class="note">Disabled unless <code>AI_DAMAGE_ENABLED=true</code>. Atomic leases recover jobs after restart; transient errors receive bounded retries. Uploads and expert review continue when AI is unavailable. Replaced or removed photos are excluded from the live AI tab. Older current captures are scheduled when an authorized reviewer opens the tab.</p>
<p><a href="ai-damage-companion.md">Configuration, result contract, access controls and rollout checks</a></p>
</div>
<!-- ═══════════════════════════════════════════════════════════ -->
@@ -563,9 +556,9 @@
<h3>AI service</h3>
<table class="env-table">
<tr><th>Variable</th><th>Description</th></tr>
<tr><td><code>AI_URL_V2</code></td><td>AI gateway base URL. Default: <code>https://ai-gw.ittalie.ir</code> (unused — service is disabled)</td></tr>
<tr><td><code>AI_USERNAME</code></td><td>AI service login username (unused)</td></tr>
<tr><td><code>AI_PASSWORD</code></td><td>AI service login password (unused)</td></tr>
<tr><td><code>AI_DAMAGE_ENABLED</code></td><td>Explicit opt-in (<code>true</code>); defaults to disabled.</td></tr>
<tr><td><code>AI_DAMAGE_URL</code></td><td>Development base URL: <code>http://79.132.207.77:30527</code>. Required when enabled.</td></tr>
<tr><td><code>AI_DAMAGE_TIMEOUT_MS</code></td><td>Request timeout; default 180000 ms (1000–600000).</td></tr>
</table>
</div>