AGEGraph#
- class langchain_community.graphs.age_graph.AGEGraph(graph_name: str, conf: Dict[str, Any], create: bool = True)[source]#
Apache AGE wrapper for graph operations.
- Parameters:
graph_name (str) โ the name of the graph to connect to or create
conf (Dict[str, Any]) โ the pgsql connection config passed directly to psycopg2.connect
create (bool) โ if True and graph doesnโt exist, attempt to create it
- Security note: Make sure that the database connection uses credentials
that are narrowly-scoped to only include necessary permissions. Failure to do so may result in data corruption or loss, since the calling code may attempt commands that would result in deletion, mutation of data if appropriately prompted or reading sensitive data if such data is present in the database. The best way to guard against such negative outcomes is to (as appropriate) limit the permissions granted to the credentials used with this tool.
See https://python.langchain.com/docs/security for more information.
Create a new AGEGraph instance.
Attributes
get_schema
Returns the schema of the Graph
get_structured_schema
Returns the structured schema of the Graph
label_regex
types
Methods
__init__
(graph_name,ย conf[,ย create])Create a new AGEGraph instance.
add_graph_documents
(graph_documents[,ย ...])insert a list of graph documents into the graph
clean_graph_labels
(label)remove any disallowed characters from a label and replace with '_'
query
(query[,ย params])Query the graph by taking a cypher query, converting it to an age compatible query, executing it and converting the result
Refresh the graph schema information by updating the available labels, relationships, and properties
- __init__(graph_name: str, conf: Dict[str, Any], create: bool = True) None [source]#
Create a new AGEGraph instance.
- Parameters:
graph_name (str)
conf (Dict[str, Any])
create (bool)
- Return type:
None
- add_graph_documents(graph_documents: List[GraphDocument], include_source: bool = False) None [source]#
insert a list of graph documents into the graph
- Parameters:
graph_documents (List[GraphDocument]) โ the list of documents to be inserted
include_source (bool) โ if True add nodes for the sources with MENTIONS edges to the entities they mention
- Returns:
None
- Return type:
None
- static clean_graph_labels(label: str) str [source]#
remove any disallowed characters from a label and replace with โ_โ
- Parameters:
label (str) โ the original label
- Returns:
the sanitized version of the label
- Return type:
str
- query(query: str, params: dict = {}) List[Dict[str, Any]] [source]#
Query the graph by taking a cypher query, converting it to an age compatible query, executing it and converting the result
- Parameters:
query (str) โ a cypher query to be executed
params (dict) โ parameters for the query (not used in this implementation)
- Returns:
a list of dictionaries containing the result set
- Return type:
List[Dict[str, Any]]
Examples using AGEGraph