llama-index-vector-stores-postgres 0.2.4__tar.gz → 0.2.6__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.
- {llama_index_vector_stores_postgres-0.2.4 → llama_index_vector_stores_postgres-0.2.6}/PKG-INFO +1 -1
- {llama_index_vector_stores_postgres-0.2.4 → llama_index_vector_stores_postgres-0.2.6}/llama_index/vector_stores/postgres/base.py +61 -0
- {llama_index_vector_stores_postgres-0.2.4 → llama_index_vector_stores_postgres-0.2.6}/pyproject.toml +3 -7
- {llama_index_vector_stores_postgres-0.2.4 → llama_index_vector_stores_postgres-0.2.6}/README.md +0 -0
- {llama_index_vector_stores_postgres-0.2.4 → llama_index_vector_stores_postgres-0.2.6}/llama_index/py.typed +0 -0
- {llama_index_vector_stores_postgres-0.2.4 → llama_index_vector_stores_postgres-0.2.6}/llama_index/vector_stores/postgres/__init__.py +0 -0
|
@@ -462,6 +462,8 @@ class PGVectorStore(BasePydanticVectorStore):
|
|
|
462
462
|
return "NOT IN"
|
|
463
463
|
elif operator == FilterOperator.CONTAINS:
|
|
464
464
|
return "@>"
|
|
465
|
+
elif operator == FilterOperator.TEXT_MATCH:
|
|
466
|
+
return "LIKE"
|
|
465
467
|
else:
|
|
466
468
|
_logger.warning(f"Unknown operator: {operator}, fallback to '='")
|
|
467
469
|
return "="
|
|
@@ -488,6 +490,13 @@ class PGVectorStore(BasePydanticVectorStore):
|
|
|
488
490
|
f"{self._to_postgres_operator(filter_.operator)} "
|
|
489
491
|
f"'[\"{filter_.value}\"]'"
|
|
490
492
|
)
|
|
493
|
+
elif filter_.operator == FilterOperator.TEXT_MATCH:
|
|
494
|
+
# Where the operator is text_match, we need to wrap the filter in '%' characters
|
|
495
|
+
return text(
|
|
496
|
+
f"metadata_->>'{filter_.key}' "
|
|
497
|
+
f"{self._to_postgres_operator(filter_.operator)} "
|
|
498
|
+
f"'%{filter_.value}%'"
|
|
499
|
+
)
|
|
491
500
|
else:
|
|
492
501
|
# Check if value is a number. If so, cast the metadata value to a float
|
|
493
502
|
# This is necessary because the metadata is stored as a string
|
|
@@ -944,6 +953,58 @@ class PGVectorStore(BasePydanticVectorStore):
|
|
|
944
953
|
await async_session.execute(stmt)
|
|
945
954
|
await async_session.commit()
|
|
946
955
|
|
|
956
|
+
def get_nodes(
|
|
957
|
+
self,
|
|
958
|
+
node_ids: Optional[List[str]] = None,
|
|
959
|
+
filters: Optional[MetadataFilters] = None,
|
|
960
|
+
) -> List[BaseNode]:
|
|
961
|
+
"""Get nodes from vector store."""
|
|
962
|
+
assert (
|
|
963
|
+
node_ids is not None or filters is not None
|
|
964
|
+
), "Either node_ids or filters must be provided"
|
|
965
|
+
|
|
966
|
+
self._initialize()
|
|
967
|
+
from sqlalchemy import select
|
|
968
|
+
|
|
969
|
+
stmt = select(
|
|
970
|
+
self._table_class.node_id,
|
|
971
|
+
self._table_class.text,
|
|
972
|
+
self._table_class.metadata_,
|
|
973
|
+
self._table_class.embedding,
|
|
974
|
+
)
|
|
975
|
+
|
|
976
|
+
if node_ids:
|
|
977
|
+
stmt = stmt.where(self._table_class.node_id.in_(node_ids))
|
|
978
|
+
|
|
979
|
+
if filters:
|
|
980
|
+
filter_clause = self._recursively_apply_filters(filters)
|
|
981
|
+
stmt = stmt.where(filter_clause)
|
|
982
|
+
|
|
983
|
+
nodes: List[BaseNode] = []
|
|
984
|
+
|
|
985
|
+
with self._session() as session, session.begin():
|
|
986
|
+
res = session.execute(stmt).fetchall()
|
|
987
|
+
for item in res:
|
|
988
|
+
node_id = item.node_id
|
|
989
|
+
text = item.text
|
|
990
|
+
metadata = item.metadata_
|
|
991
|
+
embedding = item.embedding
|
|
992
|
+
|
|
993
|
+
try:
|
|
994
|
+
node = metadata_dict_to_node(metadata)
|
|
995
|
+
node.set_content(str(text))
|
|
996
|
+
node.embedding = embedding
|
|
997
|
+
except Exception:
|
|
998
|
+
node = TextNode(
|
|
999
|
+
id_=node_id,
|
|
1000
|
+
text=text,
|
|
1001
|
+
metadata=metadata,
|
|
1002
|
+
embedding=embedding,
|
|
1003
|
+
)
|
|
1004
|
+
nodes.append(node)
|
|
1005
|
+
|
|
1006
|
+
return nodes
|
|
1007
|
+
|
|
947
1008
|
|
|
948
1009
|
def _dedup_results(results: List[DBEmbeddingRow]) -> List[DBEmbeddingRow]:
|
|
949
1010
|
seen_ids = set()
|
{llama_index_vector_stores_postgres-0.2.4 → llama_index_vector_stores_postgres-0.2.6}/pyproject.toml
RENAMED
|
@@ -27,7 +27,7 @@ exclude = ["**/BUILD"]
|
|
|
27
27
|
license = "MIT"
|
|
28
28
|
name = "llama-index-vector-stores-postgres"
|
|
29
29
|
readme = "README.md"
|
|
30
|
-
version = "0.2.
|
|
30
|
+
version = "0.2.6"
|
|
31
31
|
|
|
32
32
|
[tool.poetry.dependencies]
|
|
33
33
|
python = ">=3.8.1,<4.0"
|
|
@@ -70,9 +70,5 @@ include = "llama_index/"
|
|
|
70
70
|
|
|
71
71
|
[tool.pytest.ini_options]
|
|
72
72
|
asyncio_mode = "auto"
|
|
73
|
-
filterwarnings = [
|
|
74
|
-
|
|
75
|
-
]
|
|
76
|
-
markers = [
|
|
77
|
-
"asyncio",
|
|
78
|
-
]
|
|
73
|
+
filterwarnings = ["ignore::DeprecationWarning:"]
|
|
74
|
+
markers = ["asyncio"]
|
{llama_index_vector_stores_postgres-0.2.4 → llama_index_vector_stores_postgres-0.2.6}/README.md
RENAMED
|
File without changes
|
|
File without changes
|