Vectorstore Services

Service layer for managing vector databases, providing abstractions for provisioning, deleting, and interacting

class smarter.apps.vectorstore.service.VectorstoreService(db)[source]

Bases: SmarterHelperMixin

Service class for managing vector databases.

This class provides service layer abstractions for provisioning, deleting, and interacting with vector databases using the appropriate backend implementations. It creates a binding between the smarter.apps.vectorstore.models.VectorestoreMeta ORM model, which contains the metadata and configuration for a vector database, and the backend implementations, which contain the logic for interacting with the underlying vector store.

The service also manages the association with LLM provider models and embedding services, enabling seamless integration for embedding and querying operations.

Original source: https://github.com/FullStackWithLawrence/openai-embeddings

__init__(db)[source]

Note: this needs to exist.

something in the Python MRO requires it, even if it does nothing. If you remove this, you will get a mysterious error about something downstream expecting exactly one object.

backend: SmarterVectorstoreBackend
db: VectorestoreMeta
delete()[source]

Delete an existing vector database using the appropriate backend.

embedding_service: SmarterEmbeddingServiceInterface
pdf_loader(filepath)[source]

Embed PDF. 1. Load PDF document text data 2. Split into pages 3. Embed each page 4. Store in Pinecone

Note: it’s important to make sure that the “context” field that holds the document text in the metadata is not indexed. Currently you need to specify explicitly the fields you do want to index. For more information checkout https://docs.pinecone.io/docs/manage-indexes#selective-metadata-indexing

provider: Provider
provider_model: ProviderModel
provision()[source]

Provision a new vector database using the appropriate backend.

query(query_vector, top_k=10)[source]

Query the vector database using the appropriate backend. Original source comes from https://github.com/FullStackWithLawrence/openai-embeddings

property ready: bool

Check if the vector database backend is ready for operations.

property text_splitter: RecursiveCharacterTextSplitter

Get the text splitter.