Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 4bdf0e5

Browse files
committed
fix(embedder): Use FQCN for embedder model config, to allow any Model child class
1 parent 50c2bf3 commit 4bdf0e5

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function getConfigTreeBuilder(): TreeBuilder
197197
->end()
198198
->arrayNode('model')
199199
->children()
200-
->scalarNode('name')->isRequired()->end()
200+
->scalarNode('className')->isRequired()->end()
201201
->scalarNode('version')->defaultNull()->end()
202202
->arrayNode('options')
203203
->scalarPrototype()->end()

src/DependencyInjection/LlmChainExtension.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,13 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
457457
*/
458458
private function processEmbedderConfig(int|string $name, array $config, ContainerBuilder $container): void
459459
{
460-
['name' => $modelName, 'version' => $version, 'options' => $options] = $config['model'];
460+
['className' => $modelClassName, 'version' => $version, 'options' => $options] = $config['model'];
461461

462-
$modelClass = match (strtolower((string) $modelName)) {
463-
'embeddings' => Embeddings::class,
464-
'voyage' => Voyage::class,
465-
default => throw new \InvalidArgumentException(sprintf('Model "%s" is not supported.', $modelName)),
466-
};
467-
$modelDefinition = (new Definition($modelClass));
462+
if (!is_a($modelClassName, Model::class)) {
463+
throw new \InvalidArgumentException(sprintf('"%s" class is not extending PhpLlm\LlmChain\Platform\Model.', $modelClassName));
464+
}
465+
466+
$modelDefinition = (new Definition($modelClassName));
468467
if (null !== $version) {
469468
$modelDefinition->setArgument('$name', $version);
470469
}

0 commit comments

Comments
 (0)