Skip to content

vendor_connectors.meshy.persistence.vector_store

SQLite vector store for idempotency tracking and RAG embeddings.

This module provides a vector-enabled SQLite database for:

  1. Idempotency tracking - deduplicate asset generation requests
  2. RAG embeddings - semantic search over prompts, species, assets

Uses sqlite-vec for vector similarity search, falling back to standard SQLite if vectors aren’t needed.

Usage: from vendor_connectors.meshy.persistence.vector_store import VectorStore

store = VectorStore("assets.db")
# Track asset generation
store.record_generation(
spec_hash="abc123",
prompt="cute otter character",
task_id="meshy-task-id",
embedding=get_embedding("cute otter character"),
)
# Find similar prompts (RAG)
similar = store.search_similar("river otter", limit=5)
# Check idempotency
existing = store.get_by_spec_hash("abc123")

Requirements: pip install mesh-toolkit[vector]

The vector extra includes:
- sqlite-vec (vector similarity extension)
- Optional: sentence-transformers for embeddings
GenerationRecordRecord of a 3D asset generation.
SimilarityResultResult from similarity search.
VectorStoreSQLite vector store for asset generation tracking and RAG.
_utc_now
get_embeddingGet embedding for text using sentence-transformers.
_HAS_VECTOR

vendor_connectors.meshy.persistence.vector_store._HAS_VECTOR

Section titled “vendor_connectors.meshy.persistence.vector_store._HAS_VECTOR”

False

class vendor_connectors.meshy.persistence.vector_store.GenerationRecord

Section titled “class vendor_connectors.meshy.persistence.vector_store.GenerationRecord”

Record of a 3D asset generation.

None

‘sculpture’

None

‘pending’

None

None

‘field(…)’

‘field(…)’

‘field(…)’

class vendor_connectors.meshy.persistence.vector_store.SimilarityResult

Section titled “class vendor_connectors.meshy.persistence.vector_store.SimilarityResult”

Result from similarity search.

None

None

None

class vendor_connectors.meshy.persistence.vector_store.VectorStore(db_path: str | pathlib.Path = ‘vendor_connectors.meshy.db’, embedding_dim: int = DEFAULT_EMBEDDING_DIM)

Section titled “class vendor_connectors.meshy.persistence.vector_store.VectorStore(db_path: str | pathlib.Path = ‘vendor_connectors.meshy.db’, embedding_dim: int = DEFAULT_EMBEDDING_DIM)”

SQLite vector store for asset generation tracking and RAG.

Features:

  • Idempotent task tracking by spec_hash
  • Vector similarity search for RAG
  • Full-text search fallback when vectors unavailable
  • Atomic transactions

Args: db_path: Path to SQLite database file embedding_dim: Dimension of embedding vectors (default: 384 for MiniLM)

384

Get or create database connection.

Context manager for transactions.

Initialize database schema.

Record a new generation (idempotent by spec_hash).

If a record with the same spec_hash exists, returns existing.

Args: spec_hash: Unique hash of the generation spec prompt: Text prompt for generation project: Project identifier art_style: Art style (realistic, sculpture, etc.) task_id: Meshy task ID if already submitted embedding: Optional embedding vector for RAG metadata: Additional metadata dict

Returns: GenerationRecord (existing or newly created)

Update generation status.

Args: spec_hash: Generation spec hash status: New status task_id: Optional task ID to update model_url: Optional model URL to update

Returns: True if record was updated, False if not found

Get generation record by spec hash.

Args: spec_hash: Generation spec hash

Returns: GenerationRecord or None

Get generation record by Meshy task ID.

Args: task_id: Meshy task ID

Returns: GenerationRecord or None

Search for similar generations using vector similarity.

Args: query_embedding: Query embedding vector limit: Maximum results to return project: Optional project filter

Returns: List of SimilarityResult ordered by similarity (highest first)

Full-text search for prompts.

Falls back to this when vector search is unavailable.

Args: query: Search query limit: Maximum results project: Optional project filter

Returns: List of matching GenerationRecords

List all pending/in-progress generations.

Args: project: Optional project filter

Returns: List of pending GenerationRecords

Compute deterministic hash for a generation spec.

Args: spec: Generation specification dict

Returns: SHA256 hex digest

Convert database row to GenerationRecord.

Serialize embedding to bytes for SQLite vec.

Close database connection.

Get embedding for text using sentence-transformers.

Args: text: Text to embed model: Model name (default: all-MiniLM-L6-v2)

Returns: Embedding vector or None if sentence-transformers not available