pgvector-template 0.3.3__tar.gz → 0.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/PKG-INFO +1 -1
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/core/manager.py +15 -4
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template.egg-info/PKG-INFO +1 -1
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pyproject.toml +1 -1
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/LICENSE +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/README.md +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/__init__.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/core/__init__.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/core/document.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/core/embedder.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/core/search.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/db/__init__.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/db/connection.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/db/document_db.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/models/__init__.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/models/search.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/service/__init__.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/service/document_service.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/types.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/utils/__init__.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/utils/metadata_filter.py +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template.egg-info/SOURCES.txt +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template.egg-info/dependency_links.txt +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template.egg-info/requires.txt +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template.egg-info/top_level.txt +0 -0
- {pgvector_template-0.3.3 → pgvector_template-0.3.4}/setup.cfg +0 -0
|
@@ -105,6 +105,15 @@ class BaseCorpusManager(ABC):
|
|
|
105
105
|
documents=chunks,
|
|
106
106
|
)
|
|
107
107
|
|
|
108
|
+
def _generate_corpus_id(
|
|
109
|
+
self, corpus_id: UUID | str | None = None, content: str | None = None
|
|
110
|
+
) -> UUID | str:
|
|
111
|
+
"""
|
|
112
|
+
Helper to generate a corpus_id if not provided.
|
|
113
|
+
Override this method to provide a consistent way to generate.
|
|
114
|
+
"""
|
|
115
|
+
return corpus_id if corpus_id else uuid4()
|
|
116
|
+
|
|
108
117
|
def insert_corpus(
|
|
109
118
|
self,
|
|
110
119
|
content: str,
|
|
@@ -126,8 +135,7 @@ class BaseCorpusManager(ABC):
|
|
|
126
135
|
Returns:
|
|
127
136
|
int: The number of **documents** inserted for the provided corpus
|
|
128
137
|
"""
|
|
129
|
-
|
|
130
|
-
corpus_id = uuid4()
|
|
138
|
+
corpus_id = self._generate_corpus_id(corpus_id)
|
|
131
139
|
document_contents = self._split_corpus(content)
|
|
132
140
|
document_embeddings = self.embedding_provider.embed_batch(document_contents)
|
|
133
141
|
return self.insert_documents(
|
|
@@ -214,9 +222,12 @@ class BaseCorpusManager(ABC):
|
|
|
214
222
|
|
|
215
223
|
def _delete_existing_corpus(self, corpus_id: UUID | str) -> None:
|
|
216
224
|
"""Delete all existing documents for the given corpus_id"""
|
|
217
|
-
self.session.query(self.config.document_cls).filter(
|
|
225
|
+
query = self.session.query(self.config.document_cls).filter(
|
|
218
226
|
self.config.document_cls.corpus_id == corpus_id
|
|
219
|
-
)
|
|
227
|
+
)
|
|
228
|
+
if count := query.count():
|
|
229
|
+
logger.warning(f"Deleting {count} existing documents for corpus_id: {corpus_id}")
|
|
230
|
+
query.delete()
|
|
220
231
|
|
|
221
232
|
def _split_corpus(self, content: str, **kwargs) -> list[str]:
|
|
222
233
|
"""
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pgvector-template"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.4"
|
|
8
8
|
description = "Template library for flexible PGVector RAG implementations"
|
|
9
9
|
authors = [{ name="DL", email="v49t9zpqd@mozmail.com" }]
|
|
10
10
|
license = { text = "MIT" }
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/service/document_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template/utils/metadata_filter.py
RENAMED
|
File without changes
|
|
File without changes
|
{pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pgvector_template-0.3.3 → pgvector_template-0.3.4}/pgvector_template.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|