First Commit

This commit is contained in:
marco
2026-09-01 09:22:30 -03:00
commit a43ae23eb4
407 changed files with 36138 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace App\Services\Ai;
use App\Models\AiProvider;
use InvalidArgumentException;
class AiServiceFactory
{
/**
* Create an AI service instance based on the provider.
*
* @param AiProvider|string $provider
* @return AiServiceInterface
*/
public static function make(AiProvider|string $provider): AiServiceInterface
{
if (is_string($provider)) {
$provider = AiProvider::withTrashed()->where('slug', $provider)
->firstOrFail();
}
if (!$provider->is_active) {
throw new InvalidArgumentException('AI provider is not active.');
}
return match ($provider->slug) {
'openrouter', 'openrouter-test' => new OpenRouterService($provider),
'stepfun' => new StepFunService($provider),
'llamacpp' => new LlamaCppService($provider),
default => throw new InvalidArgumentException("Unsupported AI provider: {$provider->slug}"),
};
}
}