Name | llama-index-tools-neo4j JSON |
Version |
0.3.0
JSON |
| download |
home_page | None |
Summary | llama-index tools neo4j integration |
upload_time | 2024-11-18 00:57:49 |
maintainer | shahafp |
docs_url | None |
author | Your Name |
requires_python | <4.0,>=3.9 |
license | MIT |
keywords |
cypher
graph
neo4j
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Neo4j Schema Query Builder
```bash
pip install llama-index-tools-neo4j
```
The `Neo4jQueryToolSpec` class provides a way to query a Neo4j graph database based on a provided schema definition. The class uses a language model to generate Cypher queries from user questions and has the capability to recover from Cypher syntax errors through a self-healing mechanism.
## Table of Contents
- [Usage](#usage)
- [Initialization](#initialization)
- [Running a Query](#running-a-query)
- [Features](#features)
## Usage
### Initialization
Initialize the `Neo4jQueryToolSpec` class with:
```python
from llama_index.tools.neo4j import Neo4jQueryToolSpec
from llama_index.llms.openai import OpenAI
from llama_index.agent.openai import OpenAIAgent
llm = OpenAI(model="gpt-4", openai_api_key="XXXX-XXXX", temperature=0)
gds_db = Neo4jQueryToolSpec(
url="neo4j-url",
user="neo4j-user",
password="neo4j=password",
llm=llm,
database="neo4j",
)
tools = gds_db.to_tool_list()
agent = OpenAIAgent.from_tools(tools, verbose=True)
```
Where:
- `url`: Connection string for the Neo4j database.
- `user`: Username for the Neo4j database.
- `password`: Password for the Neo4j database.
- `llm`: A language model for generating Cypher queries (any type of LLM).
- `database`: The database name.
### Running a Query
To use the agent:
```python
# use agent
agent.chat("Where is JFK airport is located?")
```
```
Generated Cypher:
MATCH (p:Port {port_code: 'JFK'})
RETURN p.location_name_wo_diacritics AS Location
Final answer:
'The port code JFK is located in New York, United States.'
```
## Features
- **Schema-Based Querying**: The class extracts the Neo4j database schema to guide the Cypher query generation.
- **Self-Healing**: On a Cypher syntax error, the class corrects itself to produce a valid query.
- **Language Model Integration**: Uses a language model for natural and accurate Cypher query generation.
Raw data
{
"_id": null,
"home_page": null,
"name": "llama-index-tools-neo4j",
"maintainer": "shahafp",
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "cypher, graph, neo4j",
"author": "Your Name",
"author_email": "you@example.com",
"download_url": "https://files.pythonhosted.org/packages/0f/28/002458ad555d76c8fa1ca5c828013e18da6732f419ae9e52062c23aa4aeb/llama_index_tools_neo4j-0.3.0.tar.gz",
"platform": null,
"description": "# Neo4j Schema Query Builder\n\n```bash\npip install llama-index-tools-neo4j\n```\n\nThe `Neo4jQueryToolSpec` class provides a way to query a Neo4j graph database based on a provided schema definition. The class uses a language model to generate Cypher queries from user questions and has the capability to recover from Cypher syntax errors through a self-healing mechanism.\n\n## Table of Contents\n\n- [Usage](#usage)\n - [Initialization](#initialization)\n - [Running a Query](#running-a-query)\n- [Features](#features)\n\n## Usage\n\n### Initialization\n\nInitialize the `Neo4jQueryToolSpec` class with:\n\n```python\nfrom llama_index.tools.neo4j import Neo4jQueryToolSpec\nfrom llama_index.llms.openai import OpenAI\nfrom llama_index.agent.openai import OpenAIAgent\n\nllm = OpenAI(model=\"gpt-4\", openai_api_key=\"XXXX-XXXX\", temperature=0)\n\ngds_db = Neo4jQueryToolSpec(\n url=\"neo4j-url\",\n user=\"neo4j-user\",\n password=\"neo4j=password\",\n llm=llm,\n database=\"neo4j\",\n)\n\ntools = gds_db.to_tool_list()\nagent = OpenAIAgent.from_tools(tools, verbose=True)\n```\n\nWhere:\n\n- `url`: Connection string for the Neo4j database.\n- `user`: Username for the Neo4j database.\n- `password`: Password for the Neo4j database.\n- `llm`: A language model for generating Cypher queries (any type of LLM).\n- `database`: The database name.\n\n### Running a Query\n\nTo use the agent:\n\n```python\n# use agent\nagent.chat(\"Where is JFK airport is located?\")\n```\n\n```\nGenerated Cypher:\n\nMATCH (p:Port {port_code: 'JFK'})\nRETURN p.location_name_wo_diacritics AS Location\n\nFinal answer:\n'The port code JFK is located in New York, United States.'\n```\n\n## Features\n\n- **Schema-Based Querying**: The class extracts the Neo4j database schema to guide the Cypher query generation.\n- **Self-Healing**: On a Cypher syntax error, the class corrects itself to produce a valid query.\n- **Language Model Integration**: Uses a language model for natural and accurate Cypher query generation.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "llama-index tools neo4j integration",
"version": "0.3.0",
"project_urls": null,
"split_keywords": [
"cypher",
" graph",
" neo4j"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "62354160f05a1583879344b4c0246f2236e30127d548d28f714c796e37ce01aa",
"md5": "671c04094a49d3c4d51fab3cb80091b8",
"sha256": "f9b34b5a1359c53cc1b5417dcd389a7b273ef68a996f4d4c8e5500e3980049c6"
},
"downloads": -1,
"filename": "llama_index_tools_neo4j-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "671c04094a49d3c4d51fab3cb80091b8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 6367,
"upload_time": "2024-11-18T00:57:48",
"upload_time_iso_8601": "2024-11-18T00:57:48.521454Z",
"url": "https://files.pythonhosted.org/packages/62/35/4160f05a1583879344b4c0246f2236e30127d548d28f714c796e37ce01aa/llama_index_tools_neo4j-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0f28002458ad555d76c8fa1ca5c828013e18da6732f419ae9e52062c23aa4aeb",
"md5": "ef58f09947661402892406d48be0416e",
"sha256": "bbd57159c366f955a51e46b4f523d08c848f4bb20641bf594aeda64a450296d4"
},
"downloads": -1,
"filename": "llama_index_tools_neo4j-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "ef58f09947661402892406d48be0416e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 5829,
"upload_time": "2024-11-18T00:57:49",
"upload_time_iso_8601": "2024-11-18T00:57:49.475833Z",
"url": "https://files.pythonhosted.org/packages/0f/28/002458ad555d76c8fa1ca5c828013e18da6732f419ae9e52062c23aa4aeb/llama_index_tools_neo4j-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-18 00:57:49",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "llama-index-tools-neo4j"
}