Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better config #25

Closed
wants to merge 1 commit into from
Closed
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: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": ">=8.2",
"php-llm/llm-chain": "^0.2",
"php-llm/llm-chain": "^0.3",
"symfony/config": "^6.4 || ^7.0",
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/framework-bundle": "^6.4 || ^7.0"
Expand Down
37 changes: 27 additions & 10 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,36 @@ public function getConfigTreeBuilder(): TreeBuilder
->end()
->end()
->end()
->arrayNode('stores')
->normalizeKeys(false)
->useAttributeAsKey('name')
->arrayPrototype()
->arrayNode('stores')
->children()
->arrayNode('chroma_db')
->children()
->scalarNode('engine')->defaultValue('chroma-db')->end()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could drop the engine key now, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or the best with config component 😄 feel free to test my PR or finish it 😊

->scalarNode('collection_name')->isRequired()->end()
->end()
->end()
->arrayNode('azure_search')
->children()
->enumNode('engine')->values(['chroma-db', 'azure-search'])->isRequired()->end()
->scalarNode('collection_name')->end()
->scalarNode('api_key')->end()
->scalarNode('endpoint')->end()
->scalarNode('index_name')->end()
->scalarNode('api_version')->end()
->scalarNode('engine')->defaultValue('azure-search')->end()
->scalarNode('api_key')->isRequired()->end()
->scalarNode('endpoint')->isRequired()->end()
->scalarNode('index_name')->isRequired()->end()
->scalarNode('api_version')->defaultValue('2024-07-01')->end()
->scalarNode('vector_field_name')->defaultValue('vector')->end()
->end()
->end()
// ->arrayNode('mongodb')
// ->children()
// ->scalarNode('engine')->defaultValue('mongodb')->end()
// ->scalarNode('uri')->isRequired()->end()
// ->scalarNode('database_name')->isRequired()->end()
// ->scalarNode('collection_name')->isRequired()->end()
// ->scalarNode('index_name')->end()
// ->scalarNode('vector_field_name')->defaultValue('vector')->end()
// ->booleanNode('bulk_write')->defaultFalse()->end()
// ->end()
Comment on lines +60 to +77
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much more maintainable to me

// ->end()
->end()
->end()
;

Expand Down
3 changes: 2 additions & 1 deletion src/DependencyInjection/LlmChainExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ private function processStoreConfig(string $name, array $stores, ContainerBuilde
->replaceArgument('$endpointUrl', $stores['endpoint'])
->replaceArgument('$apiKey', $stores['api_key'])
->replaceArgument('$indexName', $stores['index_name'])
->replaceArgument('$apiVersion', $stores['api_version']);
->replaceArgument('$apiVersion', $stores['api_version'])
->replaceArgument('$vectorFieldName', $stores['vector_field_name']);

$container->setDefinition('llm_chain.store.'.$name, $definition);
}
Expand Down
Loading