Skip to content

Commit

Permalink
feat: default with a dsn
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienbrault committed May 31, 2024
1 parent 0de7fe2 commit af28ab2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Configure api keys:
```yaml
# config/packages/instructrice.yaml
instructrice:
default:
dsn: '%env(string:INSTRUCTRICE_DSN)%'
anthropic:
api_key: '%env(string:default::ANTHROPIC_API_KEY)%'
anyscale:
Expand Down
5 changes: 5 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public function getConfigTreeBuilder(): TreeBuilder

$rootNode
->children()
->arrayNode('default')
->children()
->scalarNode('dsn')->end()
->end()
->end()
->arrayNode('anthropic')
->children()
->scalarNode('api_key')->end()
Expand Down
8 changes: 7 additions & 1 deletion src/DependencyInjection/InstructriceExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class InstructriceExtension extends ConfigurableExtension
{
/**
* @param array{
* default?: array{
* dsn?: string
* },
* anthropic?: array{
* api_key?: string
* },
Expand Down Expand Up @@ -59,7 +62,7 @@ class InstructriceExtension extends ConfigurableExtension
* },
* together?: array{
* api_key?: string
* },
* }
* } $mergedConfig
*/
protected function loadInternal(array $mergedConfig, ContainerBuilder $container): void
Expand All @@ -78,12 +81,15 @@ protected function loadInternal(array $mergedConfig, ContainerBuilder $container
Together::class => $mergedConfig['together']['api_key'] ?? null,
];

$defaultDsn = $mergedConfig['default']['dsn'] ?? null;

$definition = $container->register(Instructrice::class);
$definition->setFactory(InstructriceFactory::class . '::create');
$definition->setArguments([
'$llmFactory' => new Reference(LLMFactory::class),
'$serializer' => new Reference('serializer'),
'$propertyInfo' => new Reference('property_info'),
'$defaultLlm' => $defaultDsn,
]);

$definition = $container->register(SymfonyStreamingClient::class);
Expand Down

0 comments on commit af28ab2

Please sign in to comment.