Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ai-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
"symfony/string": "^7.3|^8.0"
},
"require-dev": {
"codewithkyrian/chromadb-php": "^0.2.1 || ^0.3 || ^0.4",
"google/auth": "^1.47",
"mongodb/mongodb": "^1.21 || ^2.0",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^11.5",
"probots-io/pinecone-php": "^1.0",
"symfony/expression-language": "^7.3|^8.0",
"symfony/security-core": "^7.3|^8.0",
"symfony/translation": "^7.3|^8.0"
Expand Down
169 changes: 87 additions & 82 deletions src/ai-bundle/config/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@
->treatNullLike(['enabled' => true])
->beforeNormalization()
->ifArray()
->then(function (array $v) {
->then(function (array $v): array {
return [
'enabled' => $v['enabled'] ?? true,
'services' => $v['services'] ?? $v,
Expand Down Expand Up @@ -564,7 +564,7 @@
->stringNode('table')->isRequired()->cannotBeEmpty()->end()
->end()
->validate()
->ifTrue(static fn ($v) => !isset($v['dsn']) && !isset($v['http_client']))
->ifTrue(static fn ($v): bool => !isset($v['dsn']) && !isset($v['http_client']))
->thenInvalid('Either "dsn" or "http_client" must be configured.')
->end()
->end()
Expand All @@ -576,8 +576,11 @@
->stringNode('account_id')->cannotBeEmpty()->end()
->stringNode('api_key')->cannotBeEmpty()->end()
->stringNode('index_name')->cannotBeEmpty()->end()
->integerNode('dimensions')->end()
->stringNode('metric')->end()
->integerNode('dimensions')->isRequired()->end()
->stringNode('metric')
->cannotBeEmpty()
->defaultValue('cosine')
->end()
->stringNode('endpoint_url')->end()
->end()
->end()
Expand All @@ -588,24 +591,40 @@
->children()
->stringNode('endpoint')->cannotBeEmpty()->end()
->stringNode('table')->cannotBeEmpty()->end()
->stringNode('field')->end()
->stringNode('type')->end()
->stringNode('similarity')->end()
->integerNode('dimensions')->end()
->stringNode('field')->cannotBeEmpty()->end()
->stringNode('type')->cannotBeEmpty()->end()
->stringNode('similarity')->cannotBeEmpty()->end()
->integerNode('dimensions')->isRequired()->end()
->stringNode('quantization')->end()
->end()
->end()
->end()
->arrayNode('mariadb')
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->stringNode('connection')->cannotBeEmpty()->end()
->stringNode('table_name')->cannotBeEmpty()->end()
->stringNode('index_name')->cannotBeEmpty()->end()
->stringNode('vector_field_name')->cannotBeEmpty()->end()
->arrayNode('setup_options')
->children()
->integerNode('dimensions')->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('meilisearch')
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->stringNode('endpoint')->cannotBeEmpty()->end()
->stringNode('api_key')->cannotBeEmpty()->end()
->stringNode('index_name')->cannotBeEmpty()->end()
->stringNode('embedder')->end()
->stringNode('vector_field')->end()
->integerNode('dimensions')->end()
->stringNode('embedder')->cannotBeEmpty()->end()
->stringNode('vector_field')->cannotBeEmpty()->end()
->integerNode('dimensions')->isRequired()->end()
->floatNode('semantic_ratio')
->info('The ratio between semantic (vector) and full-text search (0.0 to 1.0). Default: 1.0 (100% semantic)')
->defaultValue(1.0)
Expand All @@ -623,22 +642,6 @@
->end()
->end()
->end()
->arrayNode('mariadb')
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->stringNode('connection')->cannotBeEmpty()->end()
->stringNode('table_name')->cannotBeEmpty()->end()
->stringNode('index_name')->cannotBeEmpty()->end()
->stringNode('vector_field_name')->cannotBeEmpty()->end()
->arrayNode('setup_options')
->children()
->integerNode('dimensions')->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('milvus')
->useAttributeAsKey('name')
->arrayPrototype()
Expand All @@ -647,8 +650,8 @@
->stringNode('api_key')->isRequired()->end()
->stringNode('database')->isRequired()->end()
->stringNode('collection')->isRequired()->end()
->stringNode('vector_field')->end()
->integerNode('dimensions')->end()
->stringNode('vector_field')->isRequired()->end()
->integerNode('dimensions')->isRequired()->end()
->stringNode('metric_type')->end()
->end()
->end()
Expand All @@ -664,7 +667,7 @@
->stringNode('database')->isRequired()->end()
->stringNode('collection')->isRequired()->end()
->stringNode('index_name')->isRequired()->end()
->stringNode('vector_field')->end()
->stringNode('vector_field')->isRequired()->end()
->booleanNode('bulk_write')->end()
->end()
->end()
Expand All @@ -679,9 +682,9 @@
->stringNode('database')->cannotBeEmpty()->end()
->stringNode('vector_index_name')->cannotBeEmpty()->end()
->stringNode('node_name')->cannotBeEmpty()->end()
->stringNode('vector_field')->end()
->integerNode('dimensions')->end()
->stringNode('distance')->end()
->stringNode('vector_field')->isRequired()->end()
->integerNode('dimensions')->isRequired()->end()
->stringNode('distance')->isRequired()->end()
->booleanNode('quantization')->end()
->end()
->end()
Expand All @@ -696,21 +699,49 @@
->end()
->stringNode('namespace')->end()
->arrayNode('filter')
->scalarPrototype()->end()
->scalarPrototype()
->defaultValue([])
->end()
->end()
->integerNode('top_k')->end()
->end()
->end()
->end()
->arrayNode('postgres')
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->stringNode('dsn')->cannotBeEmpty()->end()
->stringNode('username')->end()
->stringNode('password')->end()
->stringNode('table_name')->isRequired()->end()
->stringNode('vector_field')->isRequired()->end()
->enumNode('distance')
->info('Distance metric to use for vector similarity search')
->enumFqcn(PostgresDistance::class)
->defaultValue(PostgresDistance::L2)
->end()
->stringNode('dbal_connection')->cannotBeEmpty()->end()
->end()
->validate()
->ifTrue(static fn (array $v): bool => !isset($v['dsn']) && !isset($v['dbal_connection']))
->thenInvalid('Either "dsn" or "dbal_connection" must be configured.')
->end()
->validate()
->ifTrue(static fn (array $v): bool => isset($v['dsn'], $v['dbal_connection']))
->thenInvalid('Either "dsn" or "dbal_connection" can be configured, but not both.')
->end()
->end()
->end()
->arrayNode('qdrant')
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->stringNode('endpoint')->cannotBeEmpty()->end()
->stringNode('api_key')->cannotBeEmpty()->end()
->stringNode('collection_name')->cannotBeEmpty()->end()
->integerNode('dimensions')->end()
->stringNode('distance')->end()
->integerNode('dimensions')->isRequired()->end()
->stringNode('distance')->isRequired()->end()
->booleanNode('async')->end()
->end()
->end()
Expand All @@ -736,32 +767,15 @@
->end()
->end()
->validate()
->ifTrue(static fn ($v) => !isset($v['connection_parameters']) && !isset($v['client']))
->ifTrue(static fn (array $v): bool => !isset($v['connection_parameters']) && !isset($v['client']))
->thenInvalid('Either "connection_parameters" or "client" must be configured.')
->end()
->validate()
->ifTrue(static fn ($v) => isset($v['connection_parameters']) && isset($v['client']))
->ifTrue(static fn (array $v): bool => isset($v['connection_parameters']) && isset($v['client']))
->thenInvalid('Either "connection_parameters" or "client" can be configured, but not both.')
->end()
->end()
->end()
->arrayNode('surreal_db')
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->stringNode('endpoint')->cannotBeEmpty()->end()
->stringNode('username')->cannotBeEmpty()->end()
->stringNode('password')->cannotBeEmpty()->end()
->stringNode('namespace')->cannotBeEmpty()->end()
->stringNode('database')->cannotBeEmpty()->end()
->stringNode('table')->end()
->stringNode('vector_field')->end()
->stringNode('strategy')->end()
->integerNode('dimensions')->end()
->booleanNode('namespaced_user')->end()
->end()
->end()
->end()
->arrayNode('supabase')
->useAttributeAsKey('name')
->arrayPrototype()
Expand All @@ -780,51 +794,42 @@
->end()
->end()
->end()
->arrayNode('typesense')
->arrayNode('surrealdb')
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->stringNode('endpoint')->cannotBeEmpty()->end()
->stringNode('api_key')->isRequired()->end()
->stringNode('collection')->isRequired()->end()
->stringNode('vector_field')->end()
->integerNode('dimensions')->end()
->stringNode('username')->cannotBeEmpty()->end()
->stringNode('password')->cannotBeEmpty()->end()
->stringNode('namespace')->cannotBeEmpty()->end()
->stringNode('database')->cannotBeEmpty()->end()
->stringNode('table')->isRequired()->end()
->stringNode('vector_field')->isRequired()->end()
->stringNode('strategy')->isRequired()->end()
->integerNode('dimensions')->isRequired()->end()
->booleanNode('namespaced_user')->end()
->end()
->end()
->end()
->arrayNode('weaviate')
->arrayNode('typesense')
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->stringNode('endpoint')->cannotBeEmpty()->end()
->stringNode('api_key')->isRequired()->end()
->stringNode('collection')->isRequired()->end()
->stringNode('vector_field')->isRequired()->end()
->integerNode('dimensions')->isRequired()->end()
->end()
->end()
->end()
->arrayNode('postgres')
->arrayNode('weaviate')
->useAttributeAsKey('name')
->arrayPrototype()
->children()
->stringNode('dsn')->cannotBeEmpty()->end()
->stringNode('username')->end()
->stringNode('password')->end()
->stringNode('table_name')->isRequired()->end()
->stringNode('vector_field')->end()
->enumNode('distance')
->info('Distance metric to use for vector similarity search')
->enumFqcn(PostgresDistance::class)
->defaultValue(PostgresDistance::L2)
->end()
->stringNode('dbal_connection')->cannotBeEmpty()->end()
->end()
->validate()
->ifTrue(static fn ($v) => !isset($v['dsn']) && !isset($v['dbal_connection']))
->thenInvalid('Either "dsn" or "dbal_connection" must be configured.')
->end()
->validate()
->ifTrue(static fn ($v) => isset($v['dsn'], $v['dbal_connection']))
->thenInvalid('Either "dsn" or "dbal_connection" can be configured, but not both.')
->stringNode('endpoint')->cannotBeEmpty()->end()
->stringNode('api_key')->isRequired()->end()
->stringNode('collection')->isRequired()->end()
->end()
->end()
->end()
Expand Down Expand Up @@ -933,7 +938,7 @@
->end()
->end()
->end()
->arrayNode('surreal_db')
->arrayNode('surrealdb')
->useAttributeAsKey('name')
->arrayPrototype()
->children()
Expand Down
Loading