mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
linting and fixing resources timeout and validator
This commit is contained in:
+17
-1
@@ -386,13 +386,29 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg
|
||||
});
|
||||
|
||||
$projectCollections = $collections['projects'];
|
||||
|
||||
$sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', ''));
|
||||
$sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', ''));
|
||||
$sharedTablesV2 = \array_diff($sharedTables, $sharedTablesV1);
|
||||
|
||||
$documentsSharedTables = \explode(',', System::getEnv('_APP_DATABASE_DOCUMENTSDB_SHARED_TABLES', ''));
|
||||
$documentsSharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_DOCUMENTSDB_SHARED_TABLES_V1', ''));
|
||||
$documentsSharedTablesV2 = \array_diff($documentsSharedTables, $documentsSharedTablesV1);
|
||||
|
||||
$vectorSharedTables = \explode(',', System::getEnv('_APP_DATABASE_VECTORDB_SHARED_TABLES', ''));
|
||||
$vectorSharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_VECTORDB_SHARED_TABLES_V1', ''));
|
||||
$vectorSharedTablesV2 = \array_diff($vectorSharedTables, $vectorSharedTablesV1);
|
||||
|
||||
$cache = $app->getResource('cache');
|
||||
|
||||
foreach ($sharedTablesV2 as $hostname) {
|
||||
// All shared tables V2 pools that need project metadata collections
|
||||
$sharedTablesV2All = \array_values(\array_unique(\array_filter([
|
||||
...$sharedTablesV2,
|
||||
...$documentsSharedTablesV2,
|
||||
...$vectorSharedTablesV2,
|
||||
])));
|
||||
|
||||
foreach ($sharedTablesV2All as $hostname) {
|
||||
$adapter = new DatabasePool($pools->get($hostname));
|
||||
$dbForProject = (new Database($adapter, $cache))
|
||||
->setDatabase('appwrite')
|
||||
|
||||
@@ -1541,7 +1541,7 @@ App::setResource('executionsRetentionCount', function (Document $project, array
|
||||
}, ['project', 'plan']);
|
||||
|
||||
App::setResource('embeddingAgent', function ($register) {
|
||||
$adapter = new Ollama();
|
||||
$adapter = new Ollama(150);
|
||||
$adapter->setEndpoint(System::getEnv('_APP_EMBEDDING_ENDPOINT', 'http://ollama:11434/api/embed'));
|
||||
return new Agent($adapter);
|
||||
}, ['register']);
|
||||
}, ['register']);
|
||||
|
||||
@@ -206,7 +206,6 @@ class Create extends Action
|
||||
$dbForDatabases->getAdapter()->getSupportForAttributes(),
|
||||
$dbForDatabases->getAdapter()->getSupportForMultipleFulltextIndexes(),
|
||||
$dbForDatabases->getAdapter()->getSupportForIdenticalIndexes(),
|
||||
$dbForDatabases->getAdapter()->getSupportForObject(),
|
||||
$dbForProject->getAdapter()->getSupportForObjectIndexes(),
|
||||
$dbForProject->getAdapter()->getSupportForTrigramIndex(),
|
||||
$dbForProject->getAdapter()->getSupportForSpatialAttributes(),
|
||||
|
||||
@@ -589,29 +589,31 @@ class DatabasesCustomServerTest extends Scope
|
||||
$collectionId = $col['body']['$id'];
|
||||
|
||||
// Success: two embeddings
|
||||
$ok = $this->client->call(Client::METHOD_POST, "/vectordb/embeddings/text", [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
], [
|
||||
'model' => 'embeddinggemma',
|
||||
'texts' => [
|
||||
'hello world',
|
||||
'second sentence',
|
||||
],
|
||||
]);
|
||||
$this->assertEquals(200, $ok['headers']['status-code']);
|
||||
$this->assertIsInt($ok['body']['total'] ?? 0);
|
||||
$this->assertEquals(2, $ok['body']['total']);
|
||||
$this->assertIsArray($ok['body']['embeddings']);
|
||||
$this->assertCount(2, $ok['body']['embeddings']);
|
||||
foreach ($ok['body']['embeddings'] as $embed) {
|
||||
$this->assertIsString($embed['model']);
|
||||
$this->assertIsInt($embed['dimension']);
|
||||
$this->assertIsArray($embed['embedding']);
|
||||
$this->assertGreaterThan(0, count($embed['embedding']));
|
||||
$this->assertArrayHasKey('error', $embed);
|
||||
}
|
||||
$this->assertEventually(function () {
|
||||
$ok = $this->client->call(Client::METHOD_POST, "/vectordb/embeddings/text", [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
], [
|
||||
'model' => 'embeddinggemma',
|
||||
'texts' => [
|
||||
'hello world',
|
||||
'second sentence',
|
||||
],
|
||||
]);
|
||||
$this->assertEquals(200, $ok['headers']['status-code']);
|
||||
$this->assertIsInt($ok['body']['total'] ?? 0);
|
||||
$this->assertEquals(2, $ok['body']['total']);
|
||||
$this->assertIsArray($ok['body']['embeddings']);
|
||||
$this->assertCount(2, $ok['body']['embeddings']);
|
||||
foreach ($ok['body']['embeddings'] as $embed) {
|
||||
$this->assertIsString($embed['model']);
|
||||
$this->assertIsInt($embed['dimension']);
|
||||
$this->assertIsArray($embed['embedding']);
|
||||
$this->assertGreaterThan(0, count($embed['embedding']));
|
||||
$this->assertArrayHasKey('error', $embed);
|
||||
}
|
||||
}, 3000, 100);
|
||||
|
||||
// Error: missing texts payload
|
||||
$missingTexts = $this->client->call(Client::METHOD_POST, "/vectordb/embeddings/text", [
|
||||
|
||||
Reference in New Issue
Block a user