From 5678860d1358e993126c78baaaa82758f110a676 Mon Sep 17 00:00:00 2001 From: Darshan Date: Sun, 14 Dec 2025 13:07:26 +0530 Subject: [PATCH 1/2] add: optional support for assistant. --- app/views/install/compose.phtml | 3 +++ src/Appwrite/Platform/Tasks/Install.php | 36 ++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 34e0aee1ae..2f77d1d0c7 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -11,6 +11,7 @@ $httpsPort = $this->getParam('httpsPort', ''); $version = $this->getParam('version', ''); $organization = $this->getParam('organization', ''); $image = $this->getParam('image', ''); +$enableAssistant = $this->getParam('enableAssistant', false); ?>services: traefik: image: traefik:2.11 @@ -848,6 +849,7 @@ $image = $this->getParam('image', ''); - _APP_DB_USER - _APP_DB_PASS + appwrite-assistant: image: appwrite/assistant:0.8.4 container_name: appwrite-assistant @@ -857,6 +859,7 @@ $image = $this->getParam('image', ''); - appwrite environment: - _APP_ASSISTANT_OPENAI_API_KEY + appwrite-browser: image: appwrite/browser:0.3.2 diff --git a/src/Appwrite/Platform/Tasks/Install.php b/src/Appwrite/Platform/Tasks/Install.php index b210a020b9..1173a8ce27 100644 --- a/src/Appwrite/Platform/Tasks/Install.php +++ b/src/Appwrite/Platform/Tasks/Install.php @@ -148,11 +148,44 @@ class Install extends Action $httpsPort = ($httpsPort) ? $httpsPort : $defaultHTTPSPort; } + $enableAssistant = false; + if ($interactive == 'Y' && Console::isInteractive()) { + $answer = Console::confirm('Add Appwrite Assistant? (Y/n)'); + $enableAssistant = !empty($answer) && \strtolower($answer) === 'y'; + } + $input = []; $password = new Password(); $token = new Token(); foreach ($vars as $var) { + if ($var['name'] === '_APP_ASSISTANT_OPENAI_API_KEY') { + if (!$enableAssistant) { + $input[$var['name']] = ''; + continue; + } + + // key already exists + if (!empty($var['default'])) { + $input[$var['name']] = $var['default']; + continue; + } + + // if assistant enabled and no key, ask for it + if (Console::isInteractive() && $interactive === 'Y') { + $input[$var['name']] = Console::confirm('Enter your OpenAI API key for Appwrite Assistant:'); + if (empty($input[$var['name']])) { + Console::warning('No API key provided. Assistant will be disabled.'); + $enableAssistant = false; + $input[$var['name']] = ''; + } + continue; + } + + $input[$var['name']] = ''; + continue; + } + if (!empty($var['filter']) && ($interactive !== 'Y' || !Console::isInteractive())) { if ($data && $var['default'] !== null) { $input[$var['name']] = $var['default']; @@ -199,7 +232,8 @@ class Install extends Action ->setParam('httpsPort', $httpsPort) ->setParam('version', APP_VERSION_STABLE) ->setParam('organization', $organization) - ->setParam('image', $image); + ->setParam('image', $image) + ->setParam('enableAssistant', $enableAssistant); $templateForEnv->setParam('vars', $input); From ff160871aed3f0d66a9bf9ced0ae473c5ae4cc70 Mon Sep 17 00:00:00 2001 From: Darshan Date: Wed, 31 Dec 2025 19:21:19 +0530 Subject: [PATCH 2/2] update: check assistant status on upgrade as well. --- src/Appwrite/Platform/Tasks/Install.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/Install.php b/src/Appwrite/Platform/Tasks/Install.php index 1173a8ce27..e51ea3188a 100644 --- a/src/Appwrite/Platform/Tasks/Install.php +++ b/src/Appwrite/Platform/Tasks/Install.php @@ -149,9 +149,28 @@ class Install extends Action } $enableAssistant = false; + $assistantExistsInOldCompose = false; + + if ($data !== false && isset($compose)) { + try { + $assistantService = $compose->getService('appwrite-assistant'); + $assistantExistsInOldCompose = $assistantService !== null; + } catch (\Throwable) { + // assistant service doesn't exist, keep default false + } + } + if ($interactive == 'Y' && Console::isInteractive()) { - $answer = Console::confirm('Add Appwrite Assistant? (Y/n)'); - $enableAssistant = !empty($answer) && \strtolower($answer) === 'y'; + $prompt = 'Add Appwrite Assistant? (Y/n)' . ($assistantExistsInOldCompose ? ' [Currently enabled]' : ''); + $answer = Console::confirm($prompt); + + if (empty($answer)) { + $enableAssistant = $assistantExistsInOldCompose; + } else { + $enableAssistant = \strtolower($answer) === 'y'; + } + } elseif ($assistantExistsInOldCompose) { + $enableAssistant = true; } $input = [];