diff --git a/inventory-server/src/routes/ai-validation.js b/inventory-server/src/routes/ai-validation.js index 28b6aa8..5dd1684 100644 --- a/inventory-server/src/routes/ai-validation.js +++ b/inventory-server/src/routes/ai-validation.js @@ -53,7 +53,7 @@ router.get('/debug', async (req, res) => { console.log('Loading prompt...'); const currentPrompt = await loadPrompt(pool); const sampleData = [{ name: "Sample Product" }]; - const fullPrompt = currentPrompt + '\n' + JSON.stringify(sampleData, null, 2); + const fullPrompt = currentPrompt + '\n' + JSON.stringify(sampleData); const response = { cacheStatus: { @@ -173,10 +173,9 @@ async function getTaxonomyData(pool) { .filter(item => item.level_order === level && item.master_cat_id === parentId) .map(item => { const children = formatHierarchy(items, level + 1, item.cat_id); - return { - name: item.name, - ...(children.length > 0 ? { subcategories: children } : {}) - }; + return children.length > 0 ? + [item.cat_id, item.name, children] : + [item.cat_id, item.name]; }); }; @@ -187,20 +186,19 @@ async function getTaxonomyData(pool) { .map(item => { const subthemes = items .filter(subitem => subitem.master_cat_id === item.cat_id) - .map(subitem => subitem.name); - return { - name: item.name, - ...(subthemes.length > 0 ? { subthemes } : {}) - }; + .map(subitem => [subitem.cat_id, subitem.name]); + return subthemes.length > 0 ? + [item.cat_id, item.name, subthemes] : + [item.cat_id, item.name]; }); }; cache.taxonomyData = { categories: formatHierarchy(categories), themes: formatThemes(themes), - colors: colors.map(c => c.name), - taxCodes: (taxCodes || []).map(tc => ({ id: tc.tax_code_id, name: tc.name })), - sizeCategories: (sizeCategories || []).map(sc => ({ id: sc.cat_id, name: sc.name })) + colors: colors.map(c => [c.color, c.name]), + taxCodes: (taxCodes || []).map(tc => [tc.tax_code_id, tc.name]), + sizeCategories: (sizeCategories || []).map(sc => [sc.cat_id, sc.name]) }; cache.lastUpdated = Date.now(); @@ -260,7 +258,7 @@ router.post('/validate', async (req, res) => { // Load the prompt and append the products data const basePrompt = await loadPrompt(req.app.locals.pool); - const fullPrompt = basePrompt + '\n' + JSON.stringify(products, null, 2); + const fullPrompt = basePrompt + '\n' + JSON.stringify(products); console.log('📝 Generated prompt:', fullPrompt); console.log('🤖 Sending request to OpenAI...'); diff --git a/inventory/src/pages/AiValidationDebug.tsx b/inventory/src/pages/AiValidationDebug.tsx index 31d40f1..23c8f0b 100644 --- a/inventory/src/pages/AiValidationDebug.tsx +++ b/inventory/src/pages/AiValidationDebug.tsx @@ -168,7 +168,7 @@ export function AiValidationDebug() { id="costPerMillion" type="number" className="w-full px-3 py-2 border rounded-md" - defaultValue="3" + defaultValue="2.50" onChange={(e) => { const costPerMillion = parseFloat(e.target.value) if (!isNaN(costPerMillion)) {