← back to Interiordesignershowroom
lib/hotspots.js
29 lines
// Hotspot-locate DISPATCHER (TK-11260, following the TK-10402 SCENE_PROVIDER pattern).
// Selects the vision backend by HOTSPOT_PROVIDER so a depleted provider is a one-flag flip:
//
// HOTSPOT_PROVIDER=gemini (default) — Gemini 2.5 Flash, ~$0.001/room. Cheapest.
// HOTSPOT_PROVIDER=openai — gpt-5.2 vision fallback, ~$0.005/room. Needs a
// funded OPENAI_API_KEY (already routed via secrets).
//
// Both providers export the same contract { locateProducts(imagePath, products), COST_PER_CALL },
// so every caller (server.js /api/rooms, scripts/backfill-room-scenes.js, the one-off
// hotspots-only backfill) is untouched. Adding a new backend = drop a
// lib/hotspot-providers/<name>.js exporting that contract + name it here.
const PROVIDERS = {
gemini: () => require('./hotspot-providers/gemini'),
openai: () => require('./hotspot-providers/openai'),
};
const NAME = (process.env.HOTSPOT_PROVIDER || 'gemini').toLowerCase();
const load = PROVIDERS[NAME];
if (!load) {
throw new Error(`Unknown HOTSPOT_PROVIDER "${NAME}". Valid: ${Object.keys(PROVIDERS).join(', ')}`);
}
const provider = load();
module.exports = {
PROVIDER: NAME,
locateProducts: provider.locateProducts,
COST_PER_CALL: provider.COST_PER_CALL,
};