From 0bc6bb1afb05b7583c16433c5b8346b79a6dcff9 Mon Sep 17 00:00:00 2001 From: Hackall <36754621+hackall360@users.noreply.github.com> Date: Mon, 15 Sep 2025 00:45:52 -0700 Subject: [PATCH] Use polliLib.image for image generation --- js/chat/chat-core.js | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/js/chat/chat-core.js b/js/chat/chat-core.js index c807637..82fe4df 100644 --- a/js/chat/chat-core.js +++ b/js/chat/chat-core.js @@ -410,17 +410,15 @@ document.addEventListener("DOMContentLoaded", () => { .register('image', async ({ prompt }) => { if (!(window.polliLib && window.polliClient)) return {}; try { - const url = window.polliLib.mcp.generateImageUrl(window.polliClient, { + const blob = await window.polliLib.image( prompt, - width: 512, - height: 512, - private: true, - nologo: true, - safe: true - }); + { width: 512, height: 512, private: true, nologo: true, safe: true }, + window.polliClient + ); + const url = blob?.url ? blob.url : URL.createObjectURL(blob); return { imageUrl: url }; } catch (e) { - console.warn('polliLib generateImageUrl failed', e); + console.warn('polliLib image failed', e); return {}; } }) @@ -474,11 +472,12 @@ document.addEventListener("DOMContentLoaded", () => { for (const prompt of imgPrompts) { if (!(window.polliLib && window.polliClient) || !prompt) continue; try { - const url = window.polliLib.mcp.generateImageUrl(window.polliClient, { prompt }); + const blob = await window.polliLib.image(prompt, { width: 512, height: 512, private: true, nologo: true, safe: true }, window.polliClient); + const url = blob?.url ? blob.url : URL.createObjectURL(blob); imageUrls.push(url); handled = true; } catch (e) { - console.warn('polliLib generateImageUrl failed', e); + console.warn('polliLib image failed', e); } } @@ -842,17 +841,15 @@ document.addEventListener("DOMContentLoaded", () => { await processPatterns(window.imagePatterns || [], async prompt => { if (!(window.polliLib && window.polliClient)) return; try { - const url = window.polliLib.mcp.generateImageUrl(window.polliClient, { + const blob = await window.polliLib.image( prompt, - width: 512, - height: 512, - private: true, - nologo: true, - safe: true - }); + { width: 512, height: 512, private: true, nologo: true, safe: true }, + window.polliClient + ); + const url = blob?.url ? blob.url : URL.createObjectURL(blob); imageUrls.push(url); } catch (e) { - console.warn('polliLib generateImageUrl failed', e); + console.warn('polliLib image failed', e); } });