1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-04-19 18:22:16 +03:00
bookstack/app/Search/Vectors/VectorQueryServiceProvider.php
2025-03-24 16:28:14 +00:00

39 lines
968 B
PHP

<?php
namespace BookStack\Search\Vectors;
use BookStack\Http\HttpRequestService;
use BookStack\Search\Vectors\Services\OpenAiVectorQueryService;
use BookStack\Search\Vectors\Services\VectorQueryService;
class VectorQueryServiceProvider
{
public function __construct(
protected HttpRequestService $http,
) {
}
public function get(): VectorQueryService
{
$service = $this->getServiceName();
if ($service === 'openai') {
$key = config('services.openai.key');
$endpoint = config('services.openai.endpoint');
return new OpenAiVectorQueryService($endpoint, $key, $this->http);
}
throw new \Exception("No '{$service}' LLM service found");
}
protected static function getServiceName(): string
{
return strtolower(config('services.llm'));
}
public static function isEnabled(): bool
{
return !empty(static::getServiceName());
}
}