Skip to content

Commit e83812e

Browse files
authored
fix: support for 0.22 (#86)
1 parent 6c48c4f commit e83812e

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

src/DependencyInjection/LlmChainExtension.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,28 +213,28 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
213213
// MODEL
214214
['name' => $modelName, 'version' => $version, 'options' => $options] = $config['model'];
215215

216-
$llmClass = match (strtolower((string) $modelName)) {
216+
$modelClass = match (strtolower((string) $modelName)) {
217217
'gpt' => GPT::class,
218218
'claude' => Claude::class,
219219
'llama' => Llama::class,
220220
'gemini' => Gemini::class,
221221
default => throw new \InvalidArgumentException(sprintf('Model "%s" is not supported.', $modelName)),
222222
};
223-
$llmDefinition = new Definition($llmClass);
223+
$modelDefinition = new Definition($modelClass);
224224
if (null !== $version) {
225-
$llmDefinition->setArgument('$name', $version);
225+
$modelDefinition->setArgument('$name', $version);
226226
}
227227
if (0 !== count($options)) {
228-
$llmDefinition->setArgument('$options', $options);
228+
$modelDefinition->setArgument('$options', $options);
229229
}
230-
$llmDefinition->addTag('llm_chain.model.language_model');
231-
$container->setDefinition('llm_chain.chain.'.$name.'.llm', $llmDefinition);
230+
$modelDefinition->addTag('llm_chain.model.language_model');
231+
$container->setDefinition('llm_chain.chain.'.$name.'.model', $modelDefinition);
232232

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

239239
$inputProcessors = [];
240240
$outputProcessors = [];
@@ -266,7 +266,7 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
266266
}
267267

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

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

441441
$definition = new Definition(Embedder::class, [
442-
'$embeddings' => new Reference('llm_chain.embedder.'.$name.'.embeddings'),
442+
'$model' => new Reference('llm_chain.embedder.'.$name.'.model'),
443443
'$platform' => new Reference($config['platform']),
444444
'$store' => new Reference($config['store']),
445445
]);

src/Profiler/TraceablePlatform.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PhpLlm\LlmChain\Platform\Message\Content\File;
88
use PhpLlm\LlmChain\Platform\Model;
99
use PhpLlm\LlmChain\Platform\PlatformInterface;
10-
use PhpLlm\LlmChain\Platform\Response\AsyncResponse;
1110
use PhpLlm\LlmChain\Platform\Response\ResponseInterface;
1211

1312
/**
@@ -42,7 +41,7 @@ public function request(Model $model, array|string|object $input, array $options
4241
'model' => $model,
4342
'input' => is_object($input) ? clone $input : $input,
4443
'options' => $options,
45-
'response' => $response instanceof AsyncResponse ? $response->unwrap() : $response,
44+
'response' => $response->getContent(),
4645
];
4746

4847
return $response;

src/Resources/config/services.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
->autowire()
3434
->abstract()
3535
->args([
36-
'$metadataFactory' => service(ToolFactoryInterface::class),
36+
'$toolFactory' => service(ToolFactoryInterface::class),
3737
'$tools' => abstract_arg('Collection of tools'),
3838
])
3939
->set(Toolbox::class)

src/Resources/views/data_collector.html.twig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,16 @@
153153
<tr>
154154
<th>Response</th>
155155
<td>
156-
{% if call.input.messages is defined and call.response.content is iterable %}{# expect array of ToolCall #}
157-
{{ _self.tool_calls(call.response.content) }}
158-
{% elseif call.response.content is iterable %}{# expect array of Vectors #}
156+
{% if call.input.messages is defined and call.response is iterable %}{# expect array of ToolCall #}
157+
{{ _self.tool_calls(call.response) }}
158+
{% elseif call.response is iterable %}{# expect array of Vectors #}
159159
<ol>
160-
{% for vector in call.response.content %}
160+
{% for vector in call.response %}
161161
<li>Vector with <strong>{{ vector.dimensions }}</strong> dimensions</li>
162162
{% endfor %}
163163
</ol>
164164
{% else %}
165-
{{ call.response.content }}
165+
{{ call.response }}
166166
{% endif %}
167167
</td>
168168
</tr>

0 commit comments

Comments
 (0)