Skip to content

Commit e3e2c25

Browse files
GuikingoneOskarStark
authored andcommitted
[AI Bundle] Improvements on configuration / tags
1 parent ff85234 commit e3e2c25

File tree

4 files changed

+1444
-380
lines changed

4 files changed

+1444
-380
lines changed

src/ai-bundle/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"phpstan/phpstan": "^2.1",
3838
"phpstan/phpstan-strict-rules": "^2.0",
3939
"phpunit/phpunit": "^11.5",
40+
"probots-io/pinecone-php": "^1.0",
4041
"symfony/expression-language": "^7.3|^8.0",
4142
"symfony/security-core": "^7.3|^8.0",
4243
"symfony/translation": "^7.3|^8.0"

src/ai-bundle/config/options.php

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@
669669
->stringNode('database')->isRequired()->end()
670670
->stringNode('collection')->isRequired()->end()
671671
->stringNode('index_name')->isRequired()->end()
672-
->stringNode('vector_field')->end()
672+
->stringNode('vector_field')->isRequired()->end()
673673
->booleanNode('bulk_write')->end()
674674
->end()
675675
->end()
@@ -684,9 +684,9 @@
684684
->stringNode('database')->cannotBeEmpty()->end()
685685
->stringNode('vector_index_name')->cannotBeEmpty()->end()
686686
->stringNode('node_name')->cannotBeEmpty()->end()
687-
->stringNode('vector_field')->end()
688-
->integerNode('dimensions')->end()
689-
->stringNode('distance')->end()
687+
->stringNode('vector_field')->isRequired()->end()
688+
->integerNode('dimensions')->isRequired()->end()
689+
->stringNode('distance')->isRequired()->end()
690690
->booleanNode('quantization')->end()
691691
->end()
692692
->end()
@@ -701,21 +701,49 @@
701701
->end()
702702
->stringNode('namespace')->end()
703703
->arrayNode('filter')
704-
->scalarPrototype()->end()
704+
->scalarPrototype()
705+
->defaultValue([])
706+
->end()
705707
->end()
706708
->integerNode('top_k')->end()
707709
->end()
708710
->end()
709711
->end()
712+
->arrayNode('postgres')
713+
->useAttributeAsKey('name')
714+
->arrayPrototype()
715+
->children()
716+
->stringNode('dsn')->cannotBeEmpty()->end()
717+
->stringNode('username')->end()
718+
->stringNode('password')->end()
719+
->stringNode('table_name')->isRequired()->end()
720+
->stringNode('vector_field')->isRequired()->end()
721+
->enumNode('distance')
722+
->info('Distance metric to use for vector similarity search')
723+
->enumFqcn(PostgresDistance::class)
724+
->defaultValue(PostgresDistance::L2)
725+
->end()
726+
->stringNode('dbal_connection')->cannotBeEmpty()->end()
727+
->end()
728+
->validate()
729+
->ifTrue(static fn (array $v): bool => !isset($v['dsn']) && !isset($v['dbal_connection']))
730+
->thenInvalid('Either "dsn" or "dbal_connection" must be configured.')
731+
->end()
732+
->validate()
733+
->ifTrue(static fn (array $v): bool => isset($v['dsn'], $v['dbal_connection']))
734+
->thenInvalid('Either "dsn" or "dbal_connection" can be configured, but not both.')
735+
->end()
736+
->end()
737+
->end()
710738
->arrayNode('qdrant')
711739
->useAttributeAsKey('name')
712740
->arrayPrototype()
713741
->children()
714742
->stringNode('endpoint')->cannotBeEmpty()->end()
715743
->stringNode('api_key')->cannotBeEmpty()->end()
716744
->stringNode('collection_name')->cannotBeEmpty()->end()
717-
->integerNode('dimensions')->end()
718-
->stringNode('distance')->end()
745+
->integerNode('dimensions')->isRequired()->end()
746+
->stringNode('distance')->isRequired()->end()
719747
->booleanNode('async')->end()
720748
->end()
721749
->end()
@@ -741,32 +769,15 @@
741769
->end()
742770
->end()
743771
->validate()
744-
->ifTrue(static fn ($v) => !isset($v['connection_parameters']) && !isset($v['client']))
772+
->ifTrue(static fn (array $v): bool => !isset($v['connection_parameters']) && !isset($v['client']))
745773
->thenInvalid('Either "connection_parameters" or "client" must be configured.')
746774
->end()
747775
->validate()
748-
->ifTrue(static fn ($v) => isset($v['connection_parameters']) && isset($v['client']))
776+
->ifTrue(static fn (array $v): bool => isset($v['connection_parameters']) && isset($v['client']))
749777
->thenInvalid('Either "connection_parameters" or "client" can be configured, but not both.')
750778
->end()
751779
->end()
752780
->end()
753-
->arrayNode('surreal_db')
754-
->useAttributeAsKey('name')
755-
->arrayPrototype()
756-
->children()
757-
->stringNode('endpoint')->cannotBeEmpty()->end()
758-
->stringNode('username')->cannotBeEmpty()->end()
759-
->stringNode('password')->cannotBeEmpty()->end()
760-
->stringNode('namespace')->cannotBeEmpty()->end()
761-
->stringNode('database')->cannotBeEmpty()->end()
762-
->stringNode('table')->end()
763-
->stringNode('vector_field')->end()
764-
->stringNode('strategy')->end()
765-
->integerNode('dimensions')->end()
766-
->booleanNode('namespaced_user')->end()
767-
->end()
768-
->end()
769-
->end()
770781
->arrayNode('supabase')
771782
->useAttributeAsKey('name')
772783
->arrayPrototype()
@@ -785,51 +796,42 @@
785796
->end()
786797
->end()
787798
->end()
788-
->arrayNode('typesense')
799+
->arrayNode('surrealdb')
789800
->useAttributeAsKey('name')
790801
->arrayPrototype()
791802
->children()
792803
->stringNode('endpoint')->cannotBeEmpty()->end()
793-
->stringNode('api_key')->isRequired()->end()
794-
->stringNode('collection')->isRequired()->end()
795-
->stringNode('vector_field')->end()
796-
->integerNode('dimensions')->end()
804+
->stringNode('username')->cannotBeEmpty()->end()
805+
->stringNode('password')->cannotBeEmpty()->end()
806+
->stringNode('namespace')->cannotBeEmpty()->end()
807+
->stringNode('database')->cannotBeEmpty()->end()
808+
->stringNode('table')->isRequired()->end()
809+
->stringNode('vector_field')->isRequired()->end()
810+
->stringNode('strategy')->isRequired()->end()
811+
->integerNode('dimensions')->isRequired()->end()
812+
->booleanNode('namespaced_user')->end()
797813
->end()
798814
->end()
799815
->end()
800-
->arrayNode('weaviate')
816+
->arrayNode('typesense')
801817
->useAttributeAsKey('name')
802818
->arrayPrototype()
803819
->children()
804820
->stringNode('endpoint')->cannotBeEmpty()->end()
805821
->stringNode('api_key')->isRequired()->end()
806822
->stringNode('collection')->isRequired()->end()
823+
->stringNode('vector_field')->isRequired()->end()
824+
->integerNode('dimensions')->isRequired()->end()
807825
->end()
808826
->end()
809827
->end()
810-
->arrayNode('postgres')
828+
->arrayNode('weaviate')
811829
->useAttributeAsKey('name')
812830
->arrayPrototype()
813831
->children()
814-
->stringNode('dsn')->cannotBeEmpty()->end()
815-
->stringNode('username')->end()
816-
->stringNode('password')->end()
817-
->stringNode('table_name')->isRequired()->end()
818-
->stringNode('vector_field')->end()
819-
->enumNode('distance')
820-
->info('Distance metric to use for vector similarity search')
821-
->enumFqcn(PostgresDistance::class)
822-
->defaultValue(PostgresDistance::L2)
823-
->end()
824-
->stringNode('dbal_connection')->cannotBeEmpty()->end()
825-
->end()
826-
->validate()
827-
->ifTrue(static fn (array $v): bool => !isset($v['dsn']) && !isset($v['dbal_connection']))
828-
->thenInvalid('Either "dsn" or "dbal_connection" must be configured.')
829-
->end()
830-
->validate()
831-
->ifTrue(static fn (array $v): bool => isset($v['dsn'], $v['dbal_connection']))
832-
->thenInvalid('Either "dsn" or "dbal_connection" can be configured, but not both.')
832+
->stringNode('endpoint')->cannotBeEmpty()->end()
833+
->stringNode('api_key')->isRequired()->end()
834+
->stringNode('collection')->isRequired()->end()
833835
->end()
834836
->end()
835837
->end()
@@ -951,7 +953,7 @@
951953
->end()
952954
->end()
953955
->end()
954-
->arrayNode('surreal_db')
956+
->arrayNode('surrealdb')
955957
->useAttributeAsKey('name')
956958
->arrayPrototype()
957959
->children()

0 commit comments

Comments
 (0)