Skip to content

Commit fbef5fe

Browse files
committed
fix 27
1 parent 89159a6 commit fbef5fe

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

js/mood-palette.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,15 @@ function analyzeColorsFromImage() {
337337
}
338338

339339
showStatus('ANALYZING COLORS...', 'info');
340+
console.log('Analyzing colors. PluginMessageHandler available:', typeof PluginMessageHandler !== 'undefined');
340341

341342
// In a real R1 implementation, we would send this to the LLM
342343
if (typeof PluginMessageHandler !== 'undefined') {
344+
console.log('Sending image directly to LLM');
343345
// Send image data directly to LLM for analysis
344346
sendImageToLLM();
345347
} else {
348+
console.log('Simulating analysis for browser testing');
346349
// Simulate analysis for browser testing with more realistic colors
347350
setTimeout(() => {
348351
// Generate colors based on actual image analysis simulation
@@ -530,9 +533,12 @@ window.onPluginMessage = function(data) {
530533
resetApp();
531534
}, 2000);
532535
}
533-
// Handle case where LLM requests image URL (fallback)
534-
else if (data.message.includes('image') && data.message.includes('url')) {
536+
// Handle case where LLM requests image URL (fallback) - make this more specific
537+
else if (data.message.includes('Please provide an image URL') ||
538+
data.message.includes('need an image URL') ||
539+
data.message.includes('upload the image')) {
535540
showStatus('LLM REQUESTS IMAGE URL - UPLOADING...', 'info');
541+
console.log('LLM requested image URL, using catbox fallback');
536542
// Use catbox as fallback only when LLM explicitly requests it
537543
fallbackToCatboxAnalysis();
538544
} else if (data.message.includes('timeout') || data.message.includes('failed') || data.message.includes('error')) {
@@ -646,6 +652,9 @@ function sendImageToLLM() {
646652
showStatus('SENDING IMAGE TO LLM...', 'info');
647653

648654
try {
655+
// Log the image data info for debugging
656+
console.log('Sending image to LLM. Image data length:', capturedImageData ? capturedImageData.length : 'null');
657+
649658
// Send image data directly to LLM for analysis
650659
const payload = {
651660
message: `Please analyze the colors in this image and provide exactly 5 dominant colors in hex format. Response format: {"colors": ["#hex1", "#hex2", "#hex3", "#hex4", "#hex5"]}.`,
@@ -654,8 +663,9 @@ function sendImageToLLM() {
654663
imageData: capturedImageData // Send image data directly
655664
};
656665

657-
console.log('Sending image to LLM');
666+
console.log('Sending image to LLM with payload:', JSON.stringify(payload, null, 2));
658667
PluginMessageHandler.postMessage(JSON.stringify(payload));
668+
showStatus('IMAGE SENT TO LLM. WAITING FOR RESPONSE...', 'info');
659669
} catch (error) {
660670
console.error('Error sending image to LLM:', error);
661671
showStatus('LLM COMMUNICATION FAILED', 'error');

0 commit comments

Comments
 (0)