Repository navigation
Conversation
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
|
Thanks for this! The gap is real, but changing what the closure receives is a breaking change on Since adding fields to public function handle(Request $request): string
{
$results = $this->search($request);
// ...
}
protected function search(Request $request): mixed
{
return call_user_func($this->using, $request->string('query'));
}A subclass then reads its own arguments and still gets the normalization, reranking and output format from the parent: class DocsSearch extends SimilaritySearch
{
public function schema(JsonSchema $schema): array
{
return [
...parent::schema($schema),
'tags' => $schema->array()->items($schema->string())->required(),
];
}
protected function search(Request $request): mixed
{
return Doc::query()
->whereVectorSimilarTo('embedding', $request->string('query'))
->whereJsonContains('tags', $request->array('tags'))
->get();
}
}For the test, a subclass that overrides |
|
Thanks, done. The closure call is back to passing only the query, and it now lives in a protected |
SimilaritySearchonly gives its closure the query string. A subclass can add arguments toschema()(tags, a category, a result count), but nothing can read them, so the only way to use them today is to copyhandle()into the subclass. The copy then drifts from the package: the result normalization, the reranking, the empty-results message and the output format all have to be kept in sync by hand.This PR moves the closure call into a protected
search()method that subclasses can override. The closure still receives only the query string, so existing callables are unaffected: