Skip to content

Commit a1a65b7

Browse files
committed
fix 36
1 parent a55b242 commit a1a65b7

File tree

1 file changed

+9
-43
lines changed

1 file changed

+9
-43
lines changed

js/mood-palette.js

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -527,27 +527,6 @@ function resetApp() {
527527
showStatus('PRESS CAPTURE TO START CAMERA', 'info');
528528
}
529529

530-
// Function to send extracted colors to LLM for processing
531-
function sendColorsToLLM(colors) {
532-
showStatus('SENDING COLORS TO LLM...', 'info');
533-
534-
try {
535-
// Send color data to LLM for processing
536-
const payload = {
537-
message: `I've analyzed an image captured from the R1 device's camera and extracted these 5 dominant colors: ${colors.join(', ')}. Please provide a creative description of the mood or theme these colors represent, and suggest a name for this color palette. Return ONLY a JSON object in this exact format: {"paletteName": "name", "description": "description"}`,
538-
useLLM: true,
539-
wantsR1Response: false // Set to false to get JSON response
540-
};
541-
542-
console.log('Sending colors to LLM with payload:', JSON.stringify(payload, null, 2));
543-
PluginMessageHandler.postMessage(JSON.stringify(payload));
544-
showStatus('COLORS SENT TO LLM. WAITING FOR RESPONSE...', 'info');
545-
} catch (error) {
546-
console.error('Error sending colors to LLM:', error);
547-
showStatus('LLM COMMUNICATION FAILED', 'error');
548-
}
549-
}
550-
551530
// Plugin message handler for LLM responses
552531
window.onPluginMessage = function(data) {
553532
console.log('Received plugin message:', data);
@@ -586,15 +565,6 @@ window.onPluginMessage = function(data) {
586565
setTimeout(() => {
587566
resetApp();
588567
}, 2000);
589-
}
590-
// Handle case where LLM requests image URL - but we're sending directly
591-
else if (data.message.includes('image') &&
592-
(data.message.includes('url') ||
593-
data.message.includes('link') ||
594-
data.message.includes('file') ||
595-
data.message.includes('upload'))) {
596-
showStatus('LLM REQUESTED IMAGE URL - SENDING DIRECTLY', 'info');
597-
console.log('LLM requested image URL but we are sending image data directly');
598568
} else if (data.message.includes('timeout') || data.message.includes('failed') || data.message.includes('error')) {
599569
showStatus('LLM ERROR: ' + data.message, 'error');
600570
} else {
@@ -701,27 +671,23 @@ function createColorShapes(colors) {
701671
return shapesContainer;
702672
}
703673

704-
// Function to send image directly to LLM for analysis (deprecated - now using color extraction)
705-
function sendImageToLLM() {
706-
showStatus('SENDING IMAGE TO LLM...', 'info');
674+
// Function to send extracted colors to LLM for processing
675+
function sendColorsToLLM(colors) {
676+
showStatus('SENDING COLORS TO LLM...', 'info');
707677

708678
try {
709-
// Log the image data info for debugging
710-
console.log('Sending image to LLM. Image data length:', capturedImageData ? capturedImageData.length : 'null');
711-
712-
// Send image data directly to LLM for analysis with specific instructions
679+
// Send color data to LLM for processing
713680
const payload = {
714-
message: `I'm sending you an image captured from the R1 device's camera. Please analyze this image and extract exactly 5 dominant colors in hex format. Return ONLY a JSON object in this exact format: {"colors": ["#hex1", "#hex2", "#hex3", "#hex4", "#hex5"]}. Do not request an image URL as I'm sending the image data directly.`,
681+
message: `I've analyzed an image captured from the R1 device's camera and extracted these 5 dominant colors: ${colors.join(', ')}. Please provide a creative description of the mood or theme these colors represent, and suggest a name for this color palette. Return ONLY a JSON object in this exact format: {"paletteName": "name", "description": "description"}`,
715682
useLLM: true,
716-
wantsR1Response: false, // Set to false to get JSON response
717-
imageData: capturedImageData // Send image data directly
683+
wantsR1Response: false // Set to false to get JSON response
718684
};
719685

720-
console.log('Sending image to LLM with payload:', JSON.stringify(payload, null, 2));
686+
console.log('Sending colors to LLM with payload:', JSON.stringify(payload, null, 2));
721687
PluginMessageHandler.postMessage(JSON.stringify(payload));
722-
showStatus('IMAGE SENT TO LLM. WAITING FOR RESPONSE...', 'info');
688+
showStatus('COLORS SENT TO LLM. WAITING FOR RESPONSE...', 'info');
723689
} catch (error) {
724-
console.error('Error sending image to LLM:', error);
690+
console.error('Error sending colors to LLM:', error);
725691
showStatus('LLM COMMUNICATION FAILED', 'error');
726692
}
727693
}

0 commit comments

Comments
 (0)