Skip to content

Commit

Permalink
Fix LLM Factory not getting APIKeys (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
baldurrensch authored Apr 25, 2024
1 parent 841dbf1 commit cbe8d73
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/DependencyInjection/InstructriceExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,24 @@ class InstructriceExtension extends ConfigurableExtension
*/
protected function loadInternal(array $mergedConfig, ContainerBuilder $container): void
{
$apiKeys = [
Anthropic::class => $mergedConfig['anthropic']['api_key'] ?? null,
Anyscale::class => $mergedConfig['anyscale']['api_key'] ?? null,
DeepInfra::class => $mergedConfig['deepinfra']['api_key'] ?? null,
Fireworks::class => $mergedConfig['fireworks']['api_key'] ?? null,
Groq::class => $mergedConfig['groq']['api_key'] ?? null,
Mistral::class => $mergedConfig['mistral']['api_key'] ?? null,
Ollama::class => $mergedConfig['ollama']['api_key'] ?? null,
OpenAi::class => $mergedConfig['openai']['api_key'] ?? null,
Perplexity::class => $mergedConfig['perplexity']['api_key'] ?? null,
Together::class => $mergedConfig['together']['api_key'] ?? null,
];

$definition = $container->register(Instructrice::class);
$definition->setFactory(InstructriceFactory::class . '::create');

$definition->setArguments([
'$apiKeys' => [
Anthropic::class => $mergedConfig['anthropic']['api_key'] ?? null,
Anyscale::class => $mergedConfig['anyscale']['api_key'] ?? null,
DeepInfra::class => $mergedConfig['deepinfra']['api_key'] ?? null,
Fireworks::class => $mergedConfig['fireworks']['api_key'] ?? null,
Groq::class => $mergedConfig['groq']['api_key'] ?? null,
Mistral::class => $mergedConfig['mistral']['api_key'] ?? null,
Ollama::class => $mergedConfig['ollama']['api_key'] ?? null,
OpenAi::class => $mergedConfig['openai']['api_key'] ?? null,
Perplexity::class => $mergedConfig['perplexity']['api_key'] ?? null,
Together::class => $mergedConfig['together']['api_key'] ?? null,
],
'$apiKeys' => $apiKeys,
'$llmFactory' => new Reference(LLMFactory::class),
'$serializer' => new Reference('serializer'),
'$propertyInfo' => new Reference('property_info'),
Expand All @@ -91,6 +93,7 @@ protected function loadInternal(array $mergedConfig, ContainerBuilder $container
$definition->setArguments([
'$client' => new Reference(SymfonyStreamingClient::class),
'$logger' => new Reference('logger'),
'$apiKeys' => $apiKeys,
]);

$container->setAlias('instructrice', Instructrice::class);
Expand Down

0 comments on commit cbe8d73

Please sign in to comment.