Skip to content

Commit aa17279

Browse files
committed
Fix Model class instantiation for proper platform support
- Add createModelForPlatform method to create appropriate model classes - Support OpenAI, Anthropic, Google, Ollama, and Mistral platforms - Use specific model classes instead of generic Model for proper capability detection - Fallback to generic Model for unknown platforms - This resolves the ModelClient registration error
1 parent 2c45a0c commit aa17279

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/ai-bundle/src/Command/PlatformInvokeCommand.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
105105
throw new InvalidArgumentException('Model is required.');
106106
}
107107

108-
$this->model = new Model($modelName);
108+
$this->model = $this->createModelForPlatform($platformName, $modelName);
109109

110110
$this->message = trim((string) $input->getArgument('message'));
111111

@@ -148,4 +148,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
148148
return Command::SUCCESS;
149149
}
150150

151+
private function createModelForPlatform(string $platformName, string $modelName): Model
152+
{
153+
return match ($platformName) {
154+
'openai' => new \Symfony\AI\Platform\Bridge\OpenAi\Gpt($modelName),
155+
'anthropic' => new \Symfony\AI\Platform\Bridge\Anthropic\Claude($modelName),
156+
'google' => new \Symfony\AI\Platform\Bridge\Gemini\Gemini($modelName),
157+
'ollama' => new \Symfony\AI\Platform\Bridge\Ollama\Ollama($modelName),
158+
'mistral' => new \Symfony\AI\Platform\Bridge\Mistral\Mistral($modelName),
159+
default => new Model($modelName), // Fallback to generic model
160+
};
161+
}
162+
151163
}

0 commit comments

Comments
 (0)