初始化仓库及v1.0.0提交
This commit is contained in:
26
app/Services/AIService.php
Normal file
26
app/Services/AIService.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Services\Providers\OpenAIProvider;
|
||||
use App\Services\Providers\ClaudeProvider;
|
||||
use App\Services\Providers\NewAPIProvider;
|
||||
|
||||
class AIService
|
||||
{
|
||||
public static function streamChat(string $providerName, string $model, array $messages, array $options, callable $onChunk): void
|
||||
{
|
||||
$provider = self::getProvider($providerName);
|
||||
$provider::stream($model, $messages, $options, $onChunk);
|
||||
}
|
||||
|
||||
public static function getProvider(string $name): string
|
||||
{
|
||||
return match ($name) {
|
||||
'openai' => OpenAIProvider::class,
|
||||
'claude' => ClaudeProvider::class,
|
||||
'newapi' => NewAPIProvider::class,
|
||||
default => throw new \RuntimeException('不支持的供应商: ' . $name)
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user