pgvector 0.4.0__tar.gz → 0.4.1__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-0.4.0 → pgvector-0.4.1}/PKG-INFO +4 -2
- {pgvector-0.4.0 → pgvector-0.4.1}/README.md +1 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/sparsevec.py +1 -1
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector.egg-info/PKG-INFO +4 -2
- {pgvector-0.4.0 → pgvector-0.4.1}/pyproject.toml +1 -1
- {pgvector-0.4.0 → pgvector-0.4.1}/tests/test_sparse_vector.py +19 -1
- {pgvector-0.4.0 → pgvector-0.4.1}/tests/test_sqlalchemy.py +2 -2
- {pgvector-0.4.0 → pgvector-0.4.1}/LICENSE.txt +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/__init__.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/asyncpg/__init__.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/asyncpg/register.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/bit.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/django/__init__.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/django/bit.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/django/extensions.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/django/functions.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/django/halfvec.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/django/indexes.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/django/sparsevec.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/django/vector.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/halfvec.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/peewee/__init__.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/peewee/bit.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/peewee/halfvec.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/peewee/sparsevec.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/peewee/vector.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/pg8000/__init__.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/pg8000/register.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/psycopg/__init__.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/psycopg/bit.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/psycopg/halfvec.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/psycopg/register.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/psycopg/sparsevec.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/psycopg/vector.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/psycopg2/__init__.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/psycopg2/halfvec.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/psycopg2/register.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/psycopg2/sparsevec.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/psycopg2/vector.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/sqlalchemy/__init__.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/sqlalchemy/bit.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/sqlalchemy/functions.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/sqlalchemy/halfvec.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/sqlalchemy/sparsevec.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/sqlalchemy/vector.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/utils/__init__.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector/vector.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector.egg-info/SOURCES.txt +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector.egg-info/dependency_links.txt +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector.egg-info/requires.txt +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/pgvector.egg-info/top_level.txt +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/setup.cfg +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/tests/test_asyncpg.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/tests/test_bit.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/tests/test_django.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/tests/test_half_vector.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/tests/test_peewee.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/tests/test_pg8000.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/tests/test_psycopg.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/tests/test_psycopg2.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/tests/test_sqlmodel.py +0 -0
- {pgvector-0.4.0 → pgvector-0.4.1}/tests/test_vector.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pgvector
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: pgvector support for Python
|
|
5
5
|
Author-email: Andrew Kane <andrew@ankane.org>
|
|
6
6
|
License: MIT
|
|
@@ -9,6 +9,7 @@ Requires-Python: >=3.9
|
|
|
9
9
|
Description-Content-Type: text/markdown
|
|
10
10
|
License-File: LICENSE.txt
|
|
11
11
|
Requires-Dist: numpy
|
|
12
|
+
Dynamic: license-file
|
|
12
13
|
|
|
13
14
|
# pgvector-python
|
|
14
15
|
|
|
@@ -39,6 +40,7 @@ And follow the instructions for your database library:
|
|
|
39
40
|
|
|
40
41
|
Or check out some examples:
|
|
41
42
|
|
|
43
|
+
- [Retrieval-augmented generation](https://github.com/pgvector/pgvector-python/blob/master/examples/rag/example.py) with Ollama
|
|
42
44
|
- [Embeddings](https://github.com/pgvector/pgvector-python/blob/master/examples/openai/example.py) with OpenAI
|
|
43
45
|
- [Binary embeddings](https://github.com/pgvector/pgvector-python/blob/master/examples/cohere/example.py) with Cohere
|
|
44
46
|
- [Sentence embeddings](https://github.com/pgvector/pgvector-python/blob/master/examples/sentence_transformers/example.py) with SentenceTransformers
|
|
@@ -27,6 +27,7 @@ And follow the instructions for your database library:
|
|
|
27
27
|
|
|
28
28
|
Or check out some examples:
|
|
29
29
|
|
|
30
|
+
- [Retrieval-augmented generation](https://github.com/pgvector/pgvector-python/blob/master/examples/rag/example.py) with Ollama
|
|
30
31
|
- [Embeddings](https://github.com/pgvector/pgvector-python/blob/master/examples/openai/example.py) with OpenAI
|
|
31
32
|
- [Binary embeddings](https://github.com/pgvector/pgvector-python/blob/master/examples/cohere/example.py) with Cohere
|
|
32
33
|
- [Sentence embeddings](https://github.com/pgvector/pgvector-python/blob/master/examples/sentence_transformers/example.py) with SentenceTransformers
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pgvector
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: pgvector support for Python
|
|
5
5
|
Author-email: Andrew Kane <andrew@ankane.org>
|
|
6
6
|
License: MIT
|
|
@@ -9,6 +9,7 @@ Requires-Python: >=3.9
|
|
|
9
9
|
Description-Content-Type: text/markdown
|
|
10
10
|
License-File: LICENSE.txt
|
|
11
11
|
Requires-Dist: numpy
|
|
12
|
+
Dynamic: license-file
|
|
12
13
|
|
|
13
14
|
# pgvector-python
|
|
14
15
|
|
|
@@ -39,6 +40,7 @@ And follow the instructions for your database library:
|
|
|
39
40
|
|
|
40
41
|
Or check out some examples:
|
|
41
42
|
|
|
43
|
+
- [Retrieval-augmented generation](https://github.com/pgvector/pgvector-python/blob/master/examples/rag/example.py) with Ollama
|
|
42
44
|
- [Embeddings](https://github.com/pgvector/pgvector-python/blob/master/examples/openai/example.py) with OpenAI
|
|
43
45
|
- [Binary embeddings](https://github.com/pgvector/pgvector-python/blob/master/examples/cohere/example.py) with Cohere
|
|
44
46
|
- [Sentence embeddings](https://github.com/pgvector/pgvector-python/blob/master/examples/sentence_transformers/example.py) with SentenceTransformers
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
from pgvector import SparseVector
|
|
3
3
|
import pytest
|
|
4
|
-
from scipy.sparse import coo_array
|
|
4
|
+
from scipy.sparse import coo_array, coo_matrix, csr_array, csr_matrix
|
|
5
5
|
from struct import pack
|
|
6
6
|
|
|
7
7
|
|
|
@@ -43,12 +43,30 @@ class TestSparseVector:
|
|
|
43
43
|
SparseVector(coo_array(np.array([1, 0, 2, 0, 3, 0])), 6)
|
|
44
44
|
assert str(error.value) == 'extra argument'
|
|
45
45
|
|
|
46
|
+
def test_coo_matrix(self):
|
|
47
|
+
mat = coo_matrix(np.array([1, 0, 2, 0, 3, 0]))
|
|
48
|
+
vec = SparseVector(mat)
|
|
49
|
+
assert vec.to_list() == [1, 0, 2, 0, 3, 0]
|
|
50
|
+
assert vec.indices() == [0, 2, 4]
|
|
51
|
+
|
|
46
52
|
def test_dok_array(self):
|
|
47
53
|
arr = coo_array(np.array([1, 0, 2, 0, 3, 0])).todok()
|
|
48
54
|
vec = SparseVector(arr)
|
|
49
55
|
assert vec.to_list() == [1, 0, 2, 0, 3, 0]
|
|
50
56
|
assert vec.indices() == [0, 2, 4]
|
|
51
57
|
|
|
58
|
+
def test_csr_array(self):
|
|
59
|
+
arr = csr_array(np.array([[1, 0, 2, 0, 3, 0]]))
|
|
60
|
+
vec = SparseVector(arr)
|
|
61
|
+
assert vec.to_list() == [1, 0, 2, 0, 3, 0]
|
|
62
|
+
assert vec.indices() == [0, 2, 4]
|
|
63
|
+
|
|
64
|
+
def test_csr_matrix(self):
|
|
65
|
+
mat = csr_matrix(np.array([1, 0, 2, 0, 3, 0]))
|
|
66
|
+
vec = SparseVector(mat)
|
|
67
|
+
assert vec.to_list() == [1, 0, 2, 0, 3, 0]
|
|
68
|
+
assert vec.indices() == [0, 2, 4]
|
|
69
|
+
|
|
52
70
|
def test_repr(self):
|
|
53
71
|
assert repr(SparseVector([1, 0, 2, 0, 3, 0])) == 'SparseVector({0: 1.0, 2: 2.0, 4: 3.0}, 6)'
|
|
54
72
|
assert str(SparseVector([1, 0, 2, 0, 3, 0])) == 'SparseVector({0: 1.0, 2: 2.0, 4: 3.0}, 6)'
|
|
@@ -43,7 +43,7 @@ if sqlalchemy_version > 1:
|
|
|
43
43
|
psycopg_async_type_engine = create_async_engine('postgresql+psycopg://localhost/pgvector_python_test')
|
|
44
44
|
|
|
45
45
|
@event.listens_for(psycopg_async_type_engine.sync_engine, "connect")
|
|
46
|
-
def
|
|
46
|
+
def psycopg_async_connect(dbapi_connection, connection_record):
|
|
47
47
|
from pgvector.psycopg import register_vector_async
|
|
48
48
|
dbapi_connection.run_async(register_vector_async)
|
|
49
49
|
|
|
@@ -51,7 +51,7 @@ if sqlalchemy_version > 1:
|
|
|
51
51
|
asyncpg_type_engine = create_async_engine('postgresql+asyncpg://localhost/pgvector_python_test')
|
|
52
52
|
|
|
53
53
|
@event.listens_for(asyncpg_type_engine.sync_engine, "connect")
|
|
54
|
-
def
|
|
54
|
+
def asyncpg_connect(dbapi_connection, connection_record):
|
|
55
55
|
from pgvector.asyncpg import register_vector
|
|
56
56
|
dbapi_connection.run_async(register_vector)
|
|
57
57
|
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|