Vectorstor ORM Models

Vectorstore models.

class smarter.apps.vectorstore.models.EmbeddingsInterface(*args, **kwargs)[source]

Bases: TimestampedModel

Model representing the SAMEmbeddingsInterface configuration for a vector database.

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

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • config (Unknown) – Config. Additional configuration settings for the embeddings interface.

  • dimensions (Unknown) – Dimensions. Number of embedding dimensions.

  • deployment (Unknown) – Deployment. Deployment name or model name.

  • api_version (Unknown) – Api version. OpenAI API version.

  • base_url (Unknown) – Base url. Base URL for OpenAI API.

  • openai_api_type (Unknown) – Openai api type. OpenAI API type.

  • openai_api_proxy (Unknown) – Openai api proxy. Proxy URL for OpenAI API.

  • embedding_ctx_length (Unknown) – Embedding ctx length. Embedding context length.

  • api_key (Unknown) – Api key. OpenAI API key or secret reference.

  • organization (Unknown) – Organization. OpenAI organization ID.

  • allowed_special (Unknown) – Allowed special. Allowed special tokens (set[str] or ‘all’).

  • disallowed_special (Unknown) – Disallowed special. Disallowed special tokens (set, sequence, or ‘all’).

  • chunk_size (Unknown) – Chunk size. Chunk size for embedding requests.

  • max_retries (Unknown) – Max retries. Maximum number of retries for API calls.

  • timeout (Unknown) – Timeout. Timeout for API requests (float, tuple, or other).

  • headers (Unknown) – Headers. Custom headers for API requests.

  • tiktoken_enabled (Unknown) – Tiktoken enabled. Enable tiktoken for tokenization.

  • tiktoken_model_name (Unknown) – Tiktoken model name. Tiktoken model name.

  • show_progress_bar (Unknown) – Show progress bar. Show progress bar during embedding.

  • model_kwargs (Unknown) – Model kwargs. Additional model keyword arguments.

  • skip_empty (Unknown) – Skip empty. Skip empty inputs.

  • default_headers (Unknown) – Default headers. Default headers for API requests.

  • default_query (Unknown) – Default query. Default query parameters for API requests.

  • retry_min_seconds (Unknown) – Retry min seconds. Minimum seconds between retries.

  • retry_max_seconds (Unknown) – Retry max seconds. Maximum seconds between retries.

  • check_ctx_length (Unknown) – Check ctx length. Check embedding context length.

Relationship fields:

Parameters:
  • vectorestore_meta (Unknown) – Vectorestore meta. The associated VectorestoreMeta object for this EmbeddingsInterface configuration. (related name: embeddings_interface)

  • provider (Unknown) – Provider. The provider associated with this vector database. (related name: vector_databases)

  • provider_model (Unknown) – Provider model. The provider model associated with this vector database. (related name: vector_databases)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

allowed_special

JSONField

Allowed special. Allowed special tokens (set[str] or ‘all’).

Type:

Type

api_key

CharField

Api key. OpenAI API key or secret reference.

Type:

Type

api_version

CharField

Api version. OpenAI API version.

Type:

Type

base_url

CharField

Base url. Base URL for OpenAI API.

Type:

Type

check_ctx_length

BooleanField

Check ctx length. Check embedding context length.

Type:

Type

chunk_size

IntegerField

Chunk size. Chunk size for embedding requests.

Type:

Type

config

JSONField

Config. Additional configuration settings for the embeddings interface.

Type:

Type

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

default_headers

JSONField

Default headers. Default headers for API requests.

Type:

Type

default_query

JSONField

Default query. Default query parameters for API requests.

Type:

Type

deployment

CharField

Deployment. Deployment name or model name.

Type:

Type

dimensions

IntegerField

Dimensions. Number of embedding dimensions.

Type:

Type

disallowed_special

JSONField

Disallowed special. Disallowed special tokens (set, sequence, or ‘all’).

Type:

Type

embedding_ctx_length

IntegerField

Embedding ctx length. Embedding context length.

Type:

Type

headers

JSONField

Headers. Custom headers for API requests.

Type:

Type

id

BigAutoField

Primary key: ID

Type:

Type

max_retries

IntegerField

Max retries. Maximum number of retries for API calls.

Type:

Type

model_kwargs

JSONField

Model kwargs. Additional model keyword arguments.

Type:

Type

objects = <django.db.models.Manager object>
openai_api_proxy

CharField

Openai api proxy. Proxy URL for OpenAI API.

Type:

Type

openai_api_type

CharField

Openai api type. OpenAI API type.

Type:

Type

organization

CharField

Organization. OpenAI organization ID.

Type:

Type

provider

ForeignKey to Provider

Provider. The provider associated with this vector database. (related name: vector_databases)

Type:

Type

provider_id

Internal field, use provider instead.

provider_model

ForeignKey to ProviderModel

Provider model. The provider model associated with this vector database. (related name: vector_databases)

Type:

Type

provider_model_id

Internal field, use provider_model instead.

retry_max_seconds

IntegerField

Retry max seconds. Maximum seconds between retries.

Type:

Type

retry_min_seconds

IntegerField

Retry min seconds. Minimum seconds between retries.

Type:

Type

save(*args, **kwargs)[source]

Override the save method to include validation for the embeddings provider model’s embedding support.

show_progress_bar

BooleanField

Show progress bar. Show progress bar during embedding.

Type:

Type

skip_empty

BooleanField

Skip empty. Skip empty inputs.

Type:

Type

tiktoken_enabled

BooleanField

Tiktoken enabled. Enable tiktoken for tokenization.

Type:

Type

tiktoken_model_name

CharField

Tiktoken model name. Tiktoken model name.

Type:

Type

timeout

FloatField

Timeout. Timeout for API requests (float, tuple, or other).

Type:

Type

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

vectorestore_meta

OneToOneField to VectorestoreMeta

Vectorestore meta. The associated VectorestoreMeta object for this EmbeddingsInterface configuration. (related name: embeddings_interface)

Type:

Type

vectorestore_meta_id

Internal field, use vectorestore_meta instead.

class smarter.apps.vectorstore.models.IndexModelInterface(*args, **kwargs)[source]

Bases: TimestampedModel

Model representing the SAMIndexModelInterface configuration for a vector database.

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

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • spec (Unknown) – Spec. Index deployment spec. Accepts a dict, ServerlessSpec, PodSpec, or ByocSpec. Example: ServerlessSpec(cloud=CloudProvider.AWS, region=AwsRegion.US_EAST_1)

  • dimension (Unknown) – Dimension. Number of dimensions for the index. Must be between 1 and 20,000, or None. Example: 1536.

  • metric (Unknown) – Metric. Distance metric for similarity search. Accepts Metric enum or string. Default: ‘cosine’.

  • timeout (Unknown) – Timeout. Timeout in seconds for index operations. Must be greater than zero or None.

  • deletion_protection (Unknown) – Deletion protection. Deletion protection setting. Accepts DeletionProtection enum or string. Default: ‘disabled’.

  • vector_type (Unknown) – Vector type. Type of vector. Accepts VectorType enum or string. Default: ‘dense’.

Relationship fields:

Parameters:

vectorestore_meta (Unknown) – Vectorestore meta. The associated VectorestoreMeta object for this IndexModelInterface configuration. (related name: index_model_interface)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

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

deletion_protection

CharField

Deletion protection. Deletion protection setting. Accepts DeletionProtection enum or string. Default: ‘disabled’.

Type:

Type

dimension

IntegerField

Dimension. Number of dimensions for the index. Must be between 1 and 20,000, or None. Example: 1536.

Type:

Type

id

BigAutoField

Primary key: ID

Type:

Type

metric

CharField

Metric. Distance metric for similarity search. Accepts Metric enum or string. Default: ‘cosine’.

Type:

Type

objects = <django.db.models.Manager object>
spec

JSONField

Spec. Index deployment spec. Accepts a dict, ServerlessSpec, PodSpec, or ByocSpec. Example: ServerlessSpec(cloud=CloudProvider.AWS, region=AwsRegion.US_EAST_1)

Type:

Type

timeout

IntegerField

Timeout. Timeout in seconds for index operations. Must be greater than zero or None.

Type:

Type

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

vector_type

CharField

Vector type. Type of vector. Accepts VectorType enum or string. Default: ‘dense’.

Type:

Type

vectorestore_meta

OneToOneField to VectorestoreMeta

Vectorestore meta. The associated VectorestoreMeta object for this IndexModelInterface configuration. (related name: index_model_interface)

Type:

Type

vectorestore_meta_id

Internal field, use vectorestore_meta instead.

class smarter.apps.vectorstore.models.VectorestoreMeta(*args, **kwargs)[source]

Bases: MetaDataWithOwnershipModel

Model representing a vector database.

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.

  • backend (Unknown) – Backend. The backend type for the vector database (e.g., qdrant, weaviate, pinecone).

  • is_active (Unknown) – Is active. Indicates whether the vector database is active.

  • status (Unknown) – Status. The current status of the vector database (e.g., provisioning, ready, failed, deleting).

Relationship fields:

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

  • connection (Unknown) – Connection. The Smarter Connection object containing connection details for the vector database. If provided, this connection will be used instead of the host, port, auth_config, and password fields to establish the connection. The Connection object must be owned by the authenticated API user and must contain the necessary information to connect to the vector database. (related name: vector_databases)

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

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

Reverse relationships:

Parameters:
  • embeddings_interface (Unknown) – The embeddings interface of this Vectorstore Metadata (related name of vectorestore_meta)

  • index_model_interface (Unknown) – The index model interface of this Vectorstore Metadata (related name of vectorestore_meta)

  • vectorstore_interface (Unknown) – The vectorstore interface of this Vectorstore Metadata (related name of vectorestore_meta)

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

backend

CharField

Backend. The backend type for the vector database (e.g., qdrant, weaviate, pinecone).

Choices:

  • qdrant

  • weaviate

  • pinecone

Type:

Type

connection

ForeignKey to ApiConnection

Connection. The Smarter Connection object containing connection details for the vector database. If provided, this connection will be used instead of the host, port, auth_config, and password fields to establish the connection. The Connection object must be owned by the authenticated API user and must contain the necessary information to connect to the vector database. (related name: vector_databases)

Type:

Type

connection_id

Internal field, use connection instead.

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

embeddings_interface

Reverse OneToOneField from EmbeddingsInterface

The embeddings interface of this Vectorstore Metadata (related name of vectorestore_meta)

Type:

Type

get_backend_display(*, field=<django.db.models.CharField: backend>)

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

classmethod get_cached_object(*args, backend=None, **kwargs)[source]

Retrieve a cached VectorestoreMeta object based on the provided name and backend. This method is used to optimize backend retrieval by caching database objects.

Return type:

VectorestoreMeta

Parameters:

backend (str) – The backend kind of the vector database.

Returns:

The cached VectorestoreMeta object matching the name and backend.

Return type:

VectorestoreMeta

classmethod get_cached_vectorstores_for_user(user, invalidate=False)[source]

Return a list of all instances of VectorestoreMeta.

This method retrieves all vector store objects associated with the user’s account. It is useful for enumerating all available vector stores for a given user.

Parameters:

user (User) – The user whose vector stores should be retrieved.

Returns:

A list of all vector store instances for the user’s account.

Return type:

list[VectorestoreMeta]

Example:

vectorstores = VectorestoreMeta.get_cached_vectorstores_for_user(user)
# returns [<VectorestoreMeta ...>, <VectorestoreMeta ...>, ...]

See also:

get_status_display(*, field=<django.db.models.CharField: status>)

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

id

BigAutoField

Primary key: ID

Type:

Type

index_model_interface

Reverse OneToOneField from IndexModelInterface

The index model interface of this Vectorstore Metadata (related name of vectorestore_meta)

Type:

Type

is_active

BooleanField

Is active. Indicates whether the vector database is active.

Type:

Type

name

CharField

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

Type:

Type

objects: MetaDataWithOwnershipModelManager = <smarter.apps.account.models.metadata_with_ownership.MetaDataWithOwnershipModelManager object>
status

CharField

Status. The current status of the vector database (e.g., provisioning, ready, failed, deleting).

Choices:

  • provisioning

  • ready

  • failed

  • deleting

Type:

Type

tagged_items

Reverse GenericRelation from VectorestoreMeta

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: vectorestoremeta)

Type:

Type

user_profile_id

Internal field, use user_profile instead.

vectorstore_interface

Reverse OneToOneField from VectorstoreInterface

The vectorstore interface of this Vectorstore Metadata (related name of vectorestore_meta)

Type:

Type

version

CharField

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

Type:

Type

class smarter.apps.vectorstore.models.VectorstoreBackendKind(*values)[source]

Bases: TextChoices

Enum representing the supported backend kinds for the vector database.

PINECONE = 'pinecone'
QDRANT = 'qdrant'
WEAVIATE = 'weaviate'
class smarter.apps.vectorstore.models.VectorstoreInterface(*args, **kwargs)[source]

Bases: TimestampedModel

Model representing the VectorstoreInterface configuration for a vector database.

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

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • text_key (Unknown) – Text key. The key in the vector database where the original text is stored, if applicable.

  • namespace (Unknown) – Namespace. The namespace to use for the vector database, if applicable.

  • distance_strategy (Unknown) – Distance strategy. The distance strategy to use for similarity search (e.g., cosine, euclidean, dot_product), if applicable.

Relationship fields:

Parameters:

vectorestore_meta (Unknown) – Vectorestore meta. The associated VectorestoreMeta object for this VectorstoreInterface configuration. (related name: vectorstore_interface)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

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

distance_strategy

CharField

Distance strategy. The distance strategy to use for similarity search (e.g., cosine, euclidean, dot_product), if applicable.

Type:

Type

id

BigAutoField

Primary key: ID

Type:

Type

namespace

CharField

Namespace. The namespace to use for the vector database, if applicable.

Type:

Type

objects = <django.db.models.Manager object>
text_key

CharField

Text key. The key in the vector database where the original text is stored, if applicable.

Type:

Type

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

vectorestore_meta

OneToOneField to VectorestoreMeta

Vectorestore meta. The associated VectorestoreMeta object for this VectorstoreInterface configuration. (related name: vectorstore_interface)

Type:

Type

vectorestore_meta_id

Internal field, use vectorestore_meta instead.

class smarter.apps.vectorstore.models.VectorstoreStatus(*values)[source]

Bases: TextChoices

Enum representing the possible statuses of the vector database.

DELETING = 'deleting'
FAILED = 'failed'
PROVISIONING = 'provisioning'
READY = 'ready'