llama-index-vector-stores-postgres 0.2.4__tar.gz → 0.2.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: llama-index-vector-stores-postgres
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: llama-index vector_stores postgres integration
5
5
  License: MIT
6
6
  Author: Your Name
@@ -944,6 +944,58 @@ class PGVectorStore(BasePydanticVectorStore):
944
944
  await async_session.execute(stmt)
945
945
  await async_session.commit()
946
946
 
947
+ def get_nodes(
948
+ self,
949
+ node_ids: Optional[List[str]] = None,
950
+ filters: Optional[MetadataFilters] = None,
951
+ ) -> List[BaseNode]:
952
+ """Get nodes from vector store."""
953
+ assert (
954
+ node_ids is not None or filters is not None
955
+ ), "Either node_ids or filters must be provided"
956
+
957
+ self._initialize()
958
+ from sqlalchemy import select
959
+
960
+ stmt = select(
961
+ self._table_class.node_id,
962
+ self._table_class.text,
963
+ self._table_class.metadata_,
964
+ self._table_class.embedding,
965
+ )
966
+
967
+ if node_ids:
968
+ stmt = stmt.where(self._table_class.node_id.in_(node_ids))
969
+
970
+ if filters:
971
+ filter_clause = self._recursively_apply_filters(filters)
972
+ stmt = stmt.where(filter_clause)
973
+
974
+ nodes: List[BaseNode] = []
975
+
976
+ with self._session() as session, session.begin():
977
+ res = session.execute(stmt).fetchall()
978
+ for item in res:
979
+ node_id = item.node_id
980
+ text = item.text
981
+ metadata = item.metadata_
982
+ embedding = item.embedding
983
+
984
+ try:
985
+ node = metadata_dict_to_node(metadata)
986
+ node.set_content(str(text))
987
+ node.embedding = embedding
988
+ except Exception:
989
+ node = TextNode(
990
+ id_=node_id,
991
+ text=text,
992
+ metadata=metadata,
993
+ embedding=embedding,
994
+ )
995
+ nodes.append(node)
996
+
997
+ return nodes
998
+
947
999
 
948
1000
  def _dedup_results(results: List[DBEmbeddingRow]) -> List[DBEmbeddingRow]:
949
1001
  seen_ids = set()
@@ -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.4"
30
+ version = "0.2.5"
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
- "ignore::DeprecationWarning:",
75
- ]
76
- markers = [
77
- "asyncio",
78
- ]
73
+ filterwarnings = ["ignore::DeprecationWarning:"]
74
+ markers = ["asyncio"]