Files
BookStack/app/Search/Queries/QueryController.php
Dan Brown 88ccd9e5b9 Vectors: Split out vector search and llm query runs
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.
2025-08-21 12:14:52 +01:00

49 lines
1.2 KiB
PHP

<?php
namespace BookStack\Search\Queries;
use BookStack\Http\Controller;
use BookStack\Search\SearchOptions;
use BookStack\Search\SearchRunner;
use Illuminate\Http\Request;
class QueryController extends Controller
{
public function __construct(
protected SearchRunner $searchRunner,
) {
}
/**
* Show the view to start a vector/LLM-based query search.
*/
public function show(Request $request)
{
// TODO - Validate if query system is active
$query = $request->get('ask', '');
// TODO - Placeholder
$entities = $this->searchRunner->searchEntities(SearchOptions::fromString("cat"), 'all', 1, 20)['results'];
// TODO - Set page title
return view('search.query', [
'query' => $query,
'entities' => $entities,
]);
}
/**
* Perform a vector/LLM-based query search.
*/
public function run(Request $request, VectorSearchRunner $searchRunner, LlmQueryRunner $llmRunner)
{
// TODO - Validate if query system is active
$query = $request->get('query', '');
$results = $query ? $searchRunner->run($query) : [];
$llmResult = $llmRunner->run($query, $results);
dd($results, $llmResult);
}
}