|
28 | 28 | use PhpLlm\LlmChain\Platform\Bridge\OpenAI\Embeddings;
|
29 | 29 | use PhpLlm\LlmChain\Platform\Bridge\OpenAI\GPT;
|
30 | 30 | use PhpLlm\LlmChain\Platform\Bridge\OpenAI\PlatformFactory as OpenAIPlatformFactory;
|
| 31 | +use PhpLlm\LlmChain\Platform\Bridge\OpenRouter\PlatformFactory as OpenRouterPlatformFactory; |
31 | 32 | use PhpLlm\LlmChain\Platform\Bridge\Voyage\Voyage;
|
| 33 | +use PhpLlm\LlmChain\Platform\Model; |
32 | 34 | use PhpLlm\LlmChain\Platform\ModelClientInterface;
|
33 | 35 | use PhpLlm\LlmChain\Platform\Platform;
|
34 | 36 | use PhpLlm\LlmChain\Platform\PlatformInterface;
|
@@ -204,6 +206,21 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
|
204 | 206 | return;
|
205 | 207 | }
|
206 | 208 |
|
| 209 | + if ('openrouter' === $type) { |
| 210 | + $platformId = 'llm_chain.platform.openrouter'; |
| 211 | + $definition = (new Definition(Platform::class)) |
| 212 | + ->setFactory(OpenRouterPlatformFactory::class.'::create') |
| 213 | + ->setAutowired(true) |
| 214 | + ->setLazy(true) |
| 215 | + ->addTag('proxy', ['interface' => PlatformInterface::class]) |
| 216 | + ->setArguments(['$apiKey' => $platform['api_key']]) |
| 217 | + ->addTag('llm_chain.platform'); |
| 218 | + |
| 219 | + $container->setDefinition($platformId, $definition); |
| 220 | + |
| 221 | + return; |
| 222 | + } |
| 223 | + |
207 | 224 | if ('mistral' === $type) {
|
208 | 225 | $platformId = 'llm_chain.platform.mistral';
|
209 | 226 | $definition = (new Definition(Platform::class))
|
@@ -236,6 +253,7 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
|
236 | 253 | 'llama' => Llama::class,
|
237 | 254 | 'gemini' => Gemini::class,
|
238 | 255 | 'mistral' => Mistral::class,
|
| 256 | + 'openrouter' => Model::class, |
239 | 257 | default => throw new \InvalidArgumentException(sprintf('Model "%s" is not supported.', $modelName)),
|
240 | 258 | };
|
241 | 259 | $modelDefinition = new Definition($modelClass);
|
|
0 commit comments