mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-26 19:07:41 +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.
27 lines
698 B
PHP
27 lines
698 B
PHP
<?php
|
|
|
|
namespace BookStack\Search\Queries;
|
|
|
|
use Exception;
|
|
|
|
class LlmQueryRunner
|
|
{
|
|
public function __construct(
|
|
protected VectorQueryServiceProvider $vectorQueryServiceProvider,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Run a query against the configured LLM to produce a text response.
|
|
* @param VectorSearchResult[] $vectorResults
|
|
* @throws Exception
|
|
*/
|
|
public function run(string $query, array $vectorResults): string
|
|
{
|
|
$queryService = $this->vectorQueryServiceProvider->get();
|
|
|
|
$matchesText = array_values(array_map(fn (VectorSearchResult $result) => $result->matchText, $vectorResults));
|
|
return $queryService->query($query, $matchesText);
|
|
}
|
|
}
|