mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-24 19:07:20 +03:00
Added a formal object type to carry across vector search results. Added permission application and entity combining with vector search results. Also updated namespace from vectors to queries.
39 lines
894 B
PHP
39 lines
894 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace BookStack\Search\Queries;
|
|
|
|
use BookStack\Http\HttpRequestService;
|
|
use BookStack\Search\Queries\Services\OpenAiVectorQueryService;
|
|
use BookStack\Search\Queries\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());
|
|
}
|
|
}
|