mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-12 17:57:09 +02:00
feat(ai): update batch analysis to use global supplier weight (CA/Margin)
This commit is contained in:
1 parent
c89e046dee
commit
0bb73ebcca
2 files changed
+33
-13
No files matched your search
@@ -14,7 +14,10 @@ export function BulkAiAnalyzer() {
|
||||
|
||||
const handleAnalyze = async () => {
|
||||
const { rows } = useGridStore.getState();
|
||||
console.log("[BulkAiAnalyzer] Starting analysis on", rows.length, "rows");
|
||||
const supplierTotalCa = rows.reduce((acc, row) => acc + (row.totalCa || 0), 0);
|
||||
const supplierTotalMarge = rows.reduce((acc, row) => acc + (row.totalMarge || 0), 0);
|
||||
|
||||
console.log("[BulkAiAnalyzer] Starting analysis on", rows.length, "rows", { supplierTotalCa, supplierTotalMarge });
|
||||
|
||||
setIsAnalyzing(true);
|
||||
let completed = 0;
|
||||
@@ -67,7 +70,12 @@ export function BulkAiAnalyzer() {
|
||||
res = await fetch("/api/ai/batch-analyze", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ rayon: chunk.rayon, products: payloadProducts })
|
||||
body: JSON.stringify({
|
||||
rayon: chunk.rayon,
|
||||
products: payloadProducts,
|
||||
supplierTotalCa,
|
||||
supplierTotalMarge
|
||||
})
|
||||
});
|
||||
|
||||
if (res.status === 429 && attempt < MAX_CHUNK_RETRIES) {
|
||||
|
||||
Reference in new issue
Block a user