
    Ng	                     4    d dl mZmZmZ  G d d          ZdS )    )AnyDictListc                       e Zd ZdZ	 	 	 	 	 ddededed	ed
eddfdZedefd            ZddZ	dede
eeef                  fdZdS )	HugeGrapha  HugeGraph 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.
    default	127.0.0.1  	hugegraphusernamepasswordaddressportgraphreturnNc                 @   	 ddl m} n# t          $ r t          d          w xY w|| _        || _        || _        || _        || _         ||||||          | _        d| _	        	 | 
                                 dS # t          $ r}t          d|           d}~ww xY w)z(Create a new HugeGraph wrapper instance.r   )PyHugeGraphzMPlease install HugeGraph Python client first: `pip3 install hugegraph-python`)userpwdr    z!Could not refresh schema. Error: N)hugegraph.connectionr   ImportErrorr   r   r   r   r   clientschemarefresh_schema	Exception
ValueError)selfr   r   r   r   r   r   es           `/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/graphs/hugegraph.py__init__zHugeGraph.__init__   s    	8888888 	 	 	2  	 ! 	
!kThe
 
 
 	F!!!!! 	F 	F 	FDDDEEE	Fs    	 #&A< <
BBBc                     | j         S )z,Returns the schema of the HugeGraph database)r   )r   s    r    
get_schemazHugeGraph.get_schema3   s     {    c                     | j                                         }|                                }|                                }|                                }d| d| d| d| _        dS )z=
        Refreshes the HugeGraph schema information.
        zNode properties: z
Edge properties: z
Relationships: 
N)r   r   getVertexLabelsgetEdgeLabelsgetRelations)r   r   vertex_schemaedge_schemarelationshipss        r    r   zHugeGraph.refresh_schema8   s     ##%%..00**,,++--0 0 0 +0 0+0 0 0 	r$   queryc                 n    | j                                         }|                    |          }|d         S )Ndata)r   gremlinexec)r   r-   gress       r    r-   zHugeGraph.queryG   s.    K!!ffUmm6{r$   )r   r   r	   r
   r   )r   N)__name__
__module____qualname____doc__strintr!   propertyr#   r   r   r   r   r-    r$   r    r   r      s           "!" F FF F 	F
 F F 
F F F F@ C    X
 
 
 
3 4S#X#7      r$   r   N)typingr   r   r   r   r;   r$   r    <module>r=      s_    " " " " " " " " " "F F F F F F F F F Fr$   