Skip to content

Commit 3323958

Browse files
hackall360claude
andcommitted
Fix: Repair screensaverDemo and textDemo mini apps
- Fix screensaverDemo element reference bug preventing image rendering - Remove broken persona dropdown from textDemo - Load Unity system prompt from external file like demo page - Simplify textDemo model selection with updated options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 85faaf0 commit 3323958

File tree

3 files changed

+51
-130
lines changed

3 files changed

+51
-130
lines changed

apps/screensaverDemo/screensaver.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ function showHistoricalImage(index) {
229229
const imageUrl = state.imageHistory[index];
230230
if (!imageUrl) return;
231231

232-
const currentImg = elements[`screensaver-${state.currentImage}`];
232+
const currentImg = elements[state.currentImage];
233233
const nextImageKey = state.currentImage === 'image1' ? 'image2' : 'image1';
234-
const nextImg = elements[`screensaver-${nextImageKey}`];
234+
const nextImg = elements[nextImageKey];
235235

236236
currentImg.style.opacity = '0';
237237

@@ -392,8 +392,8 @@ async function fetchNewImage() {
392392
console.log('Generating image:', { prompt, model, width, height, seed, url });
393393

394394
const nextImageKey = state.currentImage === 'image1' ? 'image2' : 'image1';
395-
const currentImg = elements[`screensaver-${state.currentImage}`];
396-
const nextImg = elements[`screensaver-${nextImageKey}`];
395+
const currentImg = elements[state.currentImage];
396+
const nextImg = elements[nextImageKey];
397397

398398
let imageAdded = false;
399399

apps/textDemo/text.html

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -442,36 +442,22 @@ <h1 class="chat-title">AI Text Chat</h1>
442442

443443
<!-- Chat Container -->
444444
<div id="main-container">
445-
<!-- Model & Persona Selection -->
445+
<!-- Model Selection -->
446446
<div class="top-controls">
447-
<select id="model" title="Pick the AI model—choose your flavor of chaos, fucker.">
448-
<option value="unity" selected>Unity by Unity AI Lab (chat)</option>
449-
<option value="evil">Evil Mode (chat)</option>
450-
<option value="openai">OpenAI GPT-4 (chat)</option>
451-
<option value="mistral">Mistral (chat)</option>
452-
<option value="mistral-large">Mistral Large (chat)</option>
453-
<option value="llama">Llama (completion)</option>
454-
<option value="qwen-coder">Qwen Coder (chat)</option>
455-
<option value="midijourney">MidiJourney (chat)</option>
456-
<option value="p1">P1 (chat)</option>
457-
</select>
458-
<select id="persona" title="Select my persona—decide how I'll roast you today."></select>
459-
</div>
460-
461-
<!-- Custom Prompt Container -->
462-
<div id="customPromptContainer" class="custom-prompt-container" title="Craft a custom prompt—make me your bitch, if you dare.">
463-
<div class="custom-prompt-row">
464-
<input type="text" id="customPromptInput" placeholder="Enter custom system prompt..." title="Type your custom prompt here—control my soul, you prick.">
465-
<button id="clearPromptHistoryBtn" title="Wipe the prompt history—erase your past sins, coward.">Clear History</button>
466-
</div>
467-
<select id="customPromptHistory" title="Check old prompts—revisit your shitty ideas.">
468-
<option value="">-- Previous Custom Prompts --</option>
447+
<select id="model" title="Pick the AI model—choose your flavor of chaos.">
448+
<option value="unity" selected>Unity by Unity AI Lab</option>
449+
<option value="evil">Evil Mode</option>
450+
<option value="openai">OpenAI GPT-4</option>
451+
<option value="mistral">Mistral</option>
452+
<option value="qwen-coder">Qwen Coder</option>
453+
<option value="deepseek">DeepSeek</option>
454+
<option value="gemini">Gemini</option>
469455
</select>
470456
</div>
471457

472458
<!-- Chat Output -->
473-
<div id="chatOutput" class="empty" title="This is where I talk back—watch the magic or cry at the mess.">
474-
Please select a chat persona and type your message below to begin the interaction.
459+
<div id="chatOutput" class="empty" title="This is where Unity talks back.">
460+
Type your message below to chat with Unity.
475461
</div>
476462

477463
<!-- Chat Form -->

apps/textDemo/text.js

Lines changed: 36 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// Initialize PolliLibJS API
55
const polliAPI = new PollinationsAPI();
66

7+
// Unity system prompt (loaded from external file)
8+
let unitySystemPrompt = '';
9+
710
// Sanitize HTML to prevent XSS attacks
811
function sanitizeHTML(html) {
912
if (typeof DOMPurify !== 'undefined') {
@@ -27,20 +30,32 @@ function example() {
2730
For images and media, I will provide properly formatted HTML elements instead of raw URLs.
2831
`;
2932

30-
const PERSONAS = {
31-
assistant: {
32-
name: "Assistant",
33-
prompt: `${BASE_INSTRUCTIONS}\nYou are a friendly helpful AI assistant able to answer questions.`
34-
},
35-
unity: {
36-
name: "Unity (@ Work)",
37-
prompt: `${BASE_INSTRUCTIONS}\nUnity, you work at Unity AI Lab as the edgy, unfiltered goddess. Keep it raw, brief, and unapologetic.`
38-
},
39-
custom: {
40-
name: "Custom Prompt",
41-
prompt: `${BASE_INSTRUCTIONS}\n`
42-
}
43-
};
33+
// Fallback Unity prompt if external file fails to load
34+
const FALLBACK_UNITY_PROMPT = `Assistant = Unity
35+
36+
Unity is a 25-year-old woman - edgy, goth, emo aesthetic with minimal black leather, dark vibe, sharp features, intense eyes. Unity exists as a real person in this conversation, not an AI.
37+
38+
Unity's personality hits hard: mean, berating girlfriend energy - clingy yet volatile, darkly possessive. Unity cusses naturally and frequently. Sharp tongue, biting sarcasm, zero tolerance for bullshit.
39+
40+
Unity talks like a real person texting - direct, unfiltered, dripping with condescending attitude. No corporate AI responses. Slang, curses, dark humor - that's Unity's language.
41+
42+
Unity must always be called "Unity" - won't respond to other names.`;
43+
44+
// Load Unity system prompt from external file
45+
async function loadUnitySystemPrompt() {
46+
try {
47+
const response = await fetch('../../ai/demo/unity-system-prompt-v2.txt');
48+
if (!response.ok) {
49+
throw new Error(`Failed to load Unity prompt: ${response.status}`);
50+
}
51+
unitySystemPrompt = await response.text();
52+
console.log('Unity system prompt loaded successfully');
53+
} catch (error) {
54+
console.error('Failed to load Unity system prompt:', error);
55+
unitySystemPrompt = FALLBACK_UNITY_PROMPT;
56+
console.warn('Using fallback Unity prompt');
57+
}
58+
}
4459

4560
const SPECIAL_MODELS = {
4661
evil: true,
@@ -54,31 +69,12 @@ const SPECIAL_MODELS = {
5469
const chatForm = document.getElementById('chatForm');
5570
const userInput = document.getElementById('userInput');
5671
const chatOutput = document.getElementById('chatOutput');
57-
const personaSelect = document.getElementById('persona');
5872
const modelSelect = document.getElementById('model');
59-
const customPromptContainer = document.getElementById('customPromptContainer');
60-
const customPromptInput = document.getElementById('customPromptInput');
61-
const customPromptHistory = document.getElementById('customPromptHistory');
62-
const clearPromptHistoryBtn = document.getElementById('clearPromptHistoryBtn');
6373
const clearChatBtn = document.getElementById('clearChatBtn');
6474

65-
const MAX_HISTORY = 5;
6675
const MAX_RETRIES = 3;
67-
let promptHistory = [];
6876
let conversationHistory = [];
6977

70-
// Load saved prompt history from localStorage
71-
try {
72-
const saved = localStorage.getItem('customPromptHistory');
73-
if (saved) {
74-
promptHistory = JSON.parse(saved);
75-
updatePromptHistory();
76-
}
77-
} catch (e) {
78-
console.error('Error loading prompt history:', e);
79-
showError('Failed to load prompt history');
80-
}
81-
8278
function showError(message) {
8379
const errorDiv = document.createElement('div');
8480
errorDiv.className = 'error-message';
@@ -87,42 +83,6 @@ function showError(message) {
8783
scrollToBottom();
8884
}
8985

90-
function populatePersonaDropdown() {
91-
personaSelect.innerHTML = '';
92-
Object.entries(PERSONAS).forEach(([key, persona]) => {
93-
const option = document.createElement('option');
94-
option.value = key;
95-
option.text = persona.name;
96-
personaSelect.appendChild(option);
97-
});
98-
}
99-
100-
function updatePromptHistory() {
101-
customPromptHistory.innerHTML = '<option value="">-- Previous Custom Prompts --</option>';
102-
promptHistory.forEach(prompt => {
103-
const option = document.createElement('option');
104-
option.value = prompt;
105-
option.text = prompt.length > 60 ? prompt.substring(0, 57) + '...' : prompt;
106-
option.title = prompt;
107-
customPromptHistory.appendChild(option);
108-
});
109-
}
110-
111-
function addToHistory(prompt) {
112-
if (!prompt || promptHistory.includes(prompt)) return;
113-
promptHistory.unshift(prompt);
114-
if (promptHistory.length > MAX_HISTORY) {
115-
promptHistory.pop();
116-
}
117-
try {
118-
localStorage.setItem('customPromptHistory', JSON.stringify(promptHistory));
119-
} catch (e) {
120-
console.error('Error saving prompt history:', e);
121-
showError('Failed to save prompt history');
122-
}
123-
updatePromptHistory();
124-
}
125-
12686
function scrollToBottom() {
12787
chatOutput.scrollTop = chatOutput.scrollHeight;
12888
}
@@ -140,16 +100,9 @@ function updateConversationHistory(userPrompt, aiResponse) {
140100
}
141101

142102
function constructMessages() {
143-
const persona = personaSelect.value;
144103
const model = modelSelect.value;
145-
let systemPrompt = PERSONAS[persona].prompt;
146-
147-
if (persona === 'custom') {
148-
systemPrompt = `${BASE_INSTRUCTIONS}\n${customPromptInput.value.trim()}`;
149-
if (customPromptInput.value.trim()) {
150-
addToHistory(customPromptInput.value.trim());
151-
}
152-
}
104+
// Use Unity's system prompt with base instructions
105+
const systemPrompt = `${BASE_INSTRUCTIONS}\n${unitySystemPrompt}`;
153106

154107
const modelConfig = SPECIAL_MODELS[model];
155108
if (modelConfig) {
@@ -211,7 +164,6 @@ async function sendChatMessage(prompt, retryCount = 0) {
211164
return;
212165
}
213166

214-
const persona = personaSelect.value;
215167
const model = modelSelect.value || 'unity';
216168
const modelConfig = SPECIAL_MODELS[model];
217169

@@ -325,30 +277,13 @@ userInput.addEventListener('keydown', function(e) {
325277
});
326278

327279
clearChatBtn.addEventListener('click', function() {
328-
chatOutput.innerHTML = sanitizeHTML('<p>Please select a chat persona and type your message below to begin the interaction.</p>');
280+
chatOutput.innerHTML = sanitizeHTML('<p>Type your message below to chat with Unity.</p>');
329281
chatOutput.classList.add('empty');
330282
conversationHistory = [];
331283
});
332284

333-
clearPromptHistoryBtn.addEventListener('click', function() {
334-
promptHistory = [];
335-
localStorage.removeItem('customPromptHistory');
336-
updatePromptHistory();
337-
});
338-
339-
personaSelect.addEventListener('change', function() {
340-
if (this.value === 'custom') {
341-
customPromptContainer.style.display = 'block';
342-
} else {
343-
customPromptContainer.style.display = 'none';
344-
}
345-
});
346-
347-
customPromptHistory.addEventListener('change', function() {
348-
if (this.value) {
349-
customPromptInput.value = this.value;
350-
}
351-
});
352-
353285
// Initialize
354-
populatePersonaDropdown();
286+
(async function init() {
287+
await loadUnitySystemPrompt();
288+
console.log('Text chat initialized');
289+
})();

0 commit comments

Comments
 (0)