feat(pos): add inventory-aware chat context (#31) and VIN decoder (#17)

Chat now fetches tenant inventory summary (brands, counts, low-stock)
and injects it into the AI system prompt so responses prioritize local
stock. VIN decoder uses free NHTSA vPIC API to decode 17-char VINs and
auto-fills the vehicle selector dropdowns when a catalog match is found.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-04 08:14:45 +00:00
parent 5d5a2777eb
commit f9589f4a4e
6 changed files with 406 additions and 5 deletions

View File

@@ -23,8 +23,23 @@ def chat():
history = body.get("history") or []
# Call AI
ai_response = ai_chat.chat(user_message, history)
# Fetch inventory context so the AI knows what this tenant has in stock
inventory_context = None
tenant_for_context = None
try:
tenant_for_context = get_tenant_conn(g.tenant_id)
inventory_context = ai_chat.get_inventory_context(tenant_for_context, g.branch_id)
except Exception:
pass
finally:
if tenant_for_context:
try:
tenant_for_context.close()
except Exception:
pass
# Call AI with inventory context
ai_response = ai_chat.chat(user_message, history, inventory_context=inventory_context)
search_results = []
vehicle_match = None