pgvector-haystack 1.3.0__py3-none-any.whl → 2.0.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/document_store.py +22 -8
- haystack_integrations/document_stores/pgvector/filters.py +0 -5
- {pgvector_haystack-1.3.0.dist-info → pgvector_haystack-2.0.0.dist-info}/METADATA +1 -1
- {pgvector_haystack-1.3.0.dist-info → pgvector_haystack-2.0.0.dist-info}/RECORD +6 -6
- {pgvector_haystack-1.3.0.dist-info → pgvector_haystack-2.0.0.dist-info}/WHEEL +0 -0
- {pgvector_haystack-1.3.0.dist-info → pgvector_haystack-2.0.0.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -28,7 +28,6 @@ CREATE TABLE IF NOT EXISTS {schema_name}.{table_name} (
|
|
|
28
28
|
id VARCHAR(128) PRIMARY KEY,
|
|
29
29
|
embedding VECTOR({embedding_dimension}),
|
|
30
30
|
content TEXT,
|
|
31
|
-
dataframe JSONB,
|
|
32
31
|
blob_data BYTEA,
|
|
33
32
|
blob_meta JSONB,
|
|
34
33
|
blob_mime_type VARCHAR(255),
|
|
@@ -37,15 +36,14 @@ meta JSONB)
|
|
|
37
36
|
|
|
38
37
|
INSERT_STATEMENT = """
|
|
39
38
|
INSERT INTO {schema_name}.{table_name}
|
|
40
|
-
(id, embedding, content,
|
|
41
|
-
VALUES (%(id)s, %(embedding)s, %(content)s, %(
|
|
39
|
+
(id, embedding, content, blob_data, blob_meta, blob_mime_type, meta)
|
|
40
|
+
VALUES (%(id)s, %(embedding)s, %(content)s, %(blob_data)s, %(blob_meta)s, %(blob_mime_type)s, %(meta)s)
|
|
42
41
|
"""
|
|
43
42
|
|
|
44
43
|
UPDATE_STATEMENT = """
|
|
45
44
|
ON CONFLICT (id) DO UPDATE SET
|
|
46
45
|
embedding = EXCLUDED.embedding,
|
|
47
46
|
content = EXCLUDED.content,
|
|
48
|
-
dataframe = EXCLUDED.dataframe,
|
|
49
47
|
blob_data = EXCLUDED.blob_data,
|
|
50
48
|
blob_meta = EXCLUDED.blob_meta,
|
|
51
49
|
blob_mime_type = EXCLUDED.blob_mime_type,
|
|
@@ -555,10 +553,18 @@ class PgvectorDocumentStore:
|
|
|
555
553
|
db_document["blob_data"] = blob.data if blob else None
|
|
556
554
|
db_document["blob_meta"] = Jsonb(blob.meta) if blob and blob.meta else None
|
|
557
555
|
db_document["blob_mime_type"] = blob.mime_type if blob and blob.mime_type else None
|
|
558
|
-
|
|
559
|
-
db_document["dataframe"] = Jsonb(db_document["dataframe"]) if db_document["dataframe"] else None
|
|
560
556
|
db_document["meta"] = Jsonb(db_document["meta"])
|
|
561
557
|
|
|
558
|
+
if "dataframe" in db_document:
|
|
559
|
+
dataframe = db_document.pop("dataframe", None)
|
|
560
|
+
if dataframe:
|
|
561
|
+
logger.warning(
|
|
562
|
+
"Document %s has the `dataframe` field set. "
|
|
563
|
+
"PgvectorDocumentStore no longer supports dataframes and this field will be ignored. "
|
|
564
|
+
"The `dataframe` field will soon be removed from Haystack Document.",
|
|
565
|
+
db_document["id"],
|
|
566
|
+
)
|
|
567
|
+
|
|
562
568
|
if "sparse_embedding" in db_document:
|
|
563
569
|
sparse_embedding = db_document.pop("sparse_embedding", None)
|
|
564
570
|
if sparse_embedding:
|
|
@@ -585,12 +591,20 @@ class PgvectorDocumentStore:
|
|
|
585
591
|
blob_data = haystack_dict.pop("blob_data")
|
|
586
592
|
blob_meta = haystack_dict.pop("blob_meta")
|
|
587
593
|
blob_mime_type = haystack_dict.pop("blob_mime_type")
|
|
594
|
+
dataframe = haystack_dict.pop("dataframe", None)
|
|
588
595
|
|
|
589
|
-
#
|
|
590
|
-
# so we need to convert it to a list of floats
|
|
596
|
+
# convert the embedding to a list of floats
|
|
591
597
|
if document.get("embedding") is not None:
|
|
592
598
|
haystack_dict["embedding"] = document["embedding"].tolist()
|
|
593
599
|
|
|
600
|
+
if dataframe:
|
|
601
|
+
logger.warning(
|
|
602
|
+
"Document %s has the `dataframe` field set. "
|
|
603
|
+
"PgvectorDocumentStore no longer supports dataframes and this field will be ignored. "
|
|
604
|
+
"The `dataframe` field will soon be removed from Haystack Document.",
|
|
605
|
+
haystack_dict["id"],
|
|
606
|
+
)
|
|
607
|
+
|
|
594
608
|
haystack_document = Document.from_dict(haystack_dict)
|
|
595
609
|
|
|
596
610
|
if blob_data:
|
|
@@ -6,7 +6,6 @@ from itertools import chain
|
|
|
6
6
|
from typing import Any, Dict, List, Literal, Tuple
|
|
7
7
|
|
|
8
8
|
from haystack.errors import FilterError
|
|
9
|
-
from pandas import DataFrame
|
|
10
9
|
from psycopg.sql import SQL
|
|
11
10
|
from psycopg.types.json import Jsonb
|
|
12
11
|
|
|
@@ -93,10 +92,6 @@ def _parse_comparison_condition(condition: Dict[str, Any]) -> Tuple[str, List[An
|
|
|
93
92
|
raise FilterError(msg)
|
|
94
93
|
|
|
95
94
|
value: Any = condition["value"]
|
|
96
|
-
if isinstance(value, DataFrame):
|
|
97
|
-
# DataFrames are stored as JSONB and we query them as such
|
|
98
|
-
value = Jsonb(value.to_json())
|
|
99
|
-
field = f"({field})::jsonb"
|
|
100
95
|
|
|
101
96
|
if field.startswith("meta."):
|
|
102
97
|
field = _treat_meta_field(field, value)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pgvector-haystack
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.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
|
|
@@ -2,9 +2,9 @@ haystack_integrations/components/retrievers/pgvector/__init__.py,sha256=n4q4pUAp
|
|
|
2
2
|
haystack_integrations/components/retrievers/pgvector/embedding_retriever.py,sha256=IEIdgKy_IWgmL5Qy_Hqkwa2mq2JxnQ_JOdjm38JPxmE,7530
|
|
3
3
|
haystack_integrations/components/retrievers/pgvector/keyword_retriever.py,sha256=SYHqjTkDczobYZ2qq0z8yS9p_g8aINnzwA5AN_nKdHI,5632
|
|
4
4
|
haystack_integrations/document_stores/pgvector/__init__.py,sha256=Ge-7ggarfr3x8UqNdFHUuFGiu52u49sOVe3l16WEwZU,197
|
|
5
|
-
haystack_integrations/document_stores/pgvector/document_store.py,sha256=
|
|
6
|
-
haystack_integrations/document_stores/pgvector/filters.py,sha256=
|
|
7
|
-
pgvector_haystack-
|
|
8
|
-
pgvector_haystack-
|
|
9
|
-
pgvector_haystack-
|
|
10
|
-
pgvector_haystack-
|
|
5
|
+
haystack_integrations/document_stores/pgvector/document_store.py,sha256=rirjSAMaPLADimwPcj-WQohrQbnXpTWgOCSIJy3qpPg,32148
|
|
6
|
+
haystack_integrations/document_stores/pgvector/filters.py,sha256=M-_wmM1iKS1QdKhnRk27N8t2W1st2YZWAwVSFUyyTtk,8508
|
|
7
|
+
pgvector_haystack-2.0.0.dist-info/METADATA,sha256=NhUGkaP8KzfX8qrlU5LrI-pjEQ3B4UDCfqN-WvlXsGY,2226
|
|
8
|
+
pgvector_haystack-2.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
9
|
+
pgvector_haystack-2.0.0.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
|
|
10
|
+
pgvector_haystack-2.0.0.dist-info/RECORD,,
|
|
File without changes
|
{pgvector_haystack-1.3.0.dist-info → pgvector_haystack-2.0.0.dist-info}/licenses/LICENSE.txt
RENAMED
|
File without changes
|