mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 08:58:35 +00:00
Merge pull request #10954 from appwrite/optional-assistant
Optional assistant
This commit is contained in:
commit
06367eca69
2 changed files with 57 additions and 1 deletions
|
|
@ -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
|
||||
|
||||
<?php if ($enableAssistant): ?>
|
||||
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
|
||||
<?php endif; ?>
|
||||
|
||||
appwrite-browser:
|
||||
image: appwrite/browser:0.3.2
|
||||
|
|
|
|||
|
|
@ -148,11 +148,63 @@ class Install extends Action
|
|||
$httpsPort = ($httpsPort) ? $httpsPort : $defaultHTTPSPort;
|
||||
}
|
||||
|
||||
$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()) {
|
||||
$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 = [];
|
||||
|
||||
$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 +251,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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue