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 $key = config('services.openai.key');
22 $endpoint = config('services.openai.endpoint');
23 return new OpenAiVectorQueryService($endpoint, $key, $this->http);
26 throw new \Exception("No '{$service}' LLM service found");
29 protected static function getServiceName(): string
31 return strtolower(config('services.llm'));
34 public static function isEnabled(): bool
36 return !empty(static::getServiceName());