
    Ng
                     2    d dl mZ dZ G d de          ZdS )    )
Neo4jGraphz.
CALL llm_util.schema("raw")
YIELD *
RETURN *
c                   F     e Zd ZdZdddededededd	f
 fd
ZddZ xZS )MemgraphGrapha  Memgraph wrapper for graph operations.

    *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.
    memgraphdatabaseurlusernamepasswordr   returnNc                R    t                                          ||||           dS )z-Create a new Memgraph graph wrapper instance.r   N)super__init__)selfr	   r
   r   r   	__class__s        e/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/graphs/memgraph_graph.pyr   zMemgraphGraph.__init__   s,     	h8DDDDD    c                    |                      t                    d                             d          }|J || _        g }|d                                         D ] \  }}|                    d| d|            !g }|d                                         D ] \  }}|                    d| d	|            !d
 |d         D             }d                    dg|d|d|          | _        dS )zB
        Refreshes the Memgraph graph schema information.
        r   schemaN
node_propszNode name: 'z', Node properties: 	rel_propszRelationship name: 'z', Relationship properties: c           	      J    g | ] }d |d          d|d          d|d          d!S )z(:startz)-[:typez]->(:end) ).0rels     r   
<listcomp>z0MemgraphGraph.refresh_schema.<locals>.<listcomp>9   sP     
 
 
 CWBB3v;BBSZBBB
 
 
r   relationships
z"Node properties are the following:z*Relationship properties are the following:z$The relationships are the following:)querySCHEMA_QUERYgetstructured_schemaitemsappendjoinr   )r   db_structured_schemaformatted_node_props	node_name
propertiesformatted_rel_propsrel_nameformatted_relss           r   refresh_schemazMemgraphGraph.refresh_schema   sx   
  $zz,77:>>xHH#///!5  "%9,%G%M%M%O%O 	 	!Iz ''JyJJjJJ   
 !$8$E$K$K$M$M 	 	 Hj&&9x 9 9,69 9   
 
+O<
 
 

 ii4% = %	
 7  	
 	
r   )r   N)__name__
__module____qualname____doc__strr   r1   __classcell__)r   s   @r   r   r   
   s          JTE E EE"%E14ECFE	E E E E E E(
 (
 (
 (
 (
 (
 (
 (
r   r   N)&langchain_community.graphs.neo4j_graphr   r$   r   r   r   r   <module>r9      sR    = = = = = ==
 =
 =
 =
 =
J =
 =
 =
 =
 =
r   