mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-25 19:07:25 +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.
49 lines
1.2 KiB
PHP
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);
|
|
}
|
|
}
|