Spaces:
Running
Running
sunheycho
commited on
Commit
·
477a402
1
Parent(s):
7fb5af7
Fix frontend rendering issues causing white screen
Browse files- Update ProductComparison.js to handle actual backend data structure
- Fix productInfo rendering to use image1/image2 keys with product_type and key_features
- Simplify comparison, valueAnalysis, and recommendation rendering with fallback JSON display
- Add comprehensive fallback rendering for any unstructured data
- Should resolve white screen issue after analysis completion
- frontend/src/components/ProductComparison.js +63 -117
- product_comparison.py +2 -2
- static/asset-manifest.json +4 -4
- static/index.html +1 -1
- static/precache-manifest.49a0bba942346b3badf09e0c8ff37ae6.js +30 -0
- static/service-worker.js +1 -1
- static/static/js/main.7f0b632e.chunk.js +2 -0
- static/static/js/main.7f0b632e.chunk.js.map +0 -0
frontend/src/components/ProductComparison.js
CHANGED
@@ -352,44 +352,45 @@ const ProductComparison = () => {
|
|
352 |
|
353 |
{analysisResults.productInfo && (
|
354 |
<div>
|
355 |
-
|
356 |
-
<
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
|
|
393 |
</div>
|
394 |
)}
|
395 |
</CardContent>
|
@@ -405,35 +406,12 @@ const ProductComparison = () => {
|
|
405 |
|
406 |
{analysisResults.comparison && (
|
407 |
<div>
|
408 |
-
<Typography variant="
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
<th>Product A</th>
|
415 |
-
<th>Product B</th>
|
416 |
-
<th>Comparison</th>
|
417 |
-
</tr>
|
418 |
-
</thead>
|
419 |
-
<tbody>
|
420 |
-
{analysisResults.comparison.specs.map((spec, index) => (
|
421 |
-
<tr key={index}>
|
422 |
-
<td><strong>{spec.name}</strong></td>
|
423 |
-
<td>{spec.valueA}</td>
|
424 |
-
<td>{spec.valueB}</td>
|
425 |
-
<td>
|
426 |
-
<span className={spec.winner === 'A' ? classes.highlight : ''}>
|
427 |
-
{spec.comparison}
|
428 |
-
</span>
|
429 |
-
</td>
|
430 |
-
</tr>
|
431 |
-
))}
|
432 |
-
</tbody>
|
433 |
-
</table>
|
434 |
-
|
435 |
-
<Typography variant="subtitle1" style={{ marginTop: '16px' }}>Overall Comparison</Typography>
|
436 |
-
<Typography variant="body1">{analysisResults.comparison.summary}</Typography>
|
437 |
</div>
|
438 |
)}
|
439 |
</CardContent>
|
@@ -449,28 +427,12 @@ const ProductComparison = () => {
|
|
449 |
|
450 |
{analysisResults.valueAnalysis && (
|
451 |
<div>
|
452 |
-
<Typography variant="
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
<Typography variant="body1">
|
458 |
-
<strong>Product B:</strong> {analysisResults.valueAnalysis.priceB}
|
459 |
-
</Typography>
|
460 |
-
)}
|
461 |
-
|
462 |
-
<Typography variant="subtitle1" style={{ marginTop: '16px' }}>Value Analysis</Typography>
|
463 |
-
<Typography variant="body1">{analysisResults.valueAnalysis.analysis}</Typography>
|
464 |
-
|
465 |
-
<Typography variant="subtitle1" style={{ marginTop: '16px' }}>Price-to-Performance Score</Typography>
|
466 |
-
<Typography variant="body1">
|
467 |
-
<strong>Product A:</strong> {analysisResults.valueAnalysis.valueScoreA}/10
|
468 |
</Typography>
|
469 |
-
{analysisResults.valueAnalysis.valueScoreB && (
|
470 |
-
<Typography variant="body1">
|
471 |
-
<strong>Product B:</strong> {analysisResults.valueAnalysis.valueScoreB}/10
|
472 |
-
</Typography>
|
473 |
-
)}
|
474 |
</div>
|
475 |
)}
|
476 |
</CardContent>
|
@@ -486,37 +448,21 @@ const ProductComparison = () => {
|
|
486 |
|
487 |
{analysisResults.recommendation && (
|
488 |
<div>
|
489 |
-
<Typography variant="
|
490 |
-
|
|
|
|
|
|
|
491 |
</Typography>
|
492 |
-
|
493 |
-
|
494 |
-
|
|
|
|
|
|
|
|
|
|
|
495 |
</Typography>
|
496 |
-
|
497 |
-
<Typography variant="subtitle1" style={{ marginTop: '16px' }}>Alternative Products</Typography>
|
498 |
-
<ul>
|
499 |
-
{analysisResults.recommendation.alternatives.map((alt, index) => (
|
500 |
-
<li key={index}>
|
501 |
-
<Typography variant="body2">
|
502 |
-
<strong>{alt.name}</strong>: {alt.reason}
|
503 |
-
</Typography>
|
504 |
-
</li>
|
505 |
-
))}
|
506 |
-
</ul>
|
507 |
-
|
508 |
-
{analysisResults.recommendation.buyingTips && (
|
509 |
-
<>
|
510 |
-
<Typography variant="subtitle1" style={{ marginTop: '16px' }}>Buying Tips</Typography>
|
511 |
-
<ul>
|
512 |
-
{analysisResults.recommendation.buyingTips.map((tip, index) => (
|
513 |
-
<li key={index}>
|
514 |
-
<Typography variant="body2">{tip}</Typography>
|
515 |
-
</li>
|
516 |
-
))}
|
517 |
-
</ul>
|
518 |
-
</>
|
519 |
-
)}
|
520 |
</div>
|
521 |
)}
|
522 |
</CardContent>
|
|
|
352 |
|
353 |
{analysisResults.productInfo && (
|
354 |
<div>
|
355 |
+
{Object.entries(analysisResults.productInfo).map(([imageKey, productData], index) => (
|
356 |
+
<div key={imageKey} style={{ marginBottom: '24px' }}>
|
357 |
+
<Typography variant="subtitle1" gutterBottom>
|
358 |
+
<strong>Product {index + 1} ({imageKey})</strong>
|
359 |
+
</Typography>
|
360 |
+
|
361 |
+
<Typography variant="body1">
|
362 |
+
<strong>Type:</strong> {productData.product_type || 'Unknown'}
|
363 |
+
</Typography>
|
364 |
+
|
365 |
+
{productData.key_features && productData.key_features.length > 0 && (
|
366 |
+
<div style={{ marginTop: '12px' }}>
|
367 |
+
<Typography variant="subtitle2">Key Features:</Typography>
|
368 |
+
<ul>
|
369 |
+
{productData.key_features.map((feature, idx) => (
|
370 |
+
<li key={idx}>
|
371 |
+
<Typography variant="body2">{feature}</Typography>
|
372 |
+
</li>
|
373 |
+
))}
|
374 |
+
</ul>
|
375 |
+
</div>
|
376 |
+
)}
|
377 |
+
|
378 |
+
{analysisResults.specifications && analysisResults.specifications[imageKey] && (
|
379 |
+
<div style={{ marginTop: '12px' }}>
|
380 |
+
<Typography variant="subtitle2">Specifications:</Typography>
|
381 |
+
<ul>
|
382 |
+
{Object.entries(analysisResults.specifications[imageKey].specifications || {}).map(([key, value]) => (
|
383 |
+
<li key={key}>
|
384 |
+
<Typography variant="body2">
|
385 |
+
<strong>{key.replace('_', ' ')}:</strong> {Array.isArray(value) ? value.join(', ') : value}
|
386 |
+
</Typography>
|
387 |
+
</li>
|
388 |
+
))}
|
389 |
+
</ul>
|
390 |
+
</div>
|
391 |
+
)}
|
392 |
+
</div>
|
393 |
+
))}
|
394 |
</div>
|
395 |
)}
|
396 |
</CardContent>
|
|
|
406 |
|
407 |
{analysisResults.comparison && (
|
408 |
<div>
|
409 |
+
<Typography variant="body1" style={{ whiteSpace: 'pre-line', marginBottom: '16px' }}>
|
410 |
+
{typeof analysisResults.comparison === 'string'
|
411 |
+
? analysisResults.comparison
|
412 |
+
: JSON.stringify(analysisResults.comparison, null, 2)
|
413 |
+
}
|
414 |
+
</Typography>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
</div>
|
416 |
)}
|
417 |
</CardContent>
|
|
|
427 |
|
428 |
{analysisResults.valueAnalysis && (
|
429 |
<div>
|
430 |
+
<Typography variant="body1" style={{ whiteSpace: 'pre-line', marginBottom: '16px' }}>
|
431 |
+
{typeof analysisResults.valueAnalysis === 'string'
|
432 |
+
? analysisResults.valueAnalysis
|
433 |
+
: JSON.stringify(analysisResults.valueAnalysis, null, 2)
|
434 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
435 |
</Typography>
|
|
|
|
|
|
|
|
|
|
|
436 |
</div>
|
437 |
)}
|
438 |
</CardContent>
|
|
|
448 |
|
449 |
{analysisResults.recommendation && (
|
450 |
<div>
|
451 |
+
<Typography variant="body1" style={{ whiteSpace: 'pre-line', marginBottom: '16px' }}>
|
452 |
+
{typeof analysisResults.recommendation === 'string'
|
453 |
+
? analysisResults.recommendation
|
454 |
+
: JSON.stringify(analysisResults.recommendation, null, 2)
|
455 |
+
}
|
456 |
</Typography>
|
457 |
+
</div>
|
458 |
+
)}
|
459 |
+
|
460 |
+
{/* Fallback: Display all analysis results as JSON if no specific data found */}
|
461 |
+
{!analysisResults.recommendation && !analysisResults.valueAnalysis && !analysisResults.comparison && !analysisResults.productInfo && (
|
462 |
+
<div>
|
463 |
+
<Typography variant="body1" style={{ whiteSpace: 'pre-line', marginBottom: '16px' }}>
|
464 |
+
{JSON.stringify(analysisResults, null, 2)}
|
465 |
</Typography>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
466 |
</div>
|
467 |
)}
|
468 |
</CardContent>
|
product_comparison.py
CHANGED
@@ -164,11 +164,11 @@ class BaseAgent:
|
|
164 |
api_key = os.environ.get('OPENAI_API_KEY')
|
165 |
if api_key:
|
166 |
self.llm = ChatOpenAI(
|
167 |
-
model="gpt-
|
168 |
temperature=0.7,
|
169 |
api_key=api_key
|
170 |
)
|
171 |
-
print(f"Initialized {name} with ChatOpenAI (gpt-
|
172 |
else:
|
173 |
print(f"Warning: OPENAI_API_KEY not found. {name} will use fallback mode.")
|
174 |
self.llm = None
|
|
|
164 |
api_key = os.environ.get('OPENAI_API_KEY')
|
165 |
if api_key:
|
166 |
self.llm = ChatOpenAI(
|
167 |
+
model="gpt-4",
|
168 |
temperature=0.7,
|
169 |
api_key=api_key
|
170 |
)
|
171 |
+
print(f"Initialized {name} with ChatOpenAI (gpt-4)")
|
172 |
else:
|
173 |
print(f"Warning: OPENAI_API_KEY not found. {name} will use fallback mode.")
|
174 |
self.llm = None
|
static/asset-manifest.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
{
|
2 |
"files": {
|
3 |
"main.css": "/static/css/main.3b4eede1.chunk.css",
|
4 |
-
"main.js": "/static/js/main.
|
5 |
-
"main.js.map": "/static/js/main.
|
6 |
"runtime-main.js": "/static/js/runtime-main.1d79dee9.js",
|
7 |
"runtime-main.js.map": "/static/js/runtime-main.1d79dee9.js.map",
|
8 |
"static/js/2.e4d49f63.chunk.js": "/static/js/2.e4d49f63.chunk.js",
|
@@ -10,7 +10,7 @@
|
|
10 |
"static/js/3.10abbce4.chunk.js": "/static/js/3.10abbce4.chunk.js",
|
11 |
"static/js/3.10abbce4.chunk.js.map": "/static/js/3.10abbce4.chunk.js.map",
|
12 |
"index.html": "/index.html",
|
13 |
-
"precache-manifest.
|
14 |
"service-worker.js": "/service-worker.js",
|
15 |
"static/css/main.3b4eede1.chunk.css.map": "/static/css/main.3b4eede1.chunk.css.map",
|
16 |
"static/js/2.e4d49f63.chunk.js.LICENSE.txt": "/static/js/2.e4d49f63.chunk.js.LICENSE.txt"
|
@@ -19,6 +19,6 @@
|
|
19 |
"static/js/runtime-main.1d79dee9.js",
|
20 |
"static/js/2.e4d49f63.chunk.js",
|
21 |
"static/css/main.3b4eede1.chunk.css",
|
22 |
-
"static/js/main.
|
23 |
]
|
24 |
}
|
|
|
1 |
{
|
2 |
"files": {
|
3 |
"main.css": "/static/css/main.3b4eede1.chunk.css",
|
4 |
+
"main.js": "/static/js/main.7f0b632e.chunk.js",
|
5 |
+
"main.js.map": "/static/js/main.7f0b632e.chunk.js.map",
|
6 |
"runtime-main.js": "/static/js/runtime-main.1d79dee9.js",
|
7 |
"runtime-main.js.map": "/static/js/runtime-main.1d79dee9.js.map",
|
8 |
"static/js/2.e4d49f63.chunk.js": "/static/js/2.e4d49f63.chunk.js",
|
|
|
10 |
"static/js/3.10abbce4.chunk.js": "/static/js/3.10abbce4.chunk.js",
|
11 |
"static/js/3.10abbce4.chunk.js.map": "/static/js/3.10abbce4.chunk.js.map",
|
12 |
"index.html": "/index.html",
|
13 |
+
"precache-manifest.49a0bba942346b3badf09e0c8ff37ae6.js": "/precache-manifest.49a0bba942346b3badf09e0c8ff37ae6.js",
|
14 |
"service-worker.js": "/service-worker.js",
|
15 |
"static/css/main.3b4eede1.chunk.css.map": "/static/css/main.3b4eede1.chunk.css.map",
|
16 |
"static/js/2.e4d49f63.chunk.js.LICENSE.txt": "/static/js/2.e4d49f63.chunk.js.LICENSE.txt"
|
|
|
19 |
"static/js/runtime-main.1d79dee9.js",
|
20 |
"static/js/2.e4d49f63.chunk.js",
|
21 |
"static/css/main.3b4eede1.chunk.css",
|
22 |
+
"static/js/main.7f0b632e.chunk.js"
|
23 |
]
|
24 |
}
|
static/index.html
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Multi-Model Object Detection Demo"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Vision Web App</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"/><link href="/static/css/main.3b4eede1.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,i,a=r[0],c=r[1],l=r[2],f=0,s=[];f<a.length;f++)i=a[f],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&s.push(o[i][0]),o[i]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,l||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,a=1;a<t.length;a++){var c=t[a];0!==o[c]&&(n=!1)}n&&(u.splice(r--,1),e=i(i.s=t[0]))}return e}var n={},o={1:0},u=[];function i(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,i),t.l=!0,t.exports}i.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,a=document.createElement("script");a.charset="utf-8",a.timeout=120,i.nc&&a.setAttribute("nonce",i.nc),a.src=function(e){return i.p+"static/js/"+({}[e]||e)+"."+{3:"10abbce4"}[e]+".chunk.js"}(e);var c=new Error;u=function(r){a.onerror=a.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){u({type:"timeout",target:a})}),12e4);a.onerror=a.onload=u,document.head.appendChild(a)}return Promise.all(r)},i.m=e,i.c=n,i.d=function(e,r,t){i.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,r){if(1&r&&(e=i(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(i.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)i.d(t,n,function(r){return e[r]}.bind(null,n));return t},i.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(r,"a",r),r},i.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},i.p="/",i.oe=function(e){throw console.error(e),e};var a=this["webpackJsonpvision-web-app"]=this["webpackJsonpvision-web-app"]||[],c=a.push.bind(a);a.push=r,a=a.slice();for(var l=0;l<a.length;l++)r(a[l]);var p=c;t()}([])</script><script src="/static/js/2.e4d49f63.chunk.js"></script><script src="/static/js/main.
|
|
|
1 |
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Multi-Model Object Detection Demo"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Vision Web App</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"/><link href="/static/css/main.3b4eede1.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,i,a=r[0],c=r[1],l=r[2],f=0,s=[];f<a.length;f++)i=a[f],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&s.push(o[i][0]),o[i]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,l||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,a=1;a<t.length;a++){var c=t[a];0!==o[c]&&(n=!1)}n&&(u.splice(r--,1),e=i(i.s=t[0]))}return e}var n={},o={1:0},u=[];function i(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,i),t.l=!0,t.exports}i.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,a=document.createElement("script");a.charset="utf-8",a.timeout=120,i.nc&&a.setAttribute("nonce",i.nc),a.src=function(e){return i.p+"static/js/"+({}[e]||e)+"."+{3:"10abbce4"}[e]+".chunk.js"}(e);var c=new Error;u=function(r){a.onerror=a.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){u({type:"timeout",target:a})}),12e4);a.onerror=a.onload=u,document.head.appendChild(a)}return Promise.all(r)},i.m=e,i.c=n,i.d=function(e,r,t){i.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,r){if(1&r&&(e=i(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(i.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)i.d(t,n,function(r){return e[r]}.bind(null,n));return t},i.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(r,"a",r),r},i.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},i.p="/",i.oe=function(e){throw console.error(e),e};var a=this["webpackJsonpvision-web-app"]=this["webpackJsonpvision-web-app"]||[],c=a.push.bind(a);a.push=r,a=a.slice();for(var l=0;l<a.length;l++)r(a[l]);var p=c;t()}([])</script><script src="/static/js/2.e4d49f63.chunk.js"></script><script src="/static/js/main.7f0b632e.chunk.js"></script></body></html>
|
static/precache-manifest.49a0bba942346b3badf09e0c8ff37ae6.js
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
self.__precacheManifest = (self.__precacheManifest || []).concat([
|
2 |
+
{
|
3 |
+
"revision": "72fdef4e3c985c76a08b639b81a92472",
|
4 |
+
"url": "/index.html"
|
5 |
+
},
|
6 |
+
{
|
7 |
+
"revision": "39e2fc6e6441b86df1ef",
|
8 |
+
"url": "/static/css/main.3b4eede1.chunk.css"
|
9 |
+
},
|
10 |
+
{
|
11 |
+
"revision": "8c82444e1d7d7382cb08",
|
12 |
+
"url": "/static/js/2.e4d49f63.chunk.js"
|
13 |
+
},
|
14 |
+
{
|
15 |
+
"revision": "89a1b2dcd30c03705b2bceeb141b76b6",
|
16 |
+
"url": "/static/js/2.e4d49f63.chunk.js.LICENSE.txt"
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"revision": "3e950a8ed9ea38f208da",
|
20 |
+
"url": "/static/js/3.10abbce4.chunk.js"
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"revision": "39e2fc6e6441b86df1ef",
|
24 |
+
"url": "/static/js/main.7f0b632e.chunk.js"
|
25 |
+
},
|
26 |
+
{
|
27 |
+
"revision": "154c4b0ed16fd7552969",
|
28 |
+
"url": "/static/js/runtime-main.1d79dee9.js"
|
29 |
+
}
|
30 |
+
]);
|
static/service-worker.js
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
|
15 |
|
16 |
importScripts(
|
17 |
-
"/precache-manifest.
|
18 |
);
|
19 |
|
20 |
self.addEventListener('message', (event) => {
|
|
|
14 |
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
|
15 |
|
16 |
importScripts(
|
17 |
+
"/precache-manifest.49a0bba942346b3badf09e0c8ff37ae6.js"
|
18 |
);
|
19 |
|
20 |
self.addEventListener('message', (event) => {
|
static/static/js/main.7f0b632e.chunk.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
(this["webpackJsonpvision-web-app"]=this["webpackJsonpvision-web-app"]||[]).push([[0],{104:function(e,a,t){},105:function(e,a,t){"use strict";t.r(a);var n=t(0),r=t.n(n),l=t(11),o=t.n(l),c=(t(99),t(79)),i=t(165),s=t(169),m=t(166),d=t(167),u=t(49),g=t(171),p=t(161),E=t(168),y=t(142),f=t(83),b=t(147),h=t(140),v=t(141),x=t(65),S=t.n(x),C=t(76),j=t.n(C),w=t(137);const O=Object(w.a)(e=>({paper:{padding:e.spacing(2),display:"flex",flexDirection:"column",alignItems:"center",height:"100%",minHeight:300,transition:"all 0.3s ease"},dragActive:{border:"2px dashed #3f51b5",backgroundColor:"rgba(63, 81, 181, 0.05)"},dragInactive:{border:"2px dashed #ccc",backgroundColor:"white"},uploadBox:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",width:"100%",cursor:"pointer"},uploadIcon:{fontSize:60,color:"#3f51b5",marginBottom:e.spacing(2)},supportText:{marginTop:e.spacing(2)},previewBox:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%",height:"100%",position:"relative"},imageContainer:{position:"relative",width:"100%",height:"45vh",[e.breakpoints.down("sm")]:{height:"35vh"},display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginTop:e.spacing(2)},deleteButton:{position:"absolute",top:0,right:0,backgroundColor:"rgba(255, 255, 255, 0.7)","&:hover":{backgroundColor:"rgba(255, 255, 255, 0.9)"}}}));var N=e=>{let{onImageUpload:a}=e;const t=O(),[l,o]=Object(n.useState)(null),[c,i]=Object(n.useState)(!1),m=Object(n.useRef)(null),d=e=>{e.preventDefault(),e.stopPropagation(),"dragenter"===e.type||"dragover"===e.type?i(!0):"dragleave"===e.type&&i(!1)},g=e=>{e.type.startsWith("image/")?(o(URL.createObjectURL(e)),a(e)):alert("Please upload an image file")};return r.a.createElement(f.a,{className:"".concat(t.paper," ").concat(c?t.dragActive:t.dragInactive),onDragEnter:d,onDragLeave:d,onDragOver:d,onDrop:e=>{e.preventDefault(),e.stopPropagation(),i(!1),e.dataTransfer.files&&e.dataTransfer.files[0]&&g(e.dataTransfer.files[0])}},r.a.createElement("input",{ref:m,type:"file",accept:"image/*",onChange:e=>{e.preventDefault(),e.target.files&&e.target.files[0]&&g(e.target.files[0])},style:{display:"none"}}),l?r.a.createElement(s.a,{className:t.previewBox},r.a.createElement(u.a,{variant:"h6",gutterBottom:!0},"Preview"),r.a.createElement(s.a,{className:t.imageContainer},r.a.createElement("img",{src:l,alt:"Preview",className:"preview-image",style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain",display:"block"}}),r.a.createElement(v.a,{"aria-label":"delete",className:t.deleteButton,onClick:()=>{o(null),a(null),m.current.value=""}},r.a.createElement(j.a,null)))):r.a.createElement(s.a,{className:t.uploadBox,onClick:()=>{m.current.click()}},r.a.createElement(S.a,{className:t.uploadIcon}),r.a.createElement(u.a,{variant:"h6",gutterBottom:!0},"Drag & Drop an image here"),r.a.createElement(u.a,{variant:"body2",color:"textSecondary",gutterBottom:!0},"or"),r.a.createElement(h.a,{variant:"contained",color:"primary",component:"span",startIcon:r.a.createElement(S.a,null)},"Browse Files"),r.a.createElement(u.a,{variant:"body2",color:"textSecondary",className:t.supportText},"Supported formats: JPG, PNG, GIF")))},I=t(143),P=t(144),B=t(176),T=t(145),k=t(66),A=t.n(k),D=t(77),R=t.n(D),F=t(78),L=t.n(F);const _=Object(w.a)(e=>({card:{height:"100%",display:"flex",flexDirection:"column"},selectedCard:{border:"2px solid #3f51b5"},unavailableCard:{opacity:.6},cardContent:{flexGrow:1},chipContainer:{marginBottom:e.spacing(1.5)},successChip:{backgroundColor:"#34C759",color:"#fff"},errorChip:{backgroundColor:"#FF3B3F",color:"#fff"},modelType:{marginTop:e.spacing(1)},processButton:{marginTop:e.spacing(3),textAlign:"center"}}));var z=e=>{let{onModelSelect:a,onProcess:t,isProcessing:n,modelsStatus:l,selectedModel:o,imageSelected:c}=e;const i=_(),m=[{id:"yolo",name:"YOLOv8",description:"Fast and accurate object detection",icon:r.a.createElement(A.a,null),available:l.yolo},{id:"detr",name:"DETR",description:"DEtection TRansformer for object detection",icon:r.a.createElement(A.a,null),available:l.detr},{id:"vit",name:"ViT",description:"Vision Transformer for image classification",icon:r.a.createElement(R.a,null),available:l.vit}],d=e=>{m.find(a=>a.id===e).available&&a(e)};return r.a.createElement(s.a,{sx:{p:2,height:"100%"}},r.a.createElement(u.a,{variant:"h6",gutterBottom:!0},"Select Model"),r.a.createElement(y.a,{container:!0,spacing:2},m.map(e=>r.a.createElement(y.a,{item:!0,xs:12,sm:4,key:e.id},r.a.createElement(I.a,{className:"\n ".concat(i.card," \n ").concat(o===e.id?i.selectedCard:""," \n ").concat(e.available?"":i.unavailableCard,"\n "),onClick:()=>d(e.id)},r.a.createElement(P.a,{className:i.cardContent},r.a.createElement(s.a,{sx:{mb:2,color:"primary"}},e.icon),r.a.createElement(u.a,{variant:"h5",component:"div",gutterBottom:!0},e.name),r.a.createElement("div",{className:i.chipContainer},e.available?r.a.createElement(B.a,{label:"Available",className:i.successChip,size:"small"}):r.a.createElement(B.a,{label:"Not Available",className:i.errorChip,size:"small"})),r.a.createElement(u.a,{variant:"body2",color:"textSecondary"},e.description)),r.a.createElement(T.a,null,r.a.createElement(h.a,{size:"small",onClick:()=>d(e.id),disabled:!e.available,color:o===e.id?"primary":"default",variant:o===e.id?"contained":"outlined",fullWidth:!0},o===e.id?"Selected":"Select")))))),r.a.createElement("div",{className:i.processButton},r.a.createElement(h.a,{variant:"contained",color:"primary",size:"large",startIcon:r.a.createElement(L.a,null),onClick:t,disabled:!o||!c||n},n?"Processing...":"Process Image")))},W=t(157),M=t(154),J=t(107),U=t(158),V=t(146),H=t(174),G=t(175),Y=t(149),q=t(150),K=t(151),Q=t(177),X=t(170),Z=t(155),$=t(179),ee=t(156),ae=t(173);const te=Object(w.a)(e=>({root:{marginTop:e.spacing(2),marginBottom:e.spacing(2),padding:e.spacing(2),backgroundColor:"#f5f5f5",borderRadius:e.shape.borderRadius},button:{marginRight:e.spacing(2)},searchDialog:{minWidth:"500px"},formControl:{marginBottom:e.spacing(2),minWidth:"100%"},searchResults:{marginTop:e.spacing(2)},resultCard:{marginBottom:e.spacing(2)},resultImage:{height:140,objectFit:"contain"},chip:{margin:e.spacing(.5)},similarityChip:{backgroundColor:e.palette.primary.main,color:"white"}}));var ne=e=>{let{results:a}=e;const t=te(),[l,o]=Object(n.useState)(!1),[c,i]=Object(n.useState)(!1),[m,d]=Object(n.useState)(null),[g,p]=Object(n.useState)(!1),[E,f]=Object(n.useState)("image"),[v,x]=Object(n.useState)(""),[S,C]=Object(n.useState)([]),[j,w]=Object(n.useState)(!1),[O,N]=Object(n.useState)(null),{model:T,data:k}=a,A=()=>{p(!1)},D=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const a=16*Math.random()|0;return("x"===e?a:3&a|8).toString(16)}));return r.a.createElement(s.a,{className:t.root},r.a.createElement(u.a,{variant:"h6",gutterBottom:!0},"Vector Database Actions"),r.a.createElement(s.a,{display:"flex",alignItems:"center",mb:2},r.a.createElement(h.a,{variant:"contained",color:"primary",onClick:async()=>{o(!0),d(null);try{let e;if(e="vit"===T?await fetch("/api/add-to-collection",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:k.image,metadata:{model:"vit",classifications:k.classifications}})}):await fetch("/api/add-detected-objects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:k.image,objects:k.detections,imageId:D()})}),!e.ok)throw new Error("HTTP error! Status: ".concat(e.status));const a=await e.json();if(a.error)throw new Error(a.error);i(!0),setTimeout(()=>i(!1),5e3)}catch(e){console.error("Error saving to vector DB:",e),d("Error saving to vector DB: ".concat(e.message))}finally{o(!1)}},disabled:l,className:t.button},l?r.a.createElement(r.a.Fragment,null,r.a.createElement(b.a,{size:20,color:"inherit",style:{marginRight:8}}),"Saving..."):"Save to Vector DB"),r.a.createElement(h.a,{variant:"outlined",color:"primary",onClick:()=>{p(!0),C([]),N(null)},className:t.button},"Search Similar")),m&&r.a.createElement(ae.a,{severity:"error",style:{marginTop:8}},m),r.a.createElement(H.a,{open:c,autoHideDuration:5e3,onClose:()=>i(!1)},r.a.createElement(ae.a,{severity:"success"},"vit"===T?"Image and classifications successfully saved to vector DB!":"Detected objects successfully saved to vector DB!")),r.a.createElement(G.a,{open:g,onClose:A,maxWidth:"md",fullWidth:!0},r.a.createElement(Y.a,null,"Search Vector Database"),r.a.createElement(q.a,null,r.a.createElement(K.a,{className:t.formControl},r.a.createElement(Q.a,{id:"search-type-label"},"Search Type"),r.a.createElement(X.a,{labelId:"search-type-label",id:"search-type",value:E,onChange:e=>{f(e.target.value),C([]),N(null)}},r.a.createElement(Z.a,{value:"image"},"Search by Current Image"),r.a.createElement(Z.a,{value:"class"},"Search by Class Name"))),"class"===E&&r.a.createElement(K.a,{className:t.formControl},r.a.createElement($.a,{label:"Class Name",value:v,onChange:e=>{x(e.target.value)},placeholder:"e.g. person, car, dog...",fullWidth:!0})),O&&r.a.createElement(ae.a,{severity:"error",style:{marginBottom:16}},O),r.a.createElement(s.a,{className:t.searchResults},j?r.a.createElement(s.a,{display:"flex",justifyContent:"center",alignItems:"center",p:4},r.a.createElement(b.a,null),r.a.createElement(u.a,{variant:"body1",style:{marginLeft:16}},"Searching...")):r.a.createElement(r.a.Fragment,null,console.log("Search dialog render - searchResults:",S),S.length>0?(console.log("Rendering search results:",S),console.log("Search results length:",S.length),0===S.length?(console.log("No results to render"),r.a.createElement(u.a,{variant:"body1"},"No results found.")):r.a.createElement(y.a,{container:!0,spacing:2},S.map((e,a)=>{const n=100*(1-e.distance);return r.a.createElement(y.a,{item:!0,xs:12,sm:6,key:a},r.a.createElement(I.a,{className:t.resultCard},e.metadata&&e.metadata.image_data?r.a.createElement(V.a,{className:t.resultImage,component:"img",height:"200",image:"data:image/jpeg;base64,".concat(e.metadata.image_data),alt:e.metadata&&e.metadata.class?e.metadata.class:"Object"}):r.a.createElement(s.a,{className:t.resultImage,style:{backgroundColor:"#f0f0f0",display:"flex",alignItems:"center",justifyContent:"center",height:200}},r.a.createElement(u.a,{variant:"body2",color:"textSecondary"},e.metadata&&e.metadata.class?e.metadata.class:"Object"," Image")),r.a.createElement(P.a,null,r.a.createElement(s.a,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1},r.a.createElement(u.a,{variant:"subtitle1"},"Result #",a+1),r.a.createElement(B.a,{label:"Similarity: ".concat(n.toFixed(2),"%"),className:t.similarityChip,size:"small"})),r.a.createElement(u.a,{variant:"body2",color:"textSecondary"},r.a.createElement("strong",null,"Class:")," ",e.metadata.class||"N/A"),e.metadata.confidence&&r.a.createElement(u.a,{variant:"body2",color:"textSecondary"},r.a.createElement("strong",null,"Confidence:")," ",(100*e.metadata.confidence).toFixed(2),"%"),r.a.createElement(u.a,{variant:"body2",color:"textSecondary"},r.a.createElement("strong",null,"Object ID:")," ",e.id))))}))):r.a.createElement(u.a,{variant:"body1"},"No results found. Please try another search.")))),r.a.createElement(ee.a,null,r.a.createElement(h.a,{onClick:A,color:"default"},"Close"),r.a.createElement(h.a,{onClick:async()=>{w(!0),N(null);try{let e={};if("image"===E)e={searchType:"image",image:k.image,n_results:5};else{if(!v.trim())throw new Error("Please enter a class name");e={searchType:"class",class_name:v.trim(),n_results:5}}const a=await fetch("/api/search-similar-objects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!a.ok)throw new Error("HTTP error! Status: ".concat(a.status));const t=await a.json();if(t.error)throw new Error(t.error);if(console.log("Search API response:",t),!t.success||!Array.isArray(t.results))throw console.error("Unexpected API response format:",t),new Error("Unexpected API response format");console.log("Setting search results array:",t.results),console.log("Results array length:",t.results.length),console.log("First result item:",t.results[0]),C(t.results)}catch(e){console.error("Error searching vector DB:",e),N("Error searching vector DB: ".concat(e.message))}finally{w(!1)}},color:"primary",variant:"contained",disabled:j||"class"===E&&!v.trim()},"Search"))))};const re=Object(w.a)(e=>({paper:{padding:e.spacing(2)},marginBottom:{marginBottom:e.spacing(2)},resultImage:{maxWidth:"100%",maxHeight:"400px",objectFit:"contain"},dividerMargin:{margin:"".concat(e.spacing(2),"px 0")},chipContainer:{display:"flex",gap:e.spacing(1),flexWrap:"wrap"}}));var le=e=>{let{results:a}=e;const t=re();if(!a)return null;const{model:n,data:l}=a;if(l.error)return r.a.createElement(f.a,{sx:{p:2,bgcolor:"#ffebee"}},r.a.createElement(u.a,{color:"error"},l.error));const o=()=>l.performance?r.a.createElement(s.a,{className:"performance-info"},r.a.createElement(W.a,{className:t.dividerMargin}),r.a.createElement(u.a,{variant:"body2"},"Inference time: ",(e=>{if(void 0===e||null===e||isNaN(e))return"-";const a=Number(e);return a<1e3?"".concat(a.toFixed(2)," ms"):"".concat((a/1e3).toFixed(2)," s")})(l.performance.inference_time)," on ",l.performance.device)):null;return"yolo"===n||"detr"===n?r.a.createElement(f.a,{className:t.paper},r.a.createElement(u.a,{variant:"h6",gutterBottom:!0},"yolo"===n?"YOLOv8":"DETR"," Detection Results"),r.a.createElement(y.a,{container:!0,spacing:3},r.a.createElement(y.a,{item:!0,xs:12,md:6},l.image&&r.a.createElement(s.a,{className:t.marginBottom},r.a.createElement(u.a,{variant:"subtitle1",gutterBottom:!0},"Detection Result"),r.a.createElement("img",{src:"data:image/png;base64,".concat(l.image),alt:"Detection Result",className:t.resultImage}))),r.a.createElement(y.a,{item:!0,xs:12,md:6},r.a.createElement(s.a,{className:t.marginBottom},r.a.createElement(u.a,{variant:"subtitle1",gutterBottom:!0},"Detected Objects:"),l.detections&&l.detections.length>0?r.a.createElement(M.a,null,l.detections.map((e,a)=>r.a.createElement(r.a.Fragment,{key:a},r.a.createElement(J.a,null,r.a.createElement(U.a,{primary:r.a.createElement(s.a,{style:{display:"flex",alignItems:"center"}},r.a.createElement(u.a,{variant:"body1",component:"span"},e.class),r.a.createElement(B.a,{label:"".concat((100*e.confidence).toFixed(0),"%"),size:"small",color:"primary",style:{marginLeft:8}})),secondary:"Bounding Box: [".concat(e.bbox.join(", "),"]")})),a<l.detections.length-1&&r.a.createElement(W.a,null)))):r.a.createElement(u.a,{variant:"body1"},"No objects detected")))),o(),r.a.createElement(ne,{results:a})):"vit"===n?r.a.createElement(f.a,{className:t.paper},r.a.createElement(u.a,{variant:"h6",gutterBottom:!0},"ViT Classification Results"),r.a.createElement(u.a,{variant:"subtitle1",gutterBottom:!0},"Top Predictions:"),l.top_predictions&&l.top_predictions.length>0?r.a.createElement(M.a,null,l.top_predictions.map((e,a)=>r.a.createElement(r.a.Fragment,{key:a},r.a.createElement(J.a,null,r.a.createElement(U.a,{primary:r.a.createElement(s.a,{style:{display:"flex",alignItems:"center"}},r.a.createElement(u.a,{variant:"body1",component:"span"},e.rank,". ",e.class),r.a.createElement(B.a,{label:"".concat((100*e.probability).toFixed(1),"%"),size:"small",color:0===a?"primary":"default",style:{marginLeft:8}}))})),a<l.top_predictions.length-1&&r.a.createElement(W.a,null)))):r.a.createElement(u.a,{variant:"body1"},"No classifications available"),o(),r.a.createElement(ne,{results:a})):null};const oe=Object(w.a)(e=>({paper:{padding:e.spacing(2),marginTop:e.spacing(2)},marginBottom:{marginBottom:e.spacing(2)},dividerMargin:{margin:"".concat(e.spacing(2),"px 0")},responseBox:{padding:e.spacing(2),backgroundColor:"#f5f5f5",borderRadius:e.shape.borderRadius,marginTop:e.spacing(2),whiteSpace:"pre-wrap"},buttonProgress:{marginLeft:e.spacing(1)}}));var ce=e=>{let{visionResults:a,model:t}=e;const l=oe(),[o,c]=Object(n.useState)(""),[i,m]=Object(n.useState)(!1),[d,g]=Object(n.useState)(null),[p,E]=Object(n.useState)(null);return a?r.a.createElement(f.a,{className:l.paper},r.a.createElement(u.a,{variant:"h6",gutterBottom:!0},"Ask AI about the ","vit"===t?"Classification":"Detection"," Results"),r.a.createElement(u.a,{variant:"body2",className:l.marginBottom},"Ask a question about the detected objects or classifications to get an AI-powered analysis."),r.a.createElement($.a,{fullWidth:!0,label:"Your question about the image",variant:"outlined",value:o,onChange:e=>c(e.target.value),disabled:i,className:l.marginBottom,placeholder:"vit"===t?"E.g., What category does this image belong to?":"E.g., How many people are in this image?"}),r.a.createElement(h.a,{variant:"contained",color:"primary",onClick:async()=>{if(o.trim()){m(!0),E(null);try{const e=await fetch("/api/analyze",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({visionResults:a,userQuery:o})});if(!e.ok)throw new Error("HTTP error! Status: ".concat(e.status));const t=await e.json();t.error?E(t.error):g(t)}catch(e){console.error("Error analyzing with LLM:",e),E("Error analyzing with LLM: ".concat(e.message))}finally{m(!1)}}},disabled:i||!o.trim()},"Analyze with AI",i&&r.a.createElement(b.a,{size:24,className:l.buttonProgress})),p&&r.a.createElement(s.a,{mt:2},r.a.createElement(u.a,{color:"error"},p)),d&&r.a.createElement(r.a.Fragment,null,r.a.createElement(W.a,{className:l.dividerMargin}),r.a.createElement(u.a,{variant:"subtitle1",gutterBottom:!0},"AI Analysis:"),r.a.createElement(s.a,{className:l.responseBox},r.a.createElement(u.a,{variant:"body1"},d.response)),d.performance&&r.a.createElement(s.a,{mt:1},r.a.createElement(u.a,{variant:"body2",color:"textSecondary"},"Analysis time: ",(e=>{if(void 0===e||null===e||isNaN(e))return"-";const a=Number(e);return a<1e3?"".concat(a.toFixed(2)," ms"):"".concat((a/1e3).toFixed(2)," s")})(d.performance.inference_time)," on ",d.performance.device)))):null};var ie=function(e){let{imageBase64:a}=e;const[t,l]=Object(n.useState)(""),[o,c]=Object(n.useState)(""),[i,s]=Object(n.useState)(""),[m,d]=Object(n.useState)(!1),[g,p]=Object(n.useState)(""),[E,b]=Object(n.useState)("image"),[v,x]=Object(n.useState)(""),[S,C]=Object(n.useState)(""),[j,w]=Object(n.useState)(5);return r.a.createElement(f.a,{style:{padding:16}},r.a.createElement(u.a,{variant:"h5",gutterBottom:!0},"Vision RAG (LangChain)"),r.a.createElement(u.a,{variant:"body2",color:"textSecondary",gutterBottom:!0},"If OPENAI_API_KEY is set on the server, API Key is optional. Select a search type and send a question to get answers based on context retrieved from the vector DB."),r.a.createElement(y.a,{container:!0,spacing:2},r.a.createElement(y.a,{item:!0,xs:12,md:6},r.a.createElement(K.a,{fullWidth:!0,variant:"outlined",size:"small"},r.a.createElement(Q.a,{id:"search-type-label"},"Search Type"),r.a.createElement(X.a,{labelId:"search-type-label",value:E,onChange:e=>b(e.target.value),label:"Search Type"},r.a.createElement(Z.a,{value:"image"},"image (current upload)"),r.a.createElement(Z.a,{value:"object"},"object (objectId)"),r.a.createElement(Z.a,{value:"class"},"class (class_name)")))),r.a.createElement(y.a,{item:!0,xs:12,md:6},r.a.createElement($.a,{label:"OpenAI API Key (optional)",value:t,onChange:e=>l(e.target.value),fullWidth:!0,variant:"outlined",size:"small",type:"password",placeholder:"sk-..."})),"object"===E&&r.a.createElement(y.a,{item:!0,xs:12,md:6},r.a.createElement($.a,{label:"objectId",value:v,onChange:e=>x(e.target.value),fullWidth:!0,variant:"outlined",size:"small"})),"class"===E&&r.a.createElement(y.a,{item:!0,xs:12,md:6},r.a.createElement($.a,{label:"class_name",value:S,onChange:e=>C(e.target.value),fullWidth:!0,variant:"outlined",size:"small",placeholder:"e.g. person, car, dog"})),r.a.createElement(y.a,{item:!0,xs:12,md:6},r.a.createElement($.a,{label:"n_results",value:j,onChange:e=>w(e.target.value),fullWidth:!0,variant:"outlined",size:"small",type:"number",inputProps:{min:1,max:50}})),r.a.createElement(y.a,{item:!0,xs:12},r.a.createElement($.a,{label:"User Question",value:o,onChange:e=>c(e.target.value),fullWidth:!0,multiline:!0,rows:4,variant:"outlined",placeholder:"image"===E?"Answer based on the uploaded image":"Answer using the retrieved object context"})),g&&r.a.createElement(y.a,{item:!0,xs:12},r.a.createElement(u.a,{color:"error"},g)),r.a.createElement(y.a,{item:!0,xs:12},r.a.createElement("div",{style:{display:"flex",gap:8}},r.a.createElement(h.a,{color:"primary",variant:"contained",onClick:async()=>{p(""),s("");const e=(o||"").trim();if(!e)return void p("Please enter a question.");const n={userQuery:e,searchType:E,n_results:Number(j)||5};if(t&&(n.api_key=t),"image"===E){if(!a)return void p("Image is required. Please upload an image first.");n.image=a}else if("object"===E){if(!v.trim())return void p("Please enter an objectId.");n.objectId=v.trim()}else if("class"===E){if(!S.trim())return void p("Please enter a class_name.");n.class_name=S.trim()}d(!0);try{const e=await fetch("/api/vision-rag/query",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(n)});if(!e.ok){let a=await e.text();try{a=JSON.stringify(JSON.parse(a),null,2)}catch(r){}throw new Error(a)}const a=await e.json(),t="Model: ".concat(a.model||"-"," | Latency: ").concat(a.latency_sec||"-","s");let l="";a.retrieved&&a.retrieved.length>0&&(l="\n\nSearch Results:\n",a.retrieved.forEach((e,a)=>{l+="".concat(a+1,". ID: ").concat(e.id||"-","\n"),e.meta&&(l+=" Class: ".concat(e.meta.class||"-","\n"),l+=" Confidence: ".concat(e.meta.confidence||"-","\n")),l+=" Similarity: ".concat(e.distance?e.distance.toFixed(4):"-","\n")})),s((a.answer||"(No response)")+l+"\n\n---\n"+t)}catch(l){p("Error: "+l.message)}finally{d(!1)}},disabled:m},m?"Sending...":"Send Question"),r.a.createElement(h.a,{variant:"outlined",onClick:()=>{c(""),s(""),p("")}},"Clear"))),r.a.createElement(y.a,{item:!0,xs:12},r.a.createElement(W.a,{style:{margin:"12px 0"}}),r.a.createElement(u.a,{variant:"subtitle2",color:"textSecondary"},"Response"),r.a.createElement("pre",{style:{whiteSpace:"pre-wrap",fontFamily:"ui-monospace, monospace"}},i))))},se=(t(80),t(159)),me=t(160),de=t(162),ue=t(163),ge=t(164);const pe=Object(w.a)(e=>({root:{marginTop:e.spacing(3),marginBottom:e.spacing(3)},imageContainer:{position:"relative",minHeight:"360px",display:"flex",justifyContent:"center",alignItems:"center",border:"2px dashed #ccc",borderRadius:"8px",margin:e.spacing(1),padding:e.spacing(1),backgroundColor:"#fafafa",overflow:"hidden"},progressLog:{marginTop:e.spacing(2),height:"200px",overflowY:"auto",backgroundColor:"#f8f9fa",padding:e.spacing(1),borderRadius:"4px",fontFamily:"monospace",fontSize:"0.9rem"},logEntry:{margin:"4px 0",padding:"2px 5px",borderLeft:"3px solid #ccc"},logEntryAgent:{borderLeft:"3px solid #2196f3"},logEntrySystem:{borderLeft:"3px solid #4caf50"},logEntryError:{borderLeft:"3px solid #f44336"},logTime:{color:"#666",fontSize:"0.8rem",marginRight:e.spacing(1)},imagePreview:{width:"100%",height:"auto",maxHeight:"60vh",objectFit:"contain"},uploadIcon:{fontSize:"3rem",color:"#aaa"},uploadInput:{display:"none"},deleteButton:{position:"absolute",top:"8px",right:"8px",backgroundColor:"rgba(255, 255, 255, 0.8)","&:hover":{backgroundColor:"rgba(255, 255, 255, 0.9)"}},tabPanel:{padding:e.spacing(2)},resultCard:{marginTop:e.spacing(2),marginBottom:e.spacing(2)},comparisonTable:{width:"100%",borderCollapse:"collapse","& th, & td":{border:"1px solid #ddd",padding:"8px",textAlign:"left"},"& th":{backgroundColor:"#f2f2f2"},"& tr:nth-child(even)":{backgroundColor:"#f9f9f9"}},loadingContainer:{display:"flex",flexDirection:"column",alignItems:"center",padding:e.spacing(4)},highlight:{backgroundColor:"#e3f2fd",padding:e.spacing(1),borderRadius:"4px",fontWeight:"bold"}}));var Ee=()=>{const e=pe(),[a,t]=Object(n.useState)([null,null]),[l,o]=Object(n.useState)([null,null]),[c,i]=Object(n.useState)(!1),[m,d]=Object(n.useState)(null),[E,x]=Object(n.useState)(null),[S,C]=Object(n.useState)(0),[j,w]=Object(n.useState)([]),O=Object(n.useRef)(null),N=function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";const t=new Date,n=t.toLocaleTimeString(),r={time:n,message:e,type:a};w(e=>[...e,r])};Object(n.useEffect)(()=>{O.current&&O.current.scrollIntoView({behavior:"smooth"})},[j]);const B=e=>{const a=new EventSource("/api/product/compare/stream/".concat(e));return a.onmessage=e=>{try{const t=JSON.parse(e.data);console.log("React SSE received:",t),t.message?N(t.message,t.agent||"info"):t.status?N("Status: ".concat(t.status),"system"):t.final_result?(console.log("Final result received:",t.final_result),d(t.final_result),i(!1),a.close()):t.error&&(N("Error: ".concat(t.error),"error"),i(!1),a.close())}catch(t){console.error("SSE parsing error:",t),N("Event processing error: ".concat(t.message),"error")}},a.onerror=e=>{N("Server connection lost. Please try again in a moment.","error"),a.close(),i(!1)},a},T=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(a[0]||a[1]){i(!0),x(null),w([]),N("Starting product analysis...","system");try{const t=new FormData;a[0]&&(t.append("image1",a[0]),N("Product A image uploaded.","info")),a[1]&&(t.append("image2",a[1]),N("Product B image uploaded.","info"));const n=["info","compare","value","recommend"],r=e||n[S];t.append("analysisType",r),N("Analysis type: ".concat("info"===r?"Product Information":"compare"===r?"Performance Comparison":"value"===r?"Value Analysis":"Purchase Recommendation"),"system"),N("Initializing analysis session...","system");for(let[e,a]of t.entries())console.log("FormData:",e,a);const l=await fetch("/api/product/compare/start",{method:"POST",body:t,credentials:"include"});if(console.log("Response status:",l.status),console.log("Response headers:",l.headers),!l.ok){const e=await l.text();throw console.error("Error response:",e),new Error("HTTP error! Status: ".concat(l.status," - ").concat(e))}const o=(await l.json()).session_id;if(!o)throw new Error("Failed to receive session ID");N("Analysis session started. (Session ID: ".concat(o.substring(0,8),"...)"),"system"),N("Agents are collaborating to analyze products. Please wait a moment...","system");const c=B(o);return()=>{c.close()}}catch(t){console.error("\uc81c\ud488 \ubd84\uc11d \uc624\ub958:",t),N("Error occurred: ".concat(t.message),"error"),x("Error during analysis: ".concat(t.message)),i(!1)}}else x("Please upload at least one product image for analysis")};return r.a.createElement(f.a,{className:e.root},r.a.createElement(s.a,{p:3},r.a.createElement(u.a,{variant:"h5",gutterBottom:!0},"Product Comparison Analysis"),r.a.createElement(u.a,{variant:"body1",paragraph:!0},"Upload product images to receive detailed information and comparison analysis. You can analyze various products including cars, smartphones, laptops, and more."),r.a.createElement(y.a,{container:!0,spacing:3},[0,1].map(n=>r.a.createElement(y.a,{item:!0,xs:12,md:6,key:n},r.a.createElement(s.a,{className:e.imageContainer},l[n]?r.a.createElement(r.a.Fragment,null,r.a.createElement("img",{src:l[n],alt:"Product ".concat(n+1),className:e.imagePreview}),r.a.createElement(v.a,{className:e.deleteButton,onClick:()=>(e=>{const n=[...a],r=[...l];n[e]=null,r[e]=null,t(n),o(r),d(null)})(n)},r.a.createElement(se.a,null))):r.a.createElement(r.a.Fragment,null,r.a.createElement("input",{accept:"image/*",className:e.uploadInput,id:"upload-image-".concat(n),type:"file",onChange:e=>((e,n)=>{const r=e.target.files[0];if(r){const e=new FileReader;e.onload=e=>{const a=[...l];a[n]=e.target.result,o(a)},e.readAsDataURL(r);const c=[...a];c[n]=r,t(c),d(null),x(null)}})(e,n)}),r.a.createElement("label",{htmlFor:"upload-image-".concat(n)},r.a.createElement(s.a,{display:"flex",flexDirection:"column",alignItems:"center"},r.a.createElement(me.a,{className:e.uploadIcon}),r.a.createElement(u.a,{variant:"body2",style:{marginTop:"8px"}},"Upload ",0===n?"Product A":"Product B"," Image"))))))),r.a.createElement(y.a,{item:!0,xs:12},r.a.createElement("input",{accept:"image/*",className:e.uploadInput,id:"upload-both-images",type:"file",multiple:!0,onChange:e=>{const n=Array.from(e.target.files||[]);if(!n.length)return;const r=[...a],c=[...l];n.slice(0,2).forEach((e,a)=>{const t=a;r[t]=e;const n=new FileReader;n.onload=e=>{c[t]=e.target.result,o([...c])},n.readAsDataURL(e)}),t(r),d(null),x(null)}}),r.a.createElement("label",{htmlFor:"upload-both-images"},r.a.createElement(h.a,{variant:"text",color:"default",component:"span"},"Or select two files at once"))),r.a.createElement(y.a,{item:!0,xs:12},r.a.createElement(f.a,null,r.a.createElement(g.a,{value:S,onChange:(e,a)=>{C(a)},indicatorColor:"primary",textColor:"primary",centered:!0},r.a.createElement(p.a,{icon:r.a.createElement(de.a,null),label:"Product Info"}),r.a.createElement(p.a,{icon:r.a.createElement(ue.a,null),label:"Performance",disabled:!a[0]||!a[1]}),r.a.createElement(p.a,{icon:r.a.createElement(ge.a,null),label:"Value Analysis"}),r.a.createElement(p.a,{label:"Recommendations"})),r.a.createElement(s.a,{p:2,display:"flex",justifyContent:"center",gridGap:12},r.a.createElement(h.a,{variant:"contained",color:"primary",onClick:()=>T(null),disabled:c||!a[0]&&!a[1],startIcon:c?r.a.createElement(b.a,{size:24}):null},c?"Analyzing...":"Start Analysis"),r.a.createElement(h.a,{variant:"outlined",color:"secondary",onClick:()=>T("compare"),disabled:c||!a[0]||!a[1],startIcon:r.a.createElement(ue.a,null)},"Compare Products")),E&&r.a.createElement(s.a,{p:2,bgcolor:"#ffebee",borderRadius:"4px",mb:2},r.a.createElement(u.a,{color:"error"},E)))),r.a.createElement(y.a,{item:!0,xs:12},r.a.createElement(f.a,null,r.a.createElement(s.a,{p:2},r.a.createElement(u.a,{variant:"h6",gutterBottom:!0},"Analysis Progress"),r.a.createElement(s.a,{className:e.progressLog},0===j.length?r.a.createElement(u.a,{variant:"body2",color:"textSecondary",style:{padding:"10px"}},"Progress details will appear here when analysis starts."):j.map((a,t)=>r.a.createElement(s.a,{key:t,className:"".concat(e.logEntry," ").concat("agent"===a.type?e.logEntryAgent:"system"===a.type?e.logEntrySystem:"error"===a.type?e.logEntryError:"")},r.a.createElement("span",{className:e.logTime},"[",a.time,"]"),a.message)),r.a.createElement("div",{ref:O}))))),r.a.createElement(y.a,{item:!0,xs:12},c?r.a.createElement(s.a,{className:e.loadingContainer},r.a.createElement(b.a,null),r.a.createElement(u.a,{variant:"h6",style:{marginTop:"16px"}},"Analyzing Products..."),r.a.createElement(u.a,{variant:"body2",color:"textSecondary"},"Product recognition, information retrieval, and comparison analysis in progress.")):(()=>{if(!m)return null;switch(S){case 0:return r.a.createElement(I.a,{className:e.resultCard},r.a.createElement(P.a,null,r.a.createElement(u.a,{variant:"h6",gutterBottom:!0},"Product Information"),r.a.createElement(W.a,{style:{margin:"8px 0 16px"}}),m.productInfo&&r.a.createElement("div",null,Object.entries(m.productInfo).map((e,a)=>{let[t,n]=e;return r.a.createElement("div",{key:t,style:{marginBottom:"24px"}},r.a.createElement(u.a,{variant:"subtitle1",gutterBottom:!0},r.a.createElement("strong",null,"Product ",a+1," (",t,")")),r.a.createElement(u.a,{variant:"body1"},r.a.createElement("strong",null,"Type:")," ",n.product_type||"Unknown"),n.key_features&&n.key_features.length>0&&r.a.createElement("div",{style:{marginTop:"12px"}},r.a.createElement(u.a,{variant:"subtitle2"},"Key Features:"),r.a.createElement("ul",null,n.key_features.map((e,a)=>r.a.createElement("li",{key:a},r.a.createElement(u.a,{variant:"body2"},e))))),m.specifications&&m.specifications[t]&&r.a.createElement("div",{style:{marginTop:"12px"}},r.a.createElement(u.a,{variant:"subtitle2"},"Specifications:"),r.a.createElement("ul",null,Object.entries(m.specifications[t].specifications||{}).map(e=>{let[a,t]=e;return r.a.createElement("li",{key:a},r.a.createElement(u.a,{variant:"body2"},r.a.createElement("strong",null,a.replace("_"," "),":")," ",Array.isArray(t)?t.join(", "):t))}))))}))));case 1:return r.a.createElement(I.a,{className:e.resultCard},r.a.createElement(P.a,null,r.a.createElement(u.a,{variant:"h6",gutterBottom:!0},"Product Comparison Analysis"),r.a.createElement(W.a,{style:{margin:"8px 0 16px"}}),m.comparison&&r.a.createElement("div",null,r.a.createElement(u.a,{variant:"body1",style:{whiteSpace:"pre-line",marginBottom:"16px"}},"string"===typeof m.comparison?m.comparison:JSON.stringify(m.comparison,null,2)))));case 2:return r.a.createElement(I.a,{className:e.resultCard},r.a.createElement(P.a,null,r.a.createElement(u.a,{variant:"h6",gutterBottom:!0},"Price-to-Value Analysis"),r.a.createElement(W.a,{style:{margin:"8px 0 16px"}}),m.valueAnalysis&&r.a.createElement("div",null,r.a.createElement(u.a,{variant:"body1",style:{whiteSpace:"pre-line",marginBottom:"16px"}},"string"===typeof m.valueAnalysis?m.valueAnalysis:JSON.stringify(m.valueAnalysis,null,2)))));case 3:return r.a.createElement(I.a,{className:e.resultCard},r.a.createElement(P.a,null,r.a.createElement(u.a,{variant:"h6",gutterBottom:!0},"Purchase Recommendations"),r.a.createElement(W.a,{style:{margin:"8px 0 16px"}}),m.recommendation&&r.a.createElement("div",null,r.a.createElement(u.a,{variant:"body1",style:{whiteSpace:"pre-line",marginBottom:"16px"}},"string"===typeof m.recommendation?m.recommendation:JSON.stringify(m.recommendation,null,2))),!m.recommendation&&!m.valueAnalysis&&!m.comparison&&!m.productInfo&&r.a.createElement("div",null,r.a.createElement(u.a,{variant:"body1",style:{whiteSpace:"pre-line",marginBottom:"16px"}},JSON.stringify(m,null,2)))));default:return null}})()))))};t(104);const ye=Object(c.a)({palette:{primary:{main:"#3f51b5"},secondary:{main:"#f50057"}},typography:{fontFamily:"Roboto, Arial, sans-serif"}});var fe=function(){const[e,a]=Object(n.useState)(null),[t,l]=Object(n.useState)(""),[o,c]=Object(n.useState)(""),[h,v]=Object(n.useState)(!1),[x,S]=Object(n.useState)(null),[C,j]=Object(n.useState)(null),[w,O]=Object(n.useState)({yolo:!1,detr:!1,vit:!1}),[I,P]=Object(n.useState)(0);return Object(n.useEffect)(()=>{fetch("/api/status").then(e=>e.json()).then(e=>{O(e.models)}).catch(e=>{console.error("Error checking API status:",e),j("Error connecting to the backend API. Please make sure the server is running.")})},[]),r.a.createElement(i.a,{theme:ye},r.a.createElement(s.a,{style:{flexGrow:1}},r.a.createElement(m.a,{position:"static"},r.a.createElement(d.a,null,r.a.createElement(u.a,{variant:"h6",style:{flexGrow:1}},"Vision LLM Multi-Agent System")),r.a.createElement(g.a,{value:I,onChange:(e,a)=>P(a),indicatorColor:"secondary",textColor:"inherit",centered:!0},r.a.createElement(p.a,{label:"Object Detection"}),r.a.createElement(p.a,{label:"Product Comparison"}))),r.a.createElement(E.a,{maxWidth:"lg",style:{marginTop:ye.spacing(4),marginBottom:ye.spacing(4)}},0===I?r.a.createElement(y.a,{container:!0,spacing:3},r.a.createElement(y.a,{item:!0,xs:12},r.a.createElement(f.a,{style:{padding:ye.spacing(2)}},r.a.createElement(u.a,{variant:"h5",gutterBottom:!0},"Upload an image to see how each model performs!"),r.a.createElement(u.a,{variant:"body1",paragraph:!0},"This demo showcases three different object detection and image classification models:"),r.a.createElement(u.a,{variant:"body1",component:"div"},r.a.createElement("ul",null,r.a.createElement("li",null,r.a.createElement("strong",null,"YOLOv8"),": Fast and accurate object detection"),r.a.createElement("li",null,r.a.createElement("strong",null,"DETR"),": DEtection TRansformer for object detection"),r.a.createElement("li",null,r.a.createElement("strong",null,"ViT"),": Vision Transformer for image classification"))))),r.a.createElement(y.a,{item:!0,xs:12,md:6},r.a.createElement(N,{onImageUpload:e=>{if(a(e),S(null),j(null),e instanceof File){const a=new FileReader;a.onload=()=>{const e=a.result;l("string"===typeof e?e:"")},a.onerror=()=>l(""),a.readAsDataURL(e)}else l("")}})),r.a.createElement(y.a,{item:!0,xs:12,md:6},r.a.createElement(z,{onModelSelect:e=>{c(e),S(null),j(null)},onProcess:async()=>{if(!e||!o)return void j("Please select both an image and a model");v(!0),j(null);const a=new FormData;a.append("image",e);let t="";switch(o){case"yolo":t="/api/detect/yolo";break;case"detr":t="/api/detect/detr";break;case"vit":t="/api/classify/vit";break;default:return j("Invalid model selection"),void v(!1)}try{const e=await fetch(t,{method:"POST",body:a});if(!e.ok)throw new Error("HTTP error! Status: ".concat(e.status));const n=await e.json();S({model:o,data:n})}catch(n){console.error("Error processing image:",n),j("Error processing image: ".concat(n.message))}finally{v(!1)}},isProcessing:h,modelsStatus:w,selectedModel:o,imageSelected:!!e})),C&&r.a.createElement(y.a,{item:!0,xs:12},r.a.createElement(f.a,{style:{padding:ye.spacing(2),backgroundColor:"#ffebee"}},r.a.createElement(u.a,{color:"error"},C))),h&&r.a.createElement(y.a,{item:!0,xs:12,style:{textAlign:"center",margin:"".concat(ye.spacing(4),"px 0")}},r.a.createElement(b.a,null),r.a.createElement(u.a,{variant:"h6",style:{marginTop:ye.spacing(2)}},"Processing image...")),x&&r.a.createElement(r.a.Fragment,null,r.a.createElement(y.a,{item:!0,xs:12},r.a.createElement(le,{results:x})),r.a.createElement(y.a,{item:!0,xs:12},r.a.createElement(ce,{visionResults:x.data,model:x.model}))),r.a.createElement(y.a,{item:!0,xs:12},r.a.createElement(ie,{imageBase64:t}))):r.a.createElement(Ee,null))))};var be=e=>{e&&e instanceof Function&&t.e(3).then(t.bind(null,181)).then(a=>{let{getCLS:t,getFID:n,getFCP:r,getLCP:l,getTTFB:o}=a;t(e),n(e),r(e),l(e),o(e)})};o.a.render(r.a.createElement(r.a.StrictMode,null,r.a.createElement(fe,null)),document.getElementById("root")),be()},94:function(e,a,t){e.exports=t(105)},99:function(e,a,t){}},[[94,1,2]]]);
|
2 |
+
//# sourceMappingURL=main.7f0b632e.chunk.js.map
|
static/static/js/main.7f0b632e.chunk.js.map
ADDED
The diff for this file is too large to render.
See raw diff
|
|