pgvector-haystack 5.2.0__tar.gz → 5.3.0__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.
Files changed (28) hide show
  1. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/CHANGELOG.md +13 -0
  2. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/PKG-INFO +7 -25
  3. pgvector_haystack-5.3.0/README.md +18 -0
  4. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/examples/embedding_retrieval.py +1 -1
  5. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/examples/hybrid_retrieval.py +1 -1
  6. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/src/haystack_integrations/document_stores/pgvector/document_store.py +34 -0
  7. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/tests/test_document_store.py +16 -0
  8. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/tests/test_document_store_async.py +17 -0
  9. pgvector_haystack-5.2.0/README.md +0 -36
  10. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/.gitignore +0 -0
  11. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/LICENSE.txt +0 -0
  12. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/pydoc/config.yml +0 -0
  13. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/pyproject.toml +0 -0
  14. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/src/haystack_integrations/components/retrievers/pgvector/__init__.py +0 -0
  15. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/src/haystack_integrations/components/retrievers/pgvector/embedding_retriever.py +0 -0
  16. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/src/haystack_integrations/components/retrievers/pgvector/keyword_retriever.py +0 -0
  17. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/src/haystack_integrations/components/retrievers/py.typed +0 -0
  18. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/src/haystack_integrations/document_stores/pgvector/__init__.py +0 -0
  19. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/src/haystack_integrations/document_stores/pgvector/converters.py +0 -0
  20. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/src/haystack_integrations/document_stores/pgvector/filters.py +0 -0
  21. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/src/haystack_integrations/document_stores/py.typed +0 -0
  22. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/tests/__init__.py +0 -0
  23. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/tests/conftest.py +0 -0
  24. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/tests/test_converters.py +0 -0
  25. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/tests/test_filters.py +0 -0
  26. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/tests/test_retrieval.py +0 -0
  27. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/tests/test_retrieval_async.py +0 -0
  28. {pgvector_haystack-5.2.0 → pgvector_haystack-5.3.0}/tests/test_retrievers.py +0 -0
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/pgvector-v5.2.1] - 2025-07-03
4
+
5
+ ### 🐛 Bug Fixes
6
+
7
+ - Pgvector - ensure DB is initialized when calling `delete_table` (#2055)
8
+
9
+
10
+ ### 🧹 Chores
11
+
12
+ - Remove black (#1985)
13
+ - Pgvector - update docker image in examples (#1995)
14
+
15
+
3
16
  ## [integrations/pgvector-v3.4.1] - 2025-06-20
4
17
 
5
18
  ### 🐛 Bug Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pgvector-haystack
3
- Version: 5.2.0
3
+ Version: 5.3.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
@@ -29,34 +29,16 @@ Description-Content-Type: text/markdown
29
29
  [![PyPI - Version](https://img.shields.io/pypi/v/pgvector-haystack.svg)](https://pypi.org/project/pgvector-haystack)
30
30
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pgvector-haystack.svg)](https://pypi.org/project/pgvector-haystack)
31
31
 
32
- ---
32
+ - [Integration page](https://haystack.deepset.ai/integrations/pgvector-documentstore)
33
+ - [Changelog](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/pgvector/CHANGELOG.md)
33
34
 
34
- **Table of Contents**
35
+ ---
35
36
 
36
- - [pgvector-haystack](#pgvector-haystack)
37
- - [Installation](#installation)
38
- - [Testing](#testing)
39
- - [License](#license)
37
+ Refer to the general [Contribution Guidelines](https://github.com/deepset-ai/haystack-core-integrations/blob/main/CONTRIBUTING.md).
40
38
 
41
- ## Installation
39
+ To run integration tests locally, you need to have a PostgreSQL DB running with the `pgvector` extension.
40
+ You can start it using Docker:
42
41
 
43
42
  ```console
44
- pip install pgvector-haystack
45
- ```
46
-
47
- ## Testing
48
-
49
- Ensure that you have a PostgreSQL running with the `pgvector` extension. For a quick setup using Docker, run:
50
- ```
51
43
  docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres pgvector/pgvector:pg17
52
44
  ```
53
-
54
- then run the tests:
55
-
56
- ```console
57
- hatch run test:all
58
- ```
59
-
60
- ## License
61
-
62
- `pgvector-haystack` is distributed under the terms of the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) license.
@@ -0,0 +1,18 @@
1
+ # pgvector-haystack
2
+
3
+ [![PyPI - Version](https://img.shields.io/pypi/v/pgvector-haystack.svg)](https://pypi.org/project/pgvector-haystack)
4
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pgvector-haystack.svg)](https://pypi.org/project/pgvector-haystack)
5
+
6
+ - [Integration page](https://haystack.deepset.ai/integrations/pgvector-documentstore)
7
+ - [Changelog](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/pgvector/CHANGELOG.md)
8
+
9
+ ---
10
+
11
+ Refer to the general [Contribution Guidelines](https://github.com/deepset-ai/haystack-core-integrations/blob/main/CONTRIBUTING.md).
12
+
13
+ To run integration tests locally, you need to have a PostgreSQL DB running with the `pgvector` extension.
14
+ You can start it using Docker:
15
+
16
+ ```console
17
+ docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres pgvector/pgvector:pg17
18
+ ```
@@ -1,7 +1,7 @@
1
1
  # Before running this example, ensure you have PostgreSQL installed with the pgvector extension.
2
2
  # For a quick setup using Docker:
3
3
  # docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres
4
- # -e POSTGRES_DB=postgres ankane/pgvector
4
+ # -e POSTGRES_DB=postgres pgvector/pgvector:pg17
5
5
 
6
6
  # Install required packages for this example, including pgvector-haystack and other libraries needed
7
7
  # for Markdown conversion and embeddings generation. Use the following command:
@@ -1,7 +1,7 @@
1
1
  # Before running this example, ensure you have PostgreSQL installed with the pgvector extension.
2
2
  # For a quick setup using Docker:
3
3
  # docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres
4
- # -e POSTGRES_DB=postgres ankane/pgvector
4
+ # -e POSTGRES_DB=postgres pgvector/pgvector:pg17
5
5
 
6
6
  # Install required packages for this example, including pgvector-haystack and other libraries needed
7
7
  # for Markdown conversion and embeddings generation. Use the following command:
@@ -534,6 +534,7 @@ class PgvectorDocumentStore:
534
534
  The name of the schema (`schema_name`) and the name of the table (`table_name`)
535
535
  are defined when initializing the `PgvectorDocumentStore`.
536
536
  """
537
+ self._ensure_db_setup()
537
538
  delete_sql = SQL("DROP TABLE IF EXISTS {schema_name}.{table_name}").format(
538
539
  schema_name=Identifier(self.schema_name),
539
540
  table_name=Identifier(self.table_name),
@@ -551,6 +552,7 @@ class PgvectorDocumentStore:
551
552
  """
552
553
  Async method to delete the table used to store Haystack documents.
553
554
  """
555
+ await self._ensure_db_setup_async()
554
556
  delete_sql = SQL("DROP TABLE IF EXISTS {schema_name}.{table_name}").format(
555
557
  schema_name=Identifier(self.schema_name),
556
558
  table_name=Identifier(self.table_name),
@@ -985,6 +987,38 @@ class PgvectorDocumentStore:
985
987
  error_msg="Could not delete documents from PgvectorDocumentStore",
986
988
  )
987
989
 
990
+ def delete_all_documents(self) -> None:
991
+ """
992
+ Deletes all documents in the document store.
993
+ """
994
+ query = SQL("TRUNCATE TABLE {schema_name}.{table_name}").format(
995
+ schema_name=Identifier(self.schema_name),
996
+ table_name=Identifier(self.table_name),
997
+ )
998
+
999
+ self._ensure_db_setup()
1000
+ assert self._cursor is not None
1001
+ self._execute_sql(
1002
+ cursor=self._cursor, sql_query=query, error_msg="Could not delete all documents from PgvectorDocumentStore"
1003
+ )
1004
+
1005
+ async def delete_all_documents_async(self) -> None:
1006
+ """
1007
+ Asynchronously deletes all documents in the document store.
1008
+ """
1009
+ query = SQL("TRUNCATE TABLE {schema_name}.{table_name}").format(
1010
+ schema_name=Identifier(self.schema_name),
1011
+ table_name=Identifier(self.table_name),
1012
+ )
1013
+
1014
+ await self._ensure_db_setup_async()
1015
+ assert self._async_cursor is not None
1016
+ await self._execute_sql_async(
1017
+ cursor=self._async_cursor,
1018
+ sql_query=query,
1019
+ error_msg="Could not delete all documents from PgvectorDocumentStore",
1020
+ )
1021
+
988
1022
  def _build_keyword_retrieval_query(
989
1023
  self, query: str, top_k: int, filters: Optional[Dict[str, Any]] = None
990
1024
  ) -> Tuple[Composed, tuple]:
@@ -53,6 +53,13 @@ class TestDocumentStore(CountDocumentsTest, WriteDocumentsTest, DeleteDocumentsT
53
53
  same_connection = document_store._connection
54
54
  assert same_connection is document_store._connection
55
55
 
56
+ def test_delete_all_documents(self, document_store: PgvectorDocumentStore) -> None:
57
+ document_store.write_documents([Document(id=str(i)) for i in range(10)])
58
+ document_store.delete_all_documents()
59
+ assert document_store.count_documents() == 0
60
+ document_store.write_documents([Document(id="1")])
61
+ assert document_store.count_documents() == 1
62
+
56
63
 
57
64
  @pytest.mark.usefixtures("patches_for_unit_tests")
58
65
  def test_init(monkeypatch):
@@ -237,3 +244,12 @@ def test_create_table_if_not_exists():
237
244
  # Clean up: drop the schema after the test
238
245
  with psycopg.connect(connection_string, autocommit=True) as conn:
239
246
  conn.execute(f"DROP SCHEMA IF EXISTS {schema_name} CASCADE")
247
+
248
+
249
+ @pytest.mark.integration
250
+ def test_delete_table_first_call(document_store):
251
+ """
252
+ Test that delete_table can be executed as the initial operation on the Document Store
253
+ without triggering errors due to an uninitialized state.
254
+ """
255
+ document_store.delete_table() # if throw error, test fails
@@ -94,6 +94,13 @@ class TestDocumentStoreAsync:
94
94
  same_connection = document_store._async_connection
95
95
  assert same_connection is document_store._async_connection
96
96
 
97
+ async def test_delete_all_documents_async(self, document_store: PgvectorDocumentStore) -> None:
98
+ document_store.write_documents([Document(id=str(i)) for i in range(10)])
99
+ await document_store.delete_all_documents_async()
100
+ assert document_store.count_documents() == 0
101
+ document_store.write_documents([Document(id="1")])
102
+ assert document_store.count_documents() == 1
103
+
97
104
 
98
105
  @pytest.mark.integration
99
106
  @pytest.mark.asyncio
@@ -206,3 +213,13 @@ async def test_create_table_if_not_exists():
206
213
  # Clean up: drop the schema after the test
207
214
  async with await psycopg.AsyncConnection.connect(connection_string, autocommit=True) as conn:
208
215
  await conn.execute(f"DROP SCHEMA IF EXISTS {schema_name} CASCADE")
216
+
217
+
218
+ @pytest.mark.integration
219
+ @pytest.mark.asyncio
220
+ async def test_delete_table_async_first_call(document_store):
221
+ """
222
+ Test that delete_table_async can be executed as the initial operation on the Document Store
223
+ without triggering errors due to an uninitialized state.
224
+ """
225
+ await document_store.delete_table_async() # if throw error, test fails
@@ -1,36 +0,0 @@
1
- # pgvector-haystack
2
-
3
- [![PyPI - Version](https://img.shields.io/pypi/v/pgvector-haystack.svg)](https://pypi.org/project/pgvector-haystack)
4
- [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pgvector-haystack.svg)](https://pypi.org/project/pgvector-haystack)
5
-
6
- ---
7
-
8
- **Table of Contents**
9
-
10
- - [pgvector-haystack](#pgvector-haystack)
11
- - [Installation](#installation)
12
- - [Testing](#testing)
13
- - [License](#license)
14
-
15
- ## Installation
16
-
17
- ```console
18
- pip install pgvector-haystack
19
- ```
20
-
21
- ## Testing
22
-
23
- Ensure that you have a PostgreSQL running with the `pgvector` extension. For a quick setup using Docker, run:
24
- ```
25
- docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres pgvector/pgvector:pg17
26
- ```
27
-
28
- then run the tests:
29
-
30
- ```console
31
- hatch run test:all
32
- ```
33
-
34
- ## License
35
-
36
- `pgvector-haystack` is distributed under the terms of the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) license.