neo4j_chat_agent
langroid/agent/special/neo4j/neo4j_chat_agent.py
Neo4jChatAgent(config)
¶
Bases: ChatAgent
Raises:
Type | Description |
---|---|
ValueError
|
If database information is not provided in the config. |
Source code in langroid/agent/special/neo4j/neo4j_chat_agent.py
handle_message_fallback(msg)
¶
When LLM sends a no-tool msg, assume user is the intended recipient, and if in interactive mode, forward the msg to the user.
Source code in langroid/agent/special/neo4j/neo4j_chat_agent.py
close()
¶
retry_query(e, query)
¶
Generate an error message for a failed Cypher query and return it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
e |
Exception
|
The exception raised during the Cypher query execution. |
required |
query |
str
|
The Cypher query that failed. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The error message. |
Source code in langroid/agent/special/neo4j/neo4j_chat_agent.py
read_query(query, parameters=None)
¶
Executes a given Cypher query with parameters on the Neo4j database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
str
|
The Cypher query string to be executed. |
required |
parameters |
Optional[Dict[Any, Any]]
|
A dictionary of parameters for the query. |
None
|
Returns:
Name | Type | Description |
---|---|---|
QueryResult |
QueryResult
|
An object representing the outcome of the query execution. |
Source code in langroid/agent/special/neo4j/neo4j_chat_agent.py
write_query(query, parameters=None)
¶
Executes a write transaction using a given Cypher query on the Neo4j database. This method should be used for queries that modify the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
str
|
The Cypher query string to be executed. |
required |
parameters |
dict
|
A dict of parameters for the Cypher query. |
None
|
Returns:
Name | Type | Description |
---|---|---|
QueryResult |
QueryResult
|
An object representing the outcome of the query execution. It contains a success flag and an optional error message. |
Source code in langroid/agent/special/neo4j/neo4j_chat_agent.py
remove_database()
¶
Deletes all nodes and relationships from the current Neo4j database.
Source code in langroid/agent/special/neo4j/neo4j_chat_agent.py
cypher_retrieval_tool(msg)
¶
" Handle a CypherRetrievalTool message by executing a Cypher query and returning the result. Args: msg (CypherRetrievalTool): The tool-message to handle.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The result of executing the cypher_query. |
Source code in langroid/agent/special/neo4j/neo4j_chat_agent.py
cypher_creation_tool(msg)
¶
" Handle a CypherCreationTool message by executing a Cypher query and returning the result. Args: msg (CypherCreationTool): The tool-message to handle.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The result of executing the cypher_query. |
Source code in langroid/agent/special/neo4j/neo4j_chat_agent.py
graph_schema_tool(msg)
¶
Retrieves the schema of a Neo4j graph database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
GraphSchemaTool
|
An instance of GraphDatabaseSchema, typically |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str | Optional[Union[str, List[Dict[Any, Any]]]]
|
The visual representation of the database schema as a string, or a |
str | Optional[Union[str, List[Dict[Any, Any]]]]
|
message stating that the database schema is empty or not valid. |