From 43b470257b5e99ba86f464e8b60ab05ce389b12d Mon Sep 17 00:00:00 2001 From: Snider Date: Tue, 3 Mar 2026 10:10:02 +0000 Subject: [PATCH] feat(brain): configurable embedding model, default to EmbeddingGemma Make embedding model swappable via BRAIN_EMBEDDING_MODEL env var. Switch default from nomic-embed-text to embeddinggemma (Gemma 3 based, 2x better cluster separation in benchmarks). Default Ollama URL now points to ollama.lan (Linux homelab GPU). Co-Authored-By: Virgil --- Boot.php | 1 + Services/BrainService.php | 5 +++-- config.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Boot.php b/Boot.php index 8672f9d..c8d4e59 100644 --- a/Boot.php +++ b/Boot.php @@ -78,6 +78,7 @@ class Boot extends ServiceProvider ollamaUrl: config('mcp.brain.ollama_url', 'http://localhost:11434'), qdrantUrl: config('mcp.brain.qdrant_url', 'http://localhost:6334'), collection: config('mcp.brain.collection', 'openbrain'), + embeddingModel: config('mcp.brain.embedding_model', 'nomic-embed-text'), ); }); } diff --git a/Services/BrainService.php b/Services/BrainService.php index e71505d..e85ad32 100644 --- a/Services/BrainService.php +++ b/Services/BrainService.php @@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Log; class BrainService { - private const EMBEDDING_MODEL = 'nomic-embed-text'; + private const DEFAULT_MODEL = 'embeddinggemma'; private const VECTOR_DIMENSION = 768; @@ -19,6 +19,7 @@ class BrainService private string $ollamaUrl = 'http://localhost:11434', private string $qdrantUrl = 'http://localhost:6334', private string $collection = 'openbrain', + private string $embeddingModel = self::DEFAULT_MODEL, ) {} /** @@ -32,7 +33,7 @@ class BrainService { $response = Http::timeout(30) ->post("{$this->ollamaUrl}/api/embeddings", [ - 'model' => self::EMBEDDING_MODEL, + 'model' => $this->embeddingModel, 'prompt' => $text, ]); diff --git a/config.php b/config.php index 1ecb135..4e9ee99 100644 --- a/config.php +++ b/config.php @@ -82,9 +82,10 @@ return [ */ 'brain' => [ - 'ollama_url' => env('BRAIN_OLLAMA_URL', 'http://localhost:11434'), + 'ollama_url' => env('BRAIN_OLLAMA_URL', 'http://ollama.lan:11434'), 'qdrant_url' => env('BRAIN_QDRANT_URL', 'http://localhost:6334'), 'collection' => env('BRAIN_COLLECTION', 'openbrain'), + 'embedding_model' => env('BRAIN_EMBEDDING_MODEL', 'embeddinggemma'), ], ];