Merge branch '1.4.x' of https://github.com/appwrite/appwrite into feat-query-support-attributes-indexes
This commit is contained in:
commit
0630f56dd5
1
.env
1
.env
|
@ -88,3 +88,4 @@ _APP_GRAPHQL_MAX_DEPTH=3
|
||||||
DOCKERHUB_PULL_USERNAME=
|
DOCKERHUB_PULL_USERNAME=
|
||||||
DOCKERHUB_PULL_PASSWORD=
|
DOCKERHUB_PULL_PASSWORD=
|
||||||
DOCKERHUB_PULL_EMAIL=
|
DOCKERHUB_PULL_EMAIL=
|
||||||
|
OPENAI_API_KEY=YOUR_OPENAI_API_KEY
|
|
@ -31,6 +31,8 @@ return [
|
||||||
'audio/ogg', // Ogg Vorbis RFC 5334
|
'audio/ogg', // Ogg Vorbis RFC 5334
|
||||||
'audio/vorbis', // Vorbis RFC 5215
|
'audio/vorbis', // Vorbis RFC 5215
|
||||||
'audio/vnd.wav', // wav RFC 2361
|
'audio/vnd.wav', // wav RFC 2361
|
||||||
|
'audio/aac', //AAC audio
|
||||||
|
'audio/x-hx-aac-adts', // AAC audio
|
||||||
|
|
||||||
// Microsoft Word
|
// Microsoft Word
|
||||||
'application/msword',
|
'application/msword',
|
||||||
|
|
|
@ -998,7 +998,7 @@ App::post('/v1/account/sessions/phone')
|
||||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||||
->label('sdk.response.model', Response::MODEL_TOKEN)
|
->label('sdk.response.model', Response::MODEL_TOKEN)
|
||||||
->label('abuse-limit', 10)
|
->label('abuse-limit', 10)
|
||||||
->label('abuse-key', 'url:{url},email:{param-email}')
|
->label('abuse-key', 'url:{url},email:{param-phone}')
|
||||||
->param('userId', '', new CustomId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
|
->param('userId', '', new CustomId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
|
||||||
->param('phone', '', new Phone(), 'Phone number. Format this number with a leading \'+\' and a country code, e.g., +16175551212.')
|
->param('phone', '', new Phone(), 'Phone number. Format this number with a leading \'+\' and a country code, e.g., +16175551212.')
|
||||||
->inject('request')
|
->inject('request')
|
||||||
|
|
|
@ -4,6 +4,7 @@ use Appwrite\Extend\Exception;
|
||||||
use Appwrite\Utopia\Response;
|
use Appwrite\Utopia\Response;
|
||||||
use Utopia\App;
|
use Utopia\App;
|
||||||
use Utopia\Database\Document;
|
use Utopia\Database\Document;
|
||||||
|
use Utopia\Validator\Text;
|
||||||
|
|
||||||
App::init()
|
App::init()
|
||||||
->groups(['console'])
|
->groups(['console'])
|
||||||
|
@ -38,3 +39,58 @@ App::get('/v1/console/variables')
|
||||||
|
|
||||||
$response->dynamic($variables, Response::MODEL_CONSOLE_VARIABLES);
|
$response->dynamic($variables, Response::MODEL_CONSOLE_VARIABLES);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
App::post('/v1/console/assistant')
|
||||||
|
->desc('Ask Query')
|
||||||
|
->groups(['api', 'assistant'])
|
||||||
|
->label('scope', 'public')
|
||||||
|
->label('sdk.auth', [APP_AUTH_TYPE_SESSION])
|
||||||
|
->label('sdk.namespace', 'assistant')
|
||||||
|
->label('sdk.method', 'chat')
|
||||||
|
->label('sdk.description', '/docs/references/assistant/chat.md')
|
||||||
|
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||||
|
->label('sdk.response.type', Response::CONTENT_TYPE_TEXT)
|
||||||
|
->label('abuse-limit', 15)
|
||||||
|
->label('abuse-key', 'userId:{userId}')
|
||||||
|
->param('query', '', new Text(2000), 'Query')
|
||||||
|
->inject('response')
|
||||||
|
->action(function (string $query, Response $response) {
|
||||||
|
$ch = curl_init('http://appwrite-assistant:3003/');
|
||||||
|
$responseHeaders = [];
|
||||||
|
$query = json_encode(['prompt' => $query]);
|
||||||
|
$headers = ['accept: text/event-stream'];
|
||||||
|
$handleEvent = function ($ch, $data) use ($response) {
|
||||||
|
$response->chunk($data);
|
||||||
|
|
||||||
|
return \strlen($data);
|
||||||
|
};
|
||||||
|
|
||||||
|
curl_setopt($ch, CURLOPT_WRITEFUNCTION, $handleEvent);
|
||||||
|
|
||||||
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
||||||
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 9000);
|
||||||
|
curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$responseHeaders) {
|
||||||
|
$len = strlen($header);
|
||||||
|
$header = explode(':', $header, 2);
|
||||||
|
|
||||||
|
if (count($header) < 2) { // ignore invalid headers
|
||||||
|
return $len;
|
||||||
|
}
|
||||||
|
|
||||||
|
$responseHeaders[strtolower(trim($header[0]))] = trim($header[1]);
|
||||||
|
|
||||||
|
return $len;
|
||||||
|
});
|
||||||
|
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
|
||||||
|
|
||||||
|
curl_exec($ch);
|
||||||
|
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
$response->chunk('', true);
|
||||||
|
});
|
||||||
|
|
|
@ -28,7 +28,7 @@ $parseLabel = function (string $label, array $responsePayload, array $requestPar
|
||||||
$parts = explode('.', $match);
|
$parts = explode('.', $match);
|
||||||
|
|
||||||
if (count($parts) !== 2) {
|
if (count($parts) !== 2) {
|
||||||
throw new Exception('Too less or too many parts', 400, Exception::GENERAL_ARGUMENT_INVALID);
|
throw new Exception(Exception::GENERAL_SERVER_ERROR, "The server encountered an error while parsing the label: $label. Please create an issue on GitHub to allow us to investigate further https://github.com/appwrite/appwrite/issues/new/choose");
|
||||||
}
|
}
|
||||||
|
|
||||||
$namespace = $parts[0] ?? '';
|
$namespace = $parts[0] ?? '';
|
||||||
|
|
|
@ -660,6 +660,15 @@ services:
|
||||||
- _APP_REDIS_USER
|
- _APP_REDIS_USER
|
||||||
- _APP_REDIS_PASS
|
- _APP_REDIS_PASS
|
||||||
|
|
||||||
|
appwrite-assistant:
|
||||||
|
container_name: appwrite-assistant
|
||||||
|
image: appwrite/assistant:0.1.0
|
||||||
|
networks:
|
||||||
|
- appwrite
|
||||||
|
environment:
|
||||||
|
- OPENAI_API_KEY
|
||||||
|
|
||||||
|
|
||||||
mariadb:
|
mariadb:
|
||||||
image: mariadb:10.7 # fix issues when upgrading using: mysql_upgrade -u root -p
|
image: mariadb:10.7 # fix issues when upgrading using: mysql_upgrade -u root -p
|
||||||
container_name: appwrite-mariadb
|
container_name: appwrite-mariadb
|
||||||
|
|
Loading…
Reference in a new issue