Skip to content

Commit 69d54bd

Browse files
Merge pull request #51 from thefirehacker/3.6.0_Voice_DeepResearchPlayground_Integration
3.6.0 voice deep research playground integration
2 parents da25dda + ff42235 commit 69d54bd

File tree

12 files changed

+1709
-143
lines changed

12 files changed

+1709
-143
lines changed

Canvas.html

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,9 @@ <h3>🎮 Controls</h3>
12591259
<!-- Configuration and Analytics -->
12601260
<script src="config.js"></script>
12611261

1262+
<!-- Shared Systems -->
1263+
<script src="lib/Pages/shared/ai-connection-manager.js"></script>
1264+
12621265
<!-- AI Agent System -->
12631266
<script src="lib/agent/canvas.js"></script>
12641267

@@ -2270,6 +2273,32 @@ <h2 style="color: white; margin-bottom: 20px; text-align: center;">🤖 Local Qw
22702273
updateStatus('🦙 Connecting to Ollama...');
22712274
document.getElementById('aiStatus').textContent = 'AI: Connecting to Ollama...';
22722275

2276+
// Check if we already have a shared AI connection
2277+
if (window.SharedAIConnection && window.SharedAIConnection.isAIConnected()) {
2278+
const currentProvider = window.SharedAIConnection.getProviderInfo();
2279+
console.log('✅ Shared AI connection already exists:', currentProvider);
2280+
2281+
if (currentProvider.provider === 'ollama') {
2282+
// Use existing Ollama connection
2283+
const sharedAI = window.SharedAIConnection.getAIAssistant();
2284+
aiSession = {
2285+
type: 'ollama',
2286+
model: currentProvider.model,
2287+
baseURL: currentProvider.baseURL || 'http://localhost:11434'
2288+
};
2289+
2290+
document.getElementById('aiStatus').textContent = `AI: Ollama (${currentProvider.model}) ✅`;
2291+
document.getElementById('generateBtn').disabled = false;
2292+
document.getElementById('initAIBtn').textContent = `🦙 Ollama Ready`;
2293+
2294+
updateHeaderAIStatus();
2295+
updateStatus(`🦙 Using existing Ollama connection (${currentProvider.model})!`);
2296+
addChatMessage('system', `🦙 Using existing Ollama connection! Model: ${currentProvider.model}. Fully local processing with GGUF models - no API costs.`);
2297+
2298+
return;
2299+
}
2300+
}
2301+
22732302
// Get custom URL from input field, fallback to default
22742303
let ollamaUrl = 'http://localhost:11434';
22752304
const urlInput = document.getElementById('ollamaUrl');
@@ -2328,6 +2357,32 @@ <h2 style="color: white; margin-bottom: 20px; text-align: center;">🤖 Local Qw
23282357
document.getElementById('generateBtn').disabled = false;
23292358
document.getElementById('initAIBtn').textContent = `🦙 Ollama Ready`;
23302359

2360+
// Store in shared AI connection manager for cross-environment use
2361+
if (window.SharedAIConnection) {
2362+
try {
2363+
// Create a mock AI assistant for Canvas's simpler needs
2364+
const canvasAI = {
2365+
type: 'ollama',
2366+
model: selectedModel,
2367+
baseURL: ollamaUrl,
2368+
generateContent: async (prompt, context) => {
2369+
// Canvas uses its own generation logic
2370+
return null;
2371+
}
2372+
};
2373+
2374+
window.SharedAIConnection.setConnection('ollama', canvasAI, {
2375+
provider: 'ollama',
2376+
model: selectedModel,
2377+
baseURL: ollamaUrl
2378+
});
2379+
2380+
console.log('✅ Ollama connection stored in shared manager');
2381+
} catch (sharedError) {
2382+
console.warn('⚠️ Failed to store in shared AI manager:', sharedError);
2383+
}
2384+
}
2385+
23312386
// Update header status
23322387
updateHeaderAIStatus();
23332388

DeepResearch.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,9 @@ <h3>✨ Features:</h3>
14021402
<!-- JSZip for PPTX parsing -->
14031403
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
14041404

1405+
<!-- Shared Systems -->
1406+
<script src="lib/Pages/shared/ai-connection-manager.js"></script>
1407+
14051408
<!-- Vector Store Module -->
14061409
<script src="lib/Pages/DeepResearch/vector-store.js"></script>
14071410
<script src="lib/Pages/DeepResearch/deepresearch.js"></script>
@@ -1479,7 +1482,7 @@ <h3>✨ Features:</h3>
14791482
}
14801483
}, 100);
14811484

1482-
const initializeApp = () => {
1485+
const initializeApp = async () => {
14831486
console.log('🔍 Script loading check:');
14841487
console.log(' - DeepResearchApp:', !!window.DeepResearchApp);
14851488
console.log(' - AIAssistant:', !!window.AIAssistant);
@@ -1492,13 +1495,14 @@ <h3>✨ Features:</h3>
14921495

14931496
if (window.DeepResearchApp) {
14941497
window.deepResearch = new DeepResearchApp();
1498+
await window.deepResearch.init();
14951499
console.log('✅ Deep Research Studio initialized with full Vector Store support');
14961500
} else {
14971501
console.error('❌ DeepResearchApp not found - script loading issue');
14981502
}
14991503
};
15001504

1501-
const initializeAppWithoutVectorStore = () => {
1505+
const initializeAppWithoutVectorStore = async () => {
15021506
console.log('🔍 Script loading check (Vector Store disabled):');
15031507
console.log(' - DeepResearchApp:', !!window.DeepResearchApp);
15041508
console.log(' - AIAssistant:', !!window.AIAssistant);
@@ -1513,6 +1517,7 @@ <h3>✨ Features:</h3>
15131517
// Set a flag to disable vector store features
15141518
window.VECTOR_STORE_DISABLED = true;
15151519
window.deepResearch = new DeepResearchApp();
1520+
await window.deepResearch.init();
15161521
console.log('⚠️ Deep Research Studio initialized WITHOUT Vector Store (document features disabled)');
15171522
} else {
15181523
console.error('❌ DeepResearchApp not found - script loading issue');

Playground.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ <h3>🎮 AI Persona</h3>
727727
<div class="control-group">
728728
<label>Document Store (RAG)</label>
729729
<button id="uploadDocuments" class="btn" disabled>📄 Upload Documents</button>
730-
<button id="manageDocuments" class="btn">📚 Manage Store</button>
730+
<button id="manageDocuments" class="btn">📚 Display Knowledge</button>
731731
<div id="vectorStatus" class="status-indicator info">Vector Store Ready</div>
732732
</div>
733733

@@ -826,7 +826,8 @@ <h2>🚀 Welcome to AI Playground</h2>
826826
<script src="lib/Pages/DeepResearch/deepresearch.js"></script>
827827
<script src="lib/Pages/DeepResearch/vector-store.js"></script>
828828

829-
<!-- Load Shared RAG System -->
829+
<!-- Load Shared Systems -->
830+
<script src="lib/Pages/shared/ai-connection-manager.js"></script>
830831
<script src="lib/Pages/shared/rag-system.js"></script>
831832

832833
<!-- Load User Agreement Module -->

index.html

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,21 @@
223223
box-shadow: 0 8px 25px rgba(79, 172, 254, 0.6);
224224
}
225225

226+
/* Launching Soon Button Style */
227+
.feature-cta.launching-soon {
228+
background: linear-gradient(45deg, #ff9800 0%, #ffc107 100%);
229+
color: #333;
230+
cursor: default;
231+
pointer-events: none;
232+
opacity: 0.8;
233+
box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
234+
}
235+
236+
.feature-cta.launching-soon:hover {
237+
transform: none;
238+
box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
239+
}
240+
226241
.feature-cta.research {
227242
background: linear-gradient(45deg, #fa709a 0%, #fee140 100%);
228243
box-shadow: 0 4px 15px rgba(250, 112, 154, 0.4);
@@ -791,10 +806,10 @@ <h2 class="feature-title">Canvas Creative Environment</h2>
791806
<li>Interactive visualization tools</li>
792807
</ul>
793808

794-
<a href="Canvas.html" class="feature-cta">
795-
<span>🎨</span>
796-
Launch Canvas
797-
</a>
809+
<div class="feature-cta launching-soon">
810+
<span>🚀</span>
811+
Launching Soon
812+
</div>
798813
</div>
799814
</div>
800815

@@ -891,13 +906,14 @@ <h2 class="feature-title">Canvas Creative Environment</h2>
891906
window.AppConfig.trackEvent('keyboard_navigation', 'navigation', 'playground');
892907
}
893908
}
894-
if (e.key === '3' || e.key === 'c' || e.key === 'C') {
895-
window.location.href = 'Canvas.html';
896-
// Track navigation event
897-
if (window.AppConfig) {
898-
window.AppConfig.trackEvent('keyboard_navigation', 'navigation', 'canvas');
899-
}
900-
}
909+
// Canvas navigation temporarily disabled (launching soon)
910+
// if (e.key === '3' || e.key === 'c' || e.key === 'C') {
911+
// window.location.href = 'Canvas.html';
912+
// // Track navigation event
913+
// if (window.AppConfig) {
914+
// window.AppConfig.trackEvent('keyboard_navigation', 'navigation', 'canvas');
915+
// }
916+
// }
901917
});
902918

903919
// Add smooth scroll behavior for better UX
@@ -914,13 +930,12 @@ <h2 class="feature-title">Canvas Creative Environment</h2>
914930
});
915931
});
916932

917-
// Track feature card clicks
918-
document.querySelectorAll('.feature-cta').forEach((cta, index) => {
933+
// Track feature card clicks (exclude launching-soon buttons)
934+
document.querySelectorAll('.feature-cta:not(.launching-soon)').forEach((cta, index) => {
919935
cta.addEventListener('click', () => {
920936
if (window.AppConfig) {
921937
const feature = index === 0 ? 'deepresearch' :
922-
index === 1 ? 'playground' :
923-
index === 2 ? 'canvas' : 'unknown';
938+
index === 1 ? 'playground' : 'unknown';
924939
window.AppConfig.trackEvent('feature_clicked', 'navigation', feature);
925940
}
926941
});

lib/AIAssistant/AIAssistant-Backend.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ When user asks for something, generate creative, compact p5.js code that creates
121121

122122
checkGlobalAgreementStatus() {
123123
// Check if the global agreement system has already accepted the agreement
124-
if (window.userAgreement && window.userAgreement.isAccepted && window.userAgreement.isAccepted()) {
124+
if (window.userAgreement && window.userAgreement.isAgreementAccepted && window.userAgreement.isAgreementAccepted()) {
125125
console.log('✅ Global user agreement already accepted - enabling AI features');
126126
this.userAgreementAccepted = true;
127-
this.agreementTimestamp = Date.now();
127+
this.agreementTimestamp = window.userAgreement.getAgreementTimestamp() || Date.now();
128128
} else {
129129
console.log('⚠️ Global user agreement not found or not accepted');
130130
}
@@ -526,12 +526,21 @@ When user asks for something, generate creative, compact p5.js code that creates
526526
this.agreementTimestamp = Date.now();
527527
this.agreementModalOpen = false;
528528

529+
// Sync with global agreement system
530+
if (window.userAgreement && window.userAgreement.acceptAgreement) {
531+
console.log('🔄 Syncing agreement acceptance with global system');
532+
window.userAgreement.userAgreementAccepted = true;
533+
window.userAgreement.agreementTimestamp = new Date(this.agreementTimestamp);
534+
window.userAgreement.saveAgreementStatus();
535+
window.userAgreement.updateAgreementStatusDisplay();
536+
}
537+
529538
const modal = document.getElementById('userAgreementModal');
530539
if (modal) {
531540
modal.remove();
532541
}
533542

534-
console.log('✅ User agreement accepted');
543+
console.log('✅ User agreement accepted and synced globally');
535544
console.log('🔍 pendingAIInitialization status:', this.pendingAIInitialization);
536545

537546
if (this.pendingAIInitialization) {
@@ -1504,6 +1513,15 @@ When user asks for something, generate creative, compact p5.js code that creates
15041513
}
15051514

15061515
async generateContent(prompt, type = 'creative') {
1516+
// Validate that AI session is properly established
1517+
if (!this.aiSession) {
1518+
throw new Error('AI session not established. Please connect to an AI provider first.');
1519+
}
1520+
1521+
if (!this.aiSession.provider) {
1522+
throw new Error('AI session is missing provider information. Please reconnect to your AI provider.');
1523+
}
1524+
15071525
if (type === 'research' || type === 'general') {
15081526
// For research and general generation, use general context instead of creative
15091527
this.setChatMode('general');
@@ -1520,6 +1538,11 @@ When user asks for something, generate creative, compact p5.js code that creates
15201538
let content = '';
15211539

15221540
if (this.aiSession.provider === 'ollama') {
1541+
// Validate Ollama session has required properties
1542+
if (!this.aiSession.baseURL || !this.aiSession.model) {
1543+
throw new Error('Ollama session is incomplete. Missing baseURL or model. Please reconnect.');
1544+
}
1545+
15231546
// Use simple chat format for general/RAG responses
15241547
const chatPrompt = `<|im_start|>system
15251548
You are a helpful AI assistant. Provide clear, accurate, and informative responses based on the given context. Always respond in plain text format.<|im_end|>
@@ -1561,7 +1584,7 @@ ${userMessage}<|im_end|>
15611584
content = data.response || '';
15621585

15631586
} else {
1564-
throw new Error('Only Ollama provider is currently supported for general/research generation');
1587+
throw new Error(`Provider '${this.aiSession.provider}' is not currently supported for general/research generation`);
15651588
}
15661589

15671590
return content.trim();

0 commit comments

Comments
 (0)