REST API
Vectorstore api/v1/vectorstores views.
Vectorstores are created and updated by applying manifests, with smarter apply. These views
load and search them, and maintain them:
GET vectorstores/: the vectorstores that the user may read.GET vectorstores/<hashed_id>/: a vectorstore that the user may read.GET vectorstores/<hashed_id>/status/: check its status and statistics, now.POST vectorstores/<hashed_id>/deploy/andPOST vectorstores/<hashed_id>/undeploy/.GET vectorstores/<hashed_id>/documents/: its documents.POST vectorstores/<hashed_id>/documents/: add documents, and queue them to be loaded: files, as multipart/form-data, or JSON{"name": ..., "text": ...}or{"url": ...}.DELETE vectorstores/<hashed_id>/documents/<document_id>/: remove a document, and its chunks.POST vectorstores/<hashed_id>/search/:{"query": ..., "k": 4, "searchType": "similarity", "scoreThreshold": null, "fetchK": null, "lambdaMult": null, "filter": {}}.GET vectorstores/<hashed_id>/snapshots/: its snapshots, or backups.POST vectorstores/<hashed_id>/snapshots/: take one now.POST vectorstores/<hashed_id>/snapshots/<snapshot_id>/restore/: restore one.
Reading and searching require read permission. Everything else requires ownership.
- class smarter.apps.vectorstore.api.v1.views.VectorstoreDeployView(*args, **kwargs)[source]
Bases:
VectorstoreViewBaseCreate the database of a vectorstore that the user owns.
- class smarter.apps.vectorstore.api.v1.views.VectorstoreDocumentView(*args, **kwargs)[source]
Bases:
VectorstoreViewBaseRemove a document, and its chunks, from a vectorstore that the user owns.
- class smarter.apps.vectorstore.api.v1.views.VectorstoreDocumentsView(*args, **kwargs)[source]
Bases:
VectorstoreViewBaseList a vectorstore’s documents, or add documents to one that the user owns.
- class smarter.apps.vectorstore.api.v1.views.VectorstoreListView(*args, **kwargs)[source]
Bases:
SmarterAuthenticatedListAPIViewThe vectorstores that the user may read.
- get_queryset(*args, **kwargs)[source]
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- Return type:
- serializer_class
alias of
VectorstoreSerializer
- class smarter.apps.vectorstore.api.v1.views.VectorstoreRestoreView(*args, **kwargs)[source]
Bases:
VectorstoreViewBaseReplace a vectorstore’s data with one of its snapshots.
- class smarter.apps.vectorstore.api.v1.views.VectorstoreSearchView(*args, **kwargs)[source]
Bases:
VectorstoreViewBaseSearch a vectorstore that the user may read.
- class smarter.apps.vectorstore.api.v1.views.VectorstoreSnapshotsView(*args, **kwargs)[source]
Bases:
VectorstoreViewBaseList a vectorstore’s snapshots, or take one now.
- class smarter.apps.vectorstore.api.v1.views.VectorstoreStatusView(*args, **kwargs)[source]
Bases:
VectorstoreViewBaseCheck a vectorstore’s status and statistics, now.
- class smarter.apps.vectorstore.api.v1.views.VectorstoreUndeployView(*args, **kwargs)[source]
Bases:
VectorstoreViewBaseStop serving a vectorstore that the user owns.
A self-hosted server’s data is kept.
- class smarter.apps.vectorstore.api.v1.views.VectorstoreView(*args, **kwargs)[source]
Bases:
VectorstoreViewBaseA vectorstore that the user may read.
- serializer_class
alias of
VectorstoreSerializer
- class smarter.apps.vectorstore.api.v1.views.VectorstoreViewBase(*args, **kwargs)[source]
Bases:
SmarterAuthenticatedAPIViewBase class of the views of one vectorstore, identified by
hashed_idorvectorstore_id.get_vectorstore()returns it only if the user may read it, or, withowner=True, owns it. Otherwise it raises Http404, so that other accounts’ vectorstores are not disclosed.- service_class
alias of
VectorstoreService
- smarter.apps.vectorstore.api.v1.views.error(message, status=HTTPStatus.BAD_REQUEST)[source]
- Return type:
URL configuration for the Vectorstore app API.
These are mounted at /api/v1/vectorstores/. See smarter.apps.vectorstore.api.v1.views.
- smarter.apps.vectorstore.api.v1.urls.PER_VECTORSTORE = {'': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreView'>, 'deploy/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreDeployView'>, 'documents/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreDocumentsView'>, 'documents/<int:document_id>/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreDocumentView'>, 'search/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreSearchView'>, 'snapshots/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreSnapshotsView'>, 'snapshots/<int:snapshot_id>/restore/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreRestoreView'>, 'status/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreStatusView'>, 'undeploy/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreUndeployView'>}
The views of one vectorstore, by URL suffix.
{ '': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreView'>, 'deploy/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreDeployView'>, 'documents/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreDocumentsView'>, 'documents/<int:document_id>/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreDocumentView'>, 'search/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreSearchView'>, 'snapshots/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreSnapshotsView'>, 'snapshots/<int:snapshot_id>/restore/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreRestoreView'>, 'status/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreStatusView'>, 'undeploy/': <class 'smarter.apps.vectorstore.api.v1.views.VectorstoreUndeployView'>, }
- class smarter.apps.vectorstore.api.v1.urls.VectorstoreApiV1ReverseViews[source]
Bases:
objectReverse view names of the Vectorstore api.
Each is available by the vectorstore’s hashed id, and by its id.
url = reverse( f"{VectorstoreApiV1ReverseViews.namespace}:{VectorstoreApiV1ReverseViews.search_by_hashed_id}", kwargs={"hashed_id": vectorstore.hashed_id}, )
- deploy_by_hashed_id = 'vectorstore_deploy_view_by_hashed_id'
- document_by_hashed_id = 'vectorstore_document_view_by_hashed_id'
- documents_by_hashed_id = 'vectorstore_documents_view_by_hashed_id'
- list_view = 'vectorstore_list_view'
- namespace = 'api:v1:vectorstore'
- restore_by_hashed_id = 'vectorstore_restore_view_by_hashed_id'
- search_by_hashed_id = 'vectorstore_search_view_by_hashed_id'
- snapshots_by_hashed_id = 'vectorstore_snapshots_view_by_hashed_id'
- status_by_hashed_id = 'vectorstore_status_view_by_hashed_id'
- undeploy_by_hashed_id = 'vectorstore_undeploy_view_by_hashed_id'
- vectorstore_by_hashed_id = 'vectorstore_view_by_hashed_id'