diff --git a/docker-compose.yml b/docker-compose.yml index c498141..e8bc6bc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,10 +2,11 @@ services: chroma: image: chromadb/chroma:latest ports: - - "8666:8000" + - '8666:8000' environment: - CHROMA_SERVER_HOST=0.0.0.0 - CHROMA_SERVER_HTTP_PORT=8000 + - CHROMA_SERVER_CORS_ALLOW_ORIGINS=["*"] volumes: - chroma_data:/chroma/chroma restart: unless-stopped diff --git a/main.js b/main.js index 3f6b802..a3333ce 100644 --- a/main.js +++ b/main.js @@ -7947,7 +7947,8 @@ var SemanticCacheService = class _SemanticCacheService { async initialize() { if (!this.config.enabled) return; try { - const chromaURL = this.config.chromaURL || "http://localhost:8000"; + const rawURL = this.config.chromaURL?.trim() || "http://localhost:8000"; + const chromaURL = rawURL.includes("://") ? rawURL : "http://localhost:8000"; this.client = new ChromaClient({ path: chromaURL }); this.collection = await this.client.getOrCreateCollection({ name: this.config.collectionName, @@ -9540,7 +9541,8 @@ var OllamaSettingTab = class extends import_obsidian4.PluginSettingTab { ); new import_obsidian4.Setting(containerEl).setName("ChromaDB URL").setDesc("URL for your ChromaDB instance (default: http://localhost:8000)").addText( (text) => text.setValue(this.plugin.settings.cacheConfig.chromaURL || "http://localhost:8000").onChange(async (value) => { - this.plugin.settings.cacheConfig.chromaURL = value; + const trimmed = value.trim(); + this.plugin.settings.cacheConfig.chromaURL = trimmed && trimmed.includes("://") ? trimmed : "http://localhost:8000"; await this.plugin.saveSettings(); }) ); diff --git a/src/main.ts b/src/main.ts index 0910fc0..d2d08cd 100755 --- a/src/main.ts +++ b/src/main.ts @@ -189,7 +189,10 @@ class OllamaSettingTab extends PluginSettingTab { text .setValue(this.plugin.settings.cacheConfig.chromaURL || 'http://localhost:8000') .onChange(async (value) => { - this.plugin.settings.cacheConfig.chromaURL = value; + const trimmed = value.trim(); + // Ensure a valid-looking URL; fall back to default if empty or malformed + this.plugin.settings.cacheConfig.chromaURL = + trimmed && trimmed.includes('://') ? trimmed : 'http://localhost:8000'; await this.plugin.saveSettings(); }) ); diff --git a/src/semantic-cache.ts b/src/semantic-cache.ts index 69efe09..d0a03b5 100644 --- a/src/semantic-cache.ts +++ b/src/semantic-cache.ts @@ -19,7 +19,9 @@ export class SemanticCacheService { if (!this.config.enabled) return; try { - const chromaURL = this.config.chromaURL || 'http://localhost:8000'; + const rawURL = this.config.chromaURL?.trim() || 'http://localhost:8000'; + // Guard against malformed URLs like 'http://:8666' + const chromaURL = rawURL.includes('://') ? rawURL : 'http://localhost:8000'; this.client = new ChromaClient({ path: chromaURL }); this.collection = await this.client.getOrCreateCollection({ name: this.config.collectionName,