mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-27 07:57:52 +03:00
Vectors: Built content vector indexing system
This commit is contained in:
38
app/Search/Vectors/VectorQueryServiceProvider.php
Normal file
38
app/Search/Vectors/VectorQueryServiceProvider.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user