0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-04-22 11:52:30 +00:00
BookStackApp_BookStack/app/Search/Vectors/VectorQueryServiceProvider.php
Dan Brown a023bed41d
Vectors: Added command to regenerate for all
Also made models configurable.
Tested system scales via 86k vector entries.
2025-03-25 19:38:32 +00:00

36 lines
868 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') {
return new OpenAiVectorQueryService(config('services.openai'), $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());
}
}