Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions chat-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,21 +486,23 @@ document.addEventListener("DOMContentLoaded", () => {
chatBox.appendChild(loadingDiv);
chatBox.scrollTop = chatBox.scrollHeight;

const messages = [{ role: "system", content: window.memoryInstructions }];
const messages = [{ role: "user", content: window.memoryInstructions }];
const memories = Memory.getMemories();
if (memories?.length) {
messages.push({ role: "user", content: `Relevant memory:\n${memories.join("\n")}\nUse it in your response.` });
}

const HISTORY = 10;
const start = Math.max(0, currentSession.messages.length - HISTORY);
for (let i = start; i < currentSession.messages.length; i++) {
const end = currentSession.messages.length - 1;
const start = Math.max(0, end - HISTORY);
for (let i = start; i < end; i++) {
const m = currentSession.messages[i];
messages.push({ role: m.role === "ai" ? "assistant" : m.role, content: m.content });
}

if (overrideContent && messages[messages.length - 1].content !== overrideContent) {
messages.push({ role: "user", content: overrideContent });
const lastUser = overrideContent || currentSession.messages[end]?.content;
if (lastUser) {
messages.push({ role: "user", content: lastUser });
}

const model = (document.getElementById("model-select")?.value) || currentSession.model || "unity";
Expand Down
50 changes: 18 additions & 32 deletions screensaver.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,38 +139,24 @@ document.addEventListener("DOMContentLoaded", () => {
});
}

async function fetchDynamicPrompt() {
const metaPrompt = "Generate an image prompt of something new and wild. Respond with text only.";
const messages = [
{ role: "system", content: "Generate unique, new, fucked up and explicit wild image prompts as text only of outlandish and psychologically thrilling images. ie demented, evil, psychotic art, under 100 characters." },
{ role: "user", content: metaPrompt }
];
const body = {
messages,
model: "unity"
};
const seed = generateSeed();
const token = encodeURIComponent(window.POLLINATIONS_TOKEN || "");
const apiUrl =
`https://text.pollinations.ai/openai?&model=unity&seed=${seed}&token=${token}`;
try {
const response = await window.pollinationsFetch(apiUrl, {
method: "POST",
headers: { "Content-Type": "application/json", Accept: "application/json" },
body: JSON.stringify(body),
cache: "no-store",
});

const data = await response.json();
let generatedPrompt = data.choices?.[0]?.message?.content || data.choices?.[0]?.text || data.response;
if (!generatedPrompt) throw new Error("No prompt returned from API");
if (generatedPrompt.length > 100) generatedPrompt = generatedPrompt.substring(0, 100);
return generatedPrompt;
} catch (err) {
console.error("Failed to fetch dynamic prompt:", err);
throw err;
}
}
async function fetchDynamicPrompt() {
const metaPrompt = "Generate an image prompt of something new and wild. Respond with text only.";
const token = encodeURIComponent(window.POLLINATIONS_TOKEN || "");
const apiUrl = `https://text.pollinations.ai/${encodeURIComponent(metaPrompt)}?model=unity${token ? `&token=${token}` : ""}`;
try {
const response = await window.pollinationsFetch(apiUrl, {
method: "GET",
headers: { Accept: "text/plain" },
cache: "no-store",
});
const generatedPrompt = await response.text();
if (!generatedPrompt) throw new Error("No prompt returned from API");
return generatedPrompt;
} catch (err) {
console.error("Failed to fetch dynamic prompt:", err);
throw err;
}
}
async function updatePrompt() {
if (!screensaverActive || paused || !autoPromptEnabled || isFetchingPrompt) {
return false;
Expand Down