Run

Run a Vectorsearch: search its Vectorstore with a query, and the Vectorsearch’s own configuration.

The one implementation of a run, which the REST api (DefaultVectorsearchApiView) and an LLMClient’s Vectorsearch tools (VectorsearchToolkit) both call, so that both refuse a disabled Vectorsearch, both respect the same budgets, and both return the same results.

smarter.apps.vectorsearch.run.combined_metadata_filter(vectorsearch, run_filter)[source]

Return the metadata that every result must match: the run’s, then the Vectorsearch’s own.

The Vectorsearch’s filter wins where both name the same key, so that a caller can narrow a Vectorsearch, but never widen it.

Parameters:
Return type:

dict[str, Any]

Returns:

The combined filter, which may be empty.

smarter.apps.vectorsearch.run.run_vectorsearch(vectorsearch, query, *, service=None, run_filter=None, budget_locators=None, sender=None)[source]

Search a Vectorsearch’s Vectorstore with a query, and return what it found, most similar first.

Parameters:
  • vectorsearch (Vectorsearch) – The Vectorsearch, whose search type, k, score threshold, mmr settings and metadata filter configure the search.

  • query (str) – What to search for.

  • service (VectorstoreService | None) – The service that searches the Vectorstore. By default, a VectorstoreService of the Vectorsearch’s Vectorstore.

  • run_filter (dict[str, Any] | None) – Metadata that the results must match, which the Vectorsearch’s own filter narrows.

  • budget_locators (list[str] | None) – The record locators whose budgets must allow the run, besides the Vectorsearch’s own, e.g. the user’s profile and account.

  • sender (object) – The vectorsearch_called signal’s sender.

Return type:

VectorsearchApiResults

Returns:

The Vectorsearch’s name, its Vectorstore’s name and the results.

Raises: