Skip to content

Commit 0a26805

Browse files
small llm feedack fixes (#97)
* Simplify LLM feedback code while maintaining core functionality - Streamlined UI with cleaner layout and better visual hierarchy - Reduced CSS by 70% using a simpler container-based approach - Simplified JavaScript from ~400 lines to ~130 lines - Improved state management and evolution logic - Maintained all core functionality including art generation, preview, and history Closes #91 Mentat precommits passed. Log: https://mentat.ai/log/ccb24099-4857-47b7-b5d7-d856a21c9041 * Update .gitignore with additional common patterns Added patterns for: - Yarn PnP files - Additional build output directory (out/) - General debug logs - OS-specific files (DS_Store, Thumbs.db) Mentat precommits passed. Log: https://mentat.ai/log/75248827-ef9b-4de6-9167-557d758749fb * Make .gitignore more comprehensive for all app types - Removed wildcard prefixes to work recursively at any depth - Added patterns for various build tools and frameworks - Added web-specific patterns for compiled assets - Added testing and temporary file patterns - Improved organization and categorization Mentat precommits passed. Log: https://mentat.ai/log/9478638d-b20e-4b73-a8ec-7dc7c7cfd202 * Update .gitignore to better handle subfolder apps - Added `**/` prefix to match files at any directory depth - Added patterns for Yarn 2+ cache files - Included vanilla HTML/JS specific patterns - Added more build output and test directories - Improved handling of OS-specific files at all levels Mentat precommits passed. Log: https://mentat.ai/log/4786f47d-56c8-44b6-bb53-1e2e7696062a * Revert "Make .gitignore more comprehensive for all app types" This reverts commit a424654. * enhance visual poetry UI and generation enhance visual poetry UI and generation - Update presets to focus on visual poetry styles (Apollinaire, Mallarmé, etc) - Improve monospace text display with better styling and dimensions - Add seed parameter for reproducible generations - Remove separate current art window in favor of preview - Enhance generation logic with better state management - Improve error handling and logging * Tweaks more prompts * add model selector * more robust fetching logic * small tweaks * improvements * Enforce dot usage over whitespace in guidelines * more robust and post --------- Co-authored-by: MentatBot <160964065+MentatBot@users.noreply.github.com>
1 parent 0c26041 commit 0a26805

File tree

1 file changed

+32
-66
lines changed

1 file changed

+32
-66
lines changed

llm-feedback/index.html

Lines changed: 32 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -282,76 +282,42 @@ <h2>History</h2>
282282

283283
elements.start.textContent = 'Generating...';
284284

285-
const encodedPrompt = encodeURIComponent(currentState);
286-
const encodedSystem = encodeURIComponent(formatInstructions);
287-
288285
let seed = elements.seed.value && elements.seed.value !== '-1' ?
289286
parseInt(elements.seed.value) :
290287
Math.floor(Math.random() * 1000000);
291-
elements.seed.value = seed; // Update input with chosen seed
292-
293-
let response = null;
294-
console.log('Fetching...');
295-
296-
let retryCount = 0;
297-
const maxRetries = 3;
298-
const retryDelay = 15000; // 15 seconds delay between retries
299-
const timeoutDuration = 20000; // 20 seconds timeout
300-
301-
do {
302-
try {
303-
const url = `https://text.pollinations.ai/${encodedPrompt}?system=${encodedSystem}&seed=${seed}&model=${getSelectedModel()}&temperature=${elements.temperature.value}`;
304-
console.log('Request URL:', url);
305-
306-
const controller = new AbortController();
307-
const timeout = setTimeout(() => {
308-
controller.abort();
309-
}, timeoutDuration);
310-
311-
try {
312-
response = await fetch(url, {
313-
signal: controller.signal
314-
});
315-
clearTimeout(timeout);
316-
} catch (error) {
317-
clearTimeout(timeout);
318-
if (error.name === 'AbortError') {
319-
throw new Error('Request timed out after ' + timeoutDuration/1000 + ' seconds');
320-
}
321-
throw error;
322-
}
323-
324-
if (!response.ok) {
325-
retryCount++;
326-
if (retryCount >= maxRetries) {
327-
console.error(`Failed after ${maxRetries} attempts. Stopping.`);
328-
elements.start.textContent = 'Start Evolution';
329-
return '';
330-
}
331-
console.log(`Attempt ${retryCount}/${maxRetries} failed. Waiting ${retryDelay/1000} seconds before retry...`);
332-
seed = seed + 1;
333-
await new Promise(resolve => setTimeout(resolve, retryDelay));
334-
continue;
335-
}
336-
337-
const text = await response.text();
338-
console.log('Raw response:', text);
339-
elements.start.textContent = 'Start Evolution';
340-
return text;
341-
342-
} catch (error) {
343-
console.error('Fetch error:', error);
344-
retryCount++;
345-
if (retryCount >= maxRetries) {
346-
console.error(`Failed after ${maxRetries} attempts. Stopping.`);
347-
elements.start.textContent = 'Start Evolution';
348-
return '';
349-
}
350-
console.log(`Attempt ${retryCount}/${maxRetries} failed. Waiting ${retryDelay/1000} seconds before retry...`);
351-
await new Promise(resolve => setTimeout(resolve, retryDelay));
288+
289+
const messages = [
290+
{
291+
role: "system",
292+
content: formatInstructions
293+
},
294+
{
295+
role: "user",
296+
content: currentState
352297
}
353-
} while (retryCount < maxRetries);
298+
];
299+
300+
const response = await fetch('https://text.pollinations.ai/', {
301+
method: 'POST',
302+
headers: {
303+
'Content-Type': 'application/json'
304+
},
305+
body: JSON.stringify({
306+
messages: messages,
307+
model: getSelectedModel(),
308+
temperature: parseFloat(elements.temperature.value),
309+
seed: seed
310+
})
311+
});
312+
313+
if (!response.ok) {
314+
console.error(`Failed to generate text: ${response.status} ${response.statusText}`);
315+
elements.start.textContent = 'Start Evolution';
316+
return '';
317+
}
354318

319+
const text = await response.text();
320+
console.log('Raw response:', text);
355321
elements.start.textContent = 'Start Evolution';
356322
return '';
357323
} catch (error) {
@@ -398,7 +364,7 @@ <h2>History</h2>
398364

399365
// Wait 3 seconds before next iteration
400366
console.log('Waiting 3 seconds...');
401-
await new Promise(resolve => setTimeout(resolve, 1000));
367+
await new Promise(resolve => setTimeout(resolve, 2000));
402368
console.log('Wait complete');
403369
} catch (error) {
404370
console.error('Evolution error:', error);

0 commit comments

Comments
 (0)