pgvector-haystack 6.1.0__py3-none-any.whl → 6.2.0__py3-none-any.whl
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.
- haystack_integrations/document_stores/pgvector/converters.py +5 -1
- haystack_integrations/document_stores/pgvector/filters.py +9 -0
- {pgvector_haystack-6.1.0.dist-info → pgvector_haystack-6.2.0.dist-info}/METADATA +2 -2
- {pgvector_haystack-6.1.0.dist-info → pgvector_haystack-6.2.0.dist-info}/RECORD +6 -6
- {pgvector_haystack-6.1.0.dist-info → pgvector_haystack-6.2.0.dist-info}/WHEEL +1 -1
- {pgvector_haystack-6.1.0.dist-info → pgvector_haystack-6.2.0.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from dataclasses import replace
|
|
1
2
|
from typing import Any
|
|
2
3
|
|
|
3
4
|
from haystack import logging
|
|
@@ -22,6 +23,9 @@ def _from_haystack_to_pg_documents(documents: list[Document]) -> list[dict[str,
|
|
|
22
23
|
db_document["blob_meta"] = Jsonb(blob.meta) if blob and blob.meta else None
|
|
23
24
|
db_document["blob_mime_type"] = blob.mime_type if blob and blob.mime_type else None
|
|
24
25
|
db_document["meta"] = Jsonb(db_document["meta"])
|
|
26
|
+
# PostgreSQL text fields cannot contain NUL (0x00) bytes, removing NUL bytes
|
|
27
|
+
if content := db_document["content"]:
|
|
28
|
+
db_document["content"] = content.replace("\x00", "")
|
|
25
29
|
|
|
26
30
|
if "sparse_embedding" in db_document:
|
|
27
31
|
sparse_embedding = db_document.pop("sparse_embedding", None)
|
|
@@ -65,7 +69,7 @@ def _from_pg_to_haystack_documents(documents: list[dict[str, Any]]) -> list[Docu
|
|
|
65
69
|
|
|
66
70
|
if blob_data:
|
|
67
71
|
blob = ByteStream(data=blob_data, meta=blob_meta, mime_type=blob_mime_type)
|
|
68
|
-
haystack_document
|
|
72
|
+
haystack_document = replace(haystack_document, blob=blob)
|
|
69
73
|
|
|
70
74
|
haystack_documents.append(haystack_document)
|
|
71
75
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
|
|
2
2
|
#
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
import re
|
|
4
6
|
from datetime import datetime
|
|
5
7
|
from itertools import chain
|
|
6
8
|
from typing import Any, Literal
|
|
@@ -19,6 +21,7 @@ PYTHON_TYPES_TO_PG_TYPES = {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
NO_VALUE = "no_value"
|
|
24
|
+
SAFE_META_FIELD_RE = re.compile(r"^[a-zA-Z0-9_-]+$")
|
|
22
25
|
|
|
23
26
|
|
|
24
27
|
def _validate_filters(filters: dict[str, Any] | None = None) -> None:
|
|
@@ -128,6 +131,12 @@ def _treat_meta_field(field: str, value: Any) -> str:
|
|
|
128
131
|
|
|
129
132
|
# use the ->> operator to access keys in the meta JSONB field
|
|
130
133
|
field_name = field.split(".", 1)[-1]
|
|
134
|
+
if not SAFE_META_FIELD_RE.match(field_name):
|
|
135
|
+
msg = (
|
|
136
|
+
f"Invalid metadata field name '{field_name}'. "
|
|
137
|
+
"Only alphanumeric characters, dashes, and underscores are allowed."
|
|
138
|
+
)
|
|
139
|
+
raise FilterError(msg)
|
|
131
140
|
field = f"meta->>'{field_name}'"
|
|
132
141
|
|
|
133
142
|
# meta fields are stored as strings in the JSONB field,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pgvector-haystack
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.2.0
|
|
4
4
|
Summary: An integration of pgvector (vector search extension for Postgres) with Haystack
|
|
5
5
|
Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations
|
|
6
6
|
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/pgvector/README.md
|
|
@@ -18,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
18
18
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
19
19
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
20
20
|
Requires-Python: >=3.10
|
|
21
|
-
Requires-Dist: haystack-ai>=2.
|
|
21
|
+
Requires-Dist: haystack-ai>=2.24.0
|
|
22
22
|
Requires-Dist: pgvector>=0.3.0
|
|
23
23
|
Requires-Dist: psycopg[binary]
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
@@ -4,10 +4,10 @@ haystack_integrations/components/retrievers/pgvector/embedding_retriever.py,sha2
|
|
|
4
4
|
haystack_integrations/components/retrievers/pgvector/keyword_retriever.py,sha256=6Qam_QABa67Yfs8UW0a5FArhLTFGU2fYQ4wGZjVHzUI,6792
|
|
5
5
|
haystack_integrations/document_stores/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
haystack_integrations/document_stores/pgvector/__init__.py,sha256=Ge-7ggarfr3x8UqNdFHUuFGiu52u49sOVe3l16WEwZU,197
|
|
7
|
-
haystack_integrations/document_stores/pgvector/converters.py,sha256=
|
|
7
|
+
haystack_integrations/document_stores/pgvector/converters.py,sha256=SXLDpb-GfaKSHl5Oann38T27QWR-8pamTmdLklK9my0,3181
|
|
8
8
|
haystack_integrations/document_stores/pgvector/document_store.py,sha256=nwxyI450JqN5rP50ZMWRs_2otT2J5kWuxbejteLhZUE,84473
|
|
9
|
-
haystack_integrations/document_stores/pgvector/filters.py,sha256=
|
|
10
|
-
pgvector_haystack-6.
|
|
11
|
-
pgvector_haystack-6.
|
|
12
|
-
pgvector_haystack-6.
|
|
13
|
-
pgvector_haystack-6.
|
|
9
|
+
haystack_integrations/document_stores/pgvector/filters.py,sha256=SpfqFvSLhQOs42QPBJuWj63Zv-q6J1ja9xaXR36S2Pw,9300
|
|
10
|
+
pgvector_haystack-6.2.0.dist-info/METADATA,sha256=DEi8WE03yyge9p0xI6AiRmwWtkQ2c96U5inGdg-hQ18,2095
|
|
11
|
+
pgvector_haystack-6.2.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
12
|
+
pgvector_haystack-6.2.0.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
|
|
13
|
+
pgvector_haystack-6.2.0.dist-info/RECORD,,
|
{pgvector_haystack-6.1.0.dist-info → pgvector_haystack-6.2.0.dist-info}/licenses/LICENSE.txt
RENAMED
|
File without changes
|