Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.
Merged
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
20 changes: 10 additions & 10 deletions src/DependencyInjection/LlmChainExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,28 +213,28 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
// MODEL
['name' => $modelName, 'version' => $version, 'options' => $options] = $config['model'];

$llmClass = match (strtolower((string) $modelName)) {
$modelClass = match (strtolower((string) $modelName)) {
'gpt' => GPT::class,
'claude' => Claude::class,
'llama' => Llama::class,
'gemini' => Gemini::class,
default => throw new \InvalidArgumentException(sprintf('Model "%s" is not supported.', $modelName)),
};
$llmDefinition = new Definition($llmClass);
$modelDefinition = new Definition($modelClass);
if (null !== $version) {
$llmDefinition->setArgument('$name', $version);
$modelDefinition->setArgument('$name', $version);
}
if (0 !== count($options)) {
$llmDefinition->setArgument('$options', $options);
$modelDefinition->setArgument('$options', $options);
}
$llmDefinition->addTag('llm_chain.model.language_model');
$container->setDefinition('llm_chain.chain.'.$name.'.llm', $llmDefinition);
$modelDefinition->addTag('llm_chain.model.language_model');
$container->setDefinition('llm_chain.chain.'.$name.'.model', $modelDefinition);

// CHAIN
$chainDefinition = (new Definition(Chain::class))
->setAutowired(true)
->setArgument('$platform', new Reference($config['platform']))
->setArgument('$llm', new Reference('llm_chain.chain.'.$name.'.llm'));
->setArgument('$model', new Reference('llm_chain.chain.'.$name.'.model'));

$inputProcessors = [];
$outputProcessors = [];
Expand Down Expand Up @@ -266,7 +266,7 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
}

$toolboxDefinition = (new ChildDefinition('llm_chain.toolbox.abstract'))
->replaceArgument('$metadataFactory', new Reference('llm_chain.toolbox.'.$name.'.chain_factory'))
->replaceArgument('$toolFactory', new Reference('llm_chain.toolbox.'.$name.'.chain_factory'))
->replaceArgument('$tools', $tools);
$container->setDefinition('llm_chain.toolbox.'.$name, $toolboxDefinition);

Expand Down Expand Up @@ -436,10 +436,10 @@ private function processEmbedderConfig(int|string $name, array $config, Containe
$modelDefinition->setArgument('$options', $options);
}
$modelDefinition->addTag('llm_chain.model.embeddings_model');
$container->setDefinition('llm_chain.embedder.'.$name.'.embeddings', $modelDefinition);
$container->setDefinition('llm_chain.embedder.'.$name.'.model', $modelDefinition);

$definition = new Definition(Embedder::class, [
'$embeddings' => new Reference('llm_chain.embedder.'.$name.'.embeddings'),
'$model' => new Reference('llm_chain.embedder.'.$name.'.model'),
'$platform' => new Reference($config['platform']),
'$store' => new Reference($config['store']),
]);
Expand Down
3 changes: 1 addition & 2 deletions src/Profiler/TraceablePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use PhpLlm\LlmChain\Platform\Message\Content\File;
use PhpLlm\LlmChain\Platform\Model;
use PhpLlm\LlmChain\Platform\PlatformInterface;
use PhpLlm\LlmChain\Platform\Response\AsyncResponse;
use PhpLlm\LlmChain\Platform\Response\ResponseInterface;

/**
Expand Down Expand Up @@ -42,7 +41,7 @@ public function request(Model $model, array|string|object $input, array $options
'model' => $model,
'input' => is_object($input) ? clone $input : $input,
'options' => $options,
'response' => $response instanceof AsyncResponse ? $response->unwrap() : $response,
'response' => $response->getContent(),
];

return $response;
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
->autowire()
->abstract()
->args([
'$metadataFactory' => service(ToolFactoryInterface::class),
'$toolFactory' => service(ToolFactoryInterface::class),
'$tools' => abstract_arg('Collection of tools'),
])
->set(Toolbox::class)
Expand Down
10 changes: 5 additions & 5 deletions src/Resources/views/data_collector.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,16 @@
<tr>
<th>Response</th>
<td>
{% if call.input.messages is defined and call.response.content is iterable %}{# expect array of ToolCall #}
{{ _self.tool_calls(call.response.content) }}
{% elseif call.response.content is iterable %}{# expect array of Vectors #}
{% if call.input.messages is defined and call.response is iterable %}{# expect array of ToolCall #}
{{ _self.tool_calls(call.response) }}
{% elseif call.response is iterable %}{# expect array of Vectors #}
<ol>
{% for vector in call.response.content %}
{% for vector in call.response %}
<li>Vector with <strong>{{ vector.dimensions }}</strong> dimensions</li>
{% endfor %}
</ol>
{% else %}
{{ call.response.content }}
{{ call.response }}
{% endif %}
</td>
</tr>
Expand Down