Django ORM

All models for the Vectorsearch app.

class smarter.apps.vectorsearch.models.Vectorsearch(*args, **kwargs)[source]

Bases: MetaDataWithOwnershipModel

Implements the Vectorsearch API model.

A Vectorsearch is a named, ownable configuration describing how to execute a semantic search against a single VectorstoreMeta. It does not itself hold embeddings/documents – it references a VectorstoreMeta for that – and it does not generate text. Combine a Vectorsearch with a Smarter LLMClient to build a RAG pipeline: the top-k results returned by the Vectorsearch are injected into the LLMClient’s system prompt at inference time.

Parameters:
  • id (Unknown) – Primary key: ID

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • name (Unknown) – Name. Name in camelCase, e.g., ‘apiKey’, no special characters.

  • description (Unknown) – Description. A brief description of this resource. Be verbose, but not too verbose.

  • version (Unknown) – Version. Semantic version in the format MAJOR.MINOR.PATCH, e.g., ‘1.0.0’.

  • annotations (Unknown) – Annotations. Key-value pairs for annotating this resource.

  • search_type (Unknown) – Search type. The retrieval strategy to use when querying the VectorstoreMeta.

  • k (Unknown) –

    1. Number of top results to return from the search.

  • score_threshold (Unknown) – Score threshold. Minimum relevance score (0.0-1.0) a result must meet to be included. Only applicable when search_type=’similarity_score_threshold’.

  • fetch_k (Unknown) – Fetch k. Number of candidate documents to fetch before applying MMR re-ranking. Only applicable when search_type=’mmr’.

  • lambda_mult (Unknown) – Lambda mult. Diversity vs. relevance trade-off for MMR, between 0.0 (max diversity) and 1.0 (max relevance). Only applicable when search_type=’mmr’.

  • metadata_filter (Unknown) – Metadata filter. Optional metadata filter applied to the VectorstoreMeta query, e.g. {‘source’: ‘faq’}.

  • is_enabled (Unknown) – Is enabled. Whether this Vectorsearch is active and eligible to be queried.

Relationship fields:

Parameters:
  • user_profile (Unknown) – User profile (related name: vectorsearch)

  • vectorstore (Unknown) – Vectorstore. The locally-hosted VectorstoreMeta this search queries against. (related name: vectorsearches)

  • auth_secret (Unknown) – Auth secret. Optional credential used to authenticate against the VectorstoreMeta, if required. (related name: vectorsearches)

  • tags (Unknown) – Tags. Tags for categorizing and organizing this resource. (related name: vectorsearch)

  • tagged_items (Unknown) – Tagged items (related name: +)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

annotations

JSONField

Annotations. Key-value pairs for annotating this resource.

Type:

Type

auth_secret

ForeignKey to Secret

Auth secret. Optional credential used to authenticate against the VectorstoreMeta, if required. (related name: vectorsearches)

Type:

Type

auth_secret_id

Internal field, use auth_secret instead.

clean()[source]

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

created_at

DateTimeField

Created at

Timestamp indicating when the model instance was created.

This field is automatically set to the current date and time when the instance is first created. It is indexed in the database for efficient querying.

Type:

Type

description

TextField

Description. A brief description of this resource. Be verbose, but not too verbose.

Type:

Type

fetch_k

PositiveSmallIntegerField

Fetch k. Number of candidate documents to fetch before applying MMR re-ranking. Only applicable when search_type=’mmr’.

Type:

Type

get_search_type_display(*, field=<django.db.models.CharField: search_type>)

Shows the label of the search_type. See get_FOO_display() for more information.

id

BigAutoField

Primary key: ID

Type:

Type

is_enabled

BooleanField

Is enabled. Whether this Vectorsearch is active and eligible to be queried.

Type:

Type

k

PositiveSmallIntegerField

  1. Number of top results to return from the search.

Type:

Type

lambda_mult

FloatField

Lambda mult. Diversity vs. relevance trade-off for MMR, between 0.0 (max diversity) and 1.0 (max relevance). Only applicable when search_type=’mmr’.

Type:

Type

metadata_filter

JSONField

Metadata filter. Optional metadata filter applied to the VectorstoreMeta query, e.g. {‘source’: ‘faq’}.

Type:

Type

name

CharField

Name. Name in camelCase, e.g., ‘apiKey’, no special characters.

Type:

Type

score_threshold

FloatField

Score threshold. Minimum relevance score (0.0-1.0) a result must meet to be included. Only applicable when search_type=’similarity_score_threshold’.

Type:

Type

search_type

CharField

Search type. The retrieval strategy to use when querying the VectorstoreMeta.

Choices:

  • similarity

  • similarity_score_threshold

  • mmr

Type:

Type

tagged_items

Reverse GenericRelation from Vectorsearch

All + of this tagged item (related name of tagged_items)

Type:

Type

tags = <taggit.managers._TaggableManager object>
updated_at

DateTimeField

Updated at

Timestamp indicating when the model instance was last updated.

This field is automatically updated to the current date and time whenever the instance is saved. It is indexed in the database for efficient querying.

Type:

Type

user_profile

ForeignKey to UserProfile

User profile (related name: vectorsearch)

Type:

Type

user_profile_id

Internal field, use user_profile instead.

vectorstore

ForeignKey to VectorstoreMeta

Vectorstore. The locally-hosted VectorstoreMeta this search queries against. (related name: vectorsearches)

Type:

Type

vectorstore_id

Internal field, use vectorstore instead.

version

CharField

Version. Semantic version in the format MAJOR.MINOR.PATCH, e.g., ‘1.0.0’.

Type:

Type

class smarter.apps.vectorsearch.models.VectorsearchSearchType(*values)[source]

Bases: TextChoices

Supported retrieval strategies for a Vectorsearch query.

MMR = 'mmr'
SIMILARITY = 'similarity'
SIMILARITY_SCORE_THRESHOLD = 'similarity_score_threshold'