diff --git a/app/controllers/api/console.php b/app/controllers/api/console.php index ac91f9ba38..82c1fc1256 100644 --- a/app/controllers/api/console.php +++ b/app/controllers/api/console.php @@ -55,10 +55,10 @@ App::post('/v1/console/assistant') ->label('abuse-key', 'userId:{userId}') ->param('prompt', '', new Text(2000), 'Prompt') ->inject('response') - ->action(function (string $query, Response $response) { + ->action(function (string $prompt, Response $response) { $ch = curl_init('http://appwrite-assistant:3003/'); $responseHeaders = []; - $query = json_encode(['prompt' => $query]); + $query = json_encode(['prompt' => $prompt]); $headers = ['accept: text/event-stream']; $handleEvent = function ($ch, $data) use ($response) { $response->chunk($data); diff --git a/app/controllers/general.php b/app/controllers/general.php index d8cc537b20..7dcc4b0541 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -148,8 +148,8 @@ function router(App $utopia, Database $dbForConsole, SwooleRequest $swooleReques $body = $execution['responseBody'] ?? ''; $encodingKey = \array_search('x-open-runtimes-encoding', \array_column($execution['responseHeaders'], 'name')); - if (!empty($encodingKey)) { - if (($execution['responseHeaders'][$encodingKey] ?? '') === 'base64') { + if ($encodingKey !== false) { + if (($execution['responseHeaders'][$encodingKey]['value'] ?? '') === 'base64') { $body = \base64_decode($body); } }