Skip to content

Commit b635762

Browse files
Merge pull request #47 from thefirehacker/3.6.0_Voice_DeepResearchPlayground_Integration
3.6.0 voice deep research playground integration
2 parents 70244cc + ed4c69f commit b635762

File tree

8 files changed

+361
-155
lines changed

8 files changed

+361
-155
lines changed

Canvas.html

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<!-- Content Security Policy - Fallback for local development and non-Amplify deployments -->
6-
<!-- Note: Amplify server headers take precedence when deployed -->
7-
<meta http-equiv="Content-Security-Policy" content="
8-
script-src 'self' 'unsafe-eval' 'unsafe-inline' https: data: blob:;
9-
style-src 'self' 'unsafe-inline' https: data:;
10-
connect-src 'self' https: wss: http://localhost:1234 http://localhost:11434;
11-
img-src 'self' data: https: blob:;
12-
font-src 'self' data: https:;
13-
worker-src 'self' blob: data:;
14-
object-src 'none';
15-
">
16-
<title>Canvas - TimeCapsule-SLM</title>
17-
<link rel="icon" type="image/png" href="lib/Media/TimeCapsule_04.png">
18-
<link rel="shortcut icon" type="image/png" href="lib/Media/TimeCapsule_04.png">
5+
<!-- Load Common Meta Configuration -->
6+
<script src="lib/common-meta.js"></script>
7+
<script>
8+
document.write(`
9+
<!-- Content Security Policy - Fallback for local development and non-Amplify deployments -->
10+
<meta http-equiv="Content-Security-Policy" content="${COMMON_META.csp}">
11+
<title>Canvas - ${COMMON_META.appSuffix}</title>
12+
<link rel="icon" type="image/png" href="${COMMON_META.favicon}">
13+
<link rel="shortcut icon" type="image/png" href="${COMMON_META.favicon}">
14+
`);
15+
</script>
1916
<style>
2017
* {
2118
margin: 0;
@@ -2013,11 +2010,25 @@ <h2 style="color: white; margin-bottom: 20px; text-align: center;">🏠 LM Studi
20132010
<h2 style="color: white; margin-bottom: 20px; text-align: center;">🦙 Ollama Connection</h2>
20142011
20152012
<div style="margin-bottom: 20px;">
2016-
<button id="connectOllama" class="ai-option-btn">
2017-
🔌 Connect to Ollama
2013+
<label style="color: white; display: block; margin-bottom: 8px; font-weight: 600;">Ollama Server URL:</label>
2014+
<input
2015+
type="text"
2016+
id="ollamaUrl"
2017+
value="http://localhost:11434"
2018+
placeholder="http://localhost:11434"
2019+
style="width: 100%; padding: 12px; border: 1px solid rgba(255,255,255,0.3);
2020+
border-radius: 8px; background: rgba(255,255,255,0.1); color: white;
2021+
font-size: 14px; margin-bottom: 10px;"
2022+
/>
2023+
<p style="color: rgba(255,255,255,0.7); font-size: 11px; margin-bottom: 15px;">
2024+
💡 Examples: http://localhost:11434, http://192.168.1.100:11434, https://my-ollama-server.com
2025+
</p>
2026+
2027+
<button id="connectOllama" class="ai-option-btn">
2028+
🔌 Connect to Ollama
20182029
</button>
20192030
<p style="color: rgba(255,255,255,0.8); font-size: 12px; margin-top: 5px;">
2020-
Connects to Ollama running on localhost:11434
2031+
Will connect to the URL specified above
20212032
</p>
20222033
</div>
20232034
@@ -2257,9 +2268,27 @@ <h2 style="color: white; margin-bottom: 20px; text-align: center;">🤖 Local Qw
22572268
updateStatus('🦙 Connecting to Ollama...');
22582269
document.getElementById('aiStatus').textContent = 'AI: Connecting to Ollama...';
22592270

2271+
// Get custom URL from input field, fallback to default
2272+
let ollamaUrl = 'http://localhost:11434';
2273+
const urlInput = document.getElementById('ollamaUrl');
2274+
if (urlInput && urlInput.value.trim()) {
2275+
ollamaUrl = urlInput.value.trim();
2276+
// Ensure URL doesn't end with slash
2277+
if (ollamaUrl.endsWith('/')) {
2278+
ollamaUrl = ollamaUrl.slice(0, -1);
2279+
}
2280+
// Validate URL format
2281+
try {
2282+
new URL(ollamaUrl);
2283+
} catch (e) {
2284+
throw new Error(`Invalid URL format: ${ollamaUrl}. Please use format like http://localhost:11434`);
2285+
}
2286+
}
2287+
2288+
console.log(`🔍 Attempting to connect to Ollama at: ${ollamaUrl}`);
2289+
22602290
// Test Ollama connection by fetching models
2261-
console.log('🔍 Testing Ollama connection...');
2262-
const testResponse = await fetch('http://localhost:11434/api/tags', {
2291+
const testResponse = await fetch(`${ollamaUrl}/api/tags`, {
22632292
method: 'GET',
22642293
headers: {
22652294
'Content-Type': 'application/json'
@@ -2269,7 +2298,7 @@ <h2 style="color: white; margin-bottom: 20px; text-align: center;">🤖 Local Qw
22692298

22702299
if (!testResponse.ok) {
22712300
console.error('❌ Ollama connection test failed:', testResponse.status, testResponse.statusText);
2272-
throw new Error(`Ollama connection failed: ${testResponse.status} ${testResponse.statusText}. Make sure Ollama is running on port 11434.`);
2301+
throw new Error(`Ollama connection failed: ${testResponse.status} ${testResponse.statusText}. Make sure Ollama is running at ${ollamaUrl}.`);
22732302
}
22742303

22752304
const modelsData = await testResponse.json();
@@ -2292,7 +2321,7 @@ <h2 style="color: white; margin-bottom: 20px; text-align: center;">🤖 Local Qw
22922321
selectedModel = modelsData.models?.[0]?.name || 'qwen2.5:0.5b';
22932322
}
22942323

2295-
aiSession = { type: 'ollama', model: selectedModel, baseURL: 'http://localhost:11434' };
2324+
aiSession = { type: 'ollama', model: selectedModel, baseURL: ollamaUrl };
22962325
document.getElementById('aiStatus').textContent = `AI: Ollama (${selectedModel}) ✅`;
22972326
document.getElementById('generateBtn').disabled = false;
22982327
document.getElementById('initAIBtn').textContent = `🦙 Ollama Ready`;
@@ -2301,8 +2330,8 @@ <h2 style="color: white; margin-bottom: 20px; text-align: center;">🤖 Local Qw
23012330
updateHeaderAIStatus();
23022331

23032332
console.log(`🦙 Ollama session initialized successfully with model: ${selectedModel}`);
2304-
updateStatus(`🦙 Ollama connected successfully!`);
2305-
addChatMessage('system', `🦙 Ollama connected! Using model: ${selectedModel}. Fully local processing with GGUF models - no API costs.`);
2333+
updateStatus(`🦙 Ollama connected successfully at ${ollamaUrl}!`);
2334+
addChatMessage('system', `🦙 Ollama connected at ${ollamaUrl}! Using model: ${selectedModel}. Fully local processing with GGUF models - no API costs.`);
23062335

23072336
// Track Ollama connection
23082337
if (window.AppConfig) {
@@ -2314,7 +2343,7 @@ <h2 style="color: white; margin-bottom: 20px; text-align: center;">🤖 Local Qw
23142343

23152344
let errorMessage = `❌ Failed to connect to Ollama: ${error.message}`;
23162345
if (error.message.includes('Failed to fetch')) {
2317-
errorMessage += `\n\n💡 Make sure Ollama is installed and running: \n1. Install Ollama from https://ollama.ai\n2. Run: ollama serve\n3. Pull a Qwen model: ollama pull qwen2.5:0.5b`;
2346+
errorMessage += `\n\n💡 Make sure Ollama is installed and running: \n1. Install Ollama from https://ollama.ai\n2. Run: ollama serve\n3. Pull a Qwen model: ollama pull qwen2.5:0.5b\n4. Ensure CORS is enabled with OLLAMA_ORIGINS`;
23182347
}
23192348

23202349
addChatMessage('system', errorMessage);

DeepResearch.html

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<!-- Content Security Policy - Fallback for local development and non-Amplify deployments -->
6-
<meta http-equiv="Content-Security-Policy" content="
7-
script-src 'self' 'unsafe-eval' 'unsafe-inline' https: data: blob:;
8-
style-src 'self' 'unsafe-inline' https: data:;
9-
connect-src 'self' https: wss: http://localhost:1234 http://localhost:11434;
10-
img-src 'self' data: https: blob:;
11-
font-src 'self' data: https:;
12-
worker-src 'self' blob: data:;
13-
object-src 'none';
14-
">
15-
<title>DeepResearch TimeCapsule - TimeCapsule-SLM</title>
16-
<link rel="icon" type="image/png" href="lib/Media/TimeCapsule_04.png">
17-
<link rel="shortcut icon" type="image/png" href="lib/Media/TimeCapsule_04.png">
5+
<!-- Load Common Meta Configuration -->
6+
<script src="lib/common-meta.js?v=2025010302"></script>
7+
<script>
8+
document.write(`
9+
<!-- Content Security Policy - Fallback for local development and non-Amplify deployments -->
10+
<meta http-equiv="Content-Security-Policy" content="${COMMON_META.csp}">
11+
<title>DeepResearch TimeCapsule - ${COMMON_META.appSuffix}</title>
12+
<link rel="icon" type="image/png" href="${COMMON_META.favicon}">
13+
<link rel="shortcut icon" type="image/png" href="${COMMON_META.favicon}">
14+
`);
15+
</script>
1816

1917
<!-- Marked.js for Markdown rendering -->
2018
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
@@ -520,8 +518,17 @@
520518
}
521519

522520
.ai-status.error {
523-
background: rgba(244, 67, 54, 0.2);
524-
border-color: rgba(244, 67, 54, 0.5);
521+
background: linear-gradient(135deg, rgba(255, 152, 0, 0.15) 0%, rgba(255, 193, 7, 0.1) 100%);
522+
border: 1px solid rgba(255, 152, 0, 0.3);
523+
color: rgba(255, 255, 255, 0.95);
524+
box-shadow: 0 2px 8px rgba(255, 152, 0, 0.1);
525+
}
526+
527+
.ai-status.error::before {
528+
content: '⚠️';
529+
font-size: 18px;
530+
margin-right: 8px;
531+
vertical-align: middle;
525532
}
526533

527534
.research-tabs {
@@ -1277,7 +1284,7 @@ <h3>✨ Features:</h3>
12771284
<!-- Scripts -->
12781285
<script src="config.js"></script>
12791286
<script src="lib/useragreement/agreement.js"></script>
1280-
<script src="lib/AIAssistant/AIAssistant-Backend.js"></script>
1287+
<script src="lib/AIAssistant/AIAssistant-Backend.js?v=2025010301"></script>
12811288

12821289
<!-- Vector Store Dependencies (CDN for development) -->
12831290
<!-- Load Transformers.js as ES module with proper handling -->
@@ -1298,8 +1305,9 @@ <h3>✨ Features:</h3>
12981305
// Configure for browser use
12991306
if (transformersModule.env) {
13001307
transformersModule.env.allowRemoteModels = true;
1301-
transformersModule.env.remoteURL = 'https://huggingface.co/';
13021308
transformersModule.env.allowLocalModels = false;
1309+
transformersModule.env.remoteURL = 'https://huggingface.co/';
1310+
transformersModule.env.localURL = null; // Disable local models
13031311
}
13041312

13051313
console.log('✅ Transformers.js configured and available globally');

Playground.html

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<!-- Content Security Policy - Fallback for local development and non-Amplify deployments -->
6-
<meta http-equiv="Content-Security-Policy" content="
7-
script-src 'self' 'unsafe-eval' 'unsafe-inline' https: data: blob:;
8-
style-src 'self' 'unsafe-inline' https: data:;
9-
connect-src 'self' https: wss: http://localhost:1234 http://localhost:11434;
10-
img-src 'self' data: https: blob:;
11-
font-src 'self' data: https:;
12-
worker-src 'self' blob: data:;
13-
object-src 'none';
14-
">
15-
<title>AI Playground - TimeCapsule-SLM</title>
16-
<link rel="icon" type="image/png" href="lib/Media/TimeCapsule_04.png">
17-
<link rel="shortcut icon" type="image/png" href="lib/Media/TimeCapsule_04.png">
5+
<!-- Load Common Meta Configuration -->
6+
<script src="lib/common-meta.js?v=2025010302"></script>
7+
<script>
8+
document.write(`
9+
<!-- Content Security Policy - Fallback for local development and non-Amplify deployments -->
10+
<meta http-equiv="Content-Security-Policy" content="${COMMON_META.csp}">
11+
<title>AI Playground - ${COMMON_META.appSuffix}</title>
12+
<link rel="icon" type="image/png" href="${COMMON_META.favicon}">
13+
<link rel="shortcut icon" type="image/png" href="${COMMON_META.favicon}">
14+
`);
15+
</script>
1816

1917
<!-- Marked.js for Markdown rendering -->
2018
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
@@ -32,6 +30,15 @@
3230
window.transformers = await import('https://cdn.jsdelivr.net/npm/@xenova/[email protected]');
3331
console.log('✅ Transformers.js loaded successfully');
3432

33+
// Configure Transformers.js environment for browser use
34+
if (window.transformers.env) {
35+
window.transformers.env.allowRemoteModels = true;
36+
window.transformers.env.allowLocalModels = false;
37+
window.transformers.env.remoteURL = 'https://huggingface.co/';
38+
window.transformers.env.localURL = null; // Disable local models
39+
console.log('🔧 Transformers.js configured for remote models only');
40+
}
41+
3542
// Signal that Transformers.js is ready
3643
window.dispatchEvent(new CustomEvent('transformersLoaded'));
3744
}
@@ -373,10 +380,18 @@
373380
}
374381

375382
.status-indicator.error {
376-
background: linear-gradient(45deg, #ff416c 0%, #ff4b2b 100%) !important;
377-
color: white !important;
378-
border: 1px solid rgba(255, 65, 108, 0.3) !important;
379-
box-shadow: 0 2px 8px rgba(255, 65, 108, 0.2);
383+
background: linear-gradient(135deg, rgba(255, 152, 0, 0.2) 0%, rgba(255, 193, 7, 0.15) 100%) !important;
384+
color: rgba(255, 255, 255, 0.95) !important;
385+
border: 1px solid rgba(255, 152, 0, 0.4) !important;
386+
box-shadow: 0 2px 8px rgba(255, 152, 0, 0.15);
387+
position: relative;
388+
}
389+
390+
.status-indicator.error::before {
391+
content: '⚠️';
392+
font-size: 16px;
393+
margin-right: 6px;
394+
vertical-align: middle;
380395
}
381396

382397
.status-indicator.info {
@@ -805,7 +820,7 @@ <h2>🚀 Welcome to AI Playground</h2>
805820
<script src="config.js"></script>
806821

807822
<!-- Load Dependencies -->
808-
<script src="lib/AIAssistant/AIAssistant-Backend.js"></script>
823+
<script src="lib/AIAssistant/AIAssistant-Backend.js?v=2025010301"></script>
809824
<script src="lib/Pages/DeepResearch/deepresearch.js"></script>
810825
<script src="lib/Pages/DeepResearch/vector-store.js"></script>
811826

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,22 @@ curl http://localhost:11434/api/tags
551551
> - **All Platforms:** Use `OLLAMA_ORIGINS="*"` for testing, then restrict to specific domains
552552
> - **Always verify** your setup with: `curl http://localhost:11434/api/tags`
553553
554+
### 🌐 **Custom Ollama URL (Local Builds Only)**
555+
556+
> **⚠️ Note**: Custom URLs only work in local builds, not hosted version.
557+
558+
**Setup:**
559+
1. **Add URL to CSP**: Edit `/lib/common-meta.js` → add your URL to `connectSrc` array
560+
```javascript
561+
'http://192.168.1.100:11434', // Example: your Ollama server
562+
```
563+
564+
2. **Use in App**: Click "Connect Ollama" → accept agreement → Enter custom URL in popup
565+
- **DeepResearch**: Click "🦙 Connect Ollama"
566+
- **Playground**: Click "Connect AI" → Select Ollama
567+
568+
**Examples**: `http://192.168.1.100:11434`, `http://localhost:9434`, `https://ollama.mydomain.com`
569+
554570
---
555571

556572
## 🏠 **LM Studio Integration**

0 commit comments

Comments
 (0)