3 namespace BookStack\Search\Vectors;
5 use BookStack\Http\HttpRequestService;
6 use BookStack\Search\Vectors\Services\OpenAiVectorQueryService;
7 use BookStack\Search\Vectors\Services\VectorQueryService;
9 class VectorQueryServiceProvider
11 public function __construct(
12 protected HttpRequestService $http,
16 public function get(): VectorQueryService
18 $service = $this->getServiceName();
20 if ($service === 'openai') {
21 return new OpenAiVectorQueryService(config('services.openai'), $this->http);
24 throw new \Exception("No '{$service}' LLM service found");
27 protected static function getServiceName(): string
29 return strtolower(config('services.llm'));
32 public static function isEnabled(): bool
34 return !empty(static::getServiceName());