core,community: add beta decorator to missed GraphVectorStore extensions (#25562)

This commit is contained in:
Erick Friis
2024-08-19 17:29:09 -07:00
committed by GitHub
parent dd2d094adc
commit e01c6789c4
10 changed files with 23 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ def _has_next(iterator: Iterator) -> bool:
return next(iterator, sentinel) is not sentinel
@beta()
class Node(Serializable):
"""Node in the GraphVectorStore.
@@ -115,6 +116,7 @@ def _documents_to_nodes(documents: Iterable[Document]) -> Iterator[Node]:
)
@beta()
def nodes_to_documents(nodes: Iterable[Node]) -> Iterator[Document]:
for node in nodes:
metadata = node.metadata.copy()

View File

@@ -1,9 +1,11 @@
from dataclasses import dataclass
from typing import Iterable, List, Literal, Union
from langchain_core._api import beta
from langchain_core.documents import Document
@beta()
@dataclass(frozen=True)
class Link:
"""A link to/from a tag of a given tag.
@@ -38,6 +40,7 @@ class Link:
METADATA_LINKS_KEY = "links"
@beta()
def get_links(doc: Document) -> List[Link]:
"""Get the links from a document.
Args:
@@ -54,6 +57,7 @@ def get_links(doc: Document) -> List[Link]:
return links
@beta()
def add_links(doc: Document, *links: Union[Link, Iterable[Link]]) -> None:
"""Add links to the given metadata.
Args:
@@ -68,6 +72,7 @@ def add_links(doc: Document, *links: Union[Link, Iterable[Link]]) -> None:
links_in_metadata.append(link)
@beta()
def copy_with_links(doc: Document, *links: Union[Link, Iterable[Link]]) -> Document:
"""Return a document with the given links added.