API Reference

Running a Vectorsearch: POST /api/v1/vectorsearches/<hashed_id>/vectorsearch/.

Run a Vectorsearch: POST /api/v1/vectorsearches/<hashed_id>/vectorsearch/, {"query": ..., "filter": {...}}.

A Vectorsearch is a saved search of one vectorstore: its search type, k, score threshold, mmr settings and metadata filter. A run searches the vectorstore with the request’s query, and that configuration, and returns the chunks it found, most similar first, as a VectorsearchApiResults.

The user needs read permission on the Vectorsearch. A run is refused when the Vectorsearch is disabled, and when a budget locks the Vectorsearch, the user’s profile or their account. Errors are Django REST framework’s {"detail": ...}.

class smarter.apps.vectorsearch.api.v1.views.default.DefaultVectorsearchApiView(*args, **kwargs)[source]

Bases: SmarterAuthenticatedAPIView

Run a Vectorsearch that the user may read: search its vectorstore with its configuration.

get_service(vectorstore)[source]

Return the service that searches a vectorstore, an instance of service_class.

Parameters:

vectorstore (VectorstoreMeta) – The vectorstore.

Return type:

VectorstoreService

Returns:

Its service.

get_vectorsearch(request, **kwargs)[source]

Return the Vectorsearch of the url, if the user may read it.

Parameters:
  • request (Request) – The request, whose user’s permissions are checked.

  • kwargs – The url’s arguments: hashed_id or vectorsearch_id.

Return type:

Vectorsearch

Returns:

The Vectorsearch.

Raises:

Http404 – If it does not exist, or the user may not read it.

static metadata_filter(vectorsearch, run)[source]

Return the metadata that every result must match: the request’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:
  • vectorsearch (Vectorsearch) – The Vectorsearch.

  • run (VectorsearchApiRun) – The request.

Return type:

dict[str, Any]

Returns:

The combined filter, which may be empty.

post(request, *args, **kwargs)[source]

Run the Vectorsearch with the JSON body’s query, and optional filter.

Parameters:
  • request (Request) – The request.

  • kwargs – The url’s arguments: hashed_id or vectorsearch_id.

Return type:

Response

Returns:

The results, 400 if the request is not valid, the Vectorsearch is disabled or the search failed, or 402 if a budget forbids it.

Raises:

Http404 – If it does not exist, or the user may not read it.

service_class

alias of VectorstoreService