Name | llama-index-tools-neo4j JSON |
Version |
0.1.3
JSON |
| download |
home_page | |
Summary | llama-index tools neo4j integration |
upload_time | 2024-02-21 22:21:54 |
maintainer | shahafp |
docs_url | None |
author | Your Name |
requires_python | >=3.8.1,<4.0 |
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
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_db import Neo4jQueryToolSpec
from llama_index.llms import OpenAI
from llama_index.agent 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": "",
"name": "llama-index-tools-neo4j",
"maintainer": "shahafp",
"docs_url": null,
"requires_python": ">=3.8.1,<4.0",
"maintainer_email": "",
"keywords": "cypher,graph,neo4j",
"author": "Your Name",
"author_email": "you@example.com",
"download_url": "https://files.pythonhosted.org/packages/2d/ad/fef924d945d4c75e97d15e18a1b384db44fa99778b4c583e82d5c120130d/llama_index_tools_neo4j-0.1.3.tar.gz",
"platform": null,
"description": "# Neo4j Schema Query Builder\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_db import Neo4jQueryToolSpec\nfrom llama_index.llms import OpenAI\nfrom llama_index.agent 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.1.3",
"project_urls": null,
"split_keywords": [
"cypher",
"graph",
"neo4j"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "94c023d4141e64750966b754ed509d9f01662f8202e3db1acb8c408e7d8657d7",
"md5": "d841d55d71be9aca52fe77be12b8845a",
"sha256": "a2555e96e8cb515bee6de7025e75b23bddbe21ffd182d7907759f5340b9779f7"
},
"downloads": -1,
"filename": "llama_index_tools_neo4j-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d841d55d71be9aca52fe77be12b8845a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8.1,<4.0",
"size": 6350,
"upload_time": "2024-02-21T22:21:53",
"upload_time_iso_8601": "2024-02-21T22:21:53.398604Z",
"url": "https://files.pythonhosted.org/packages/94/c0/23d4141e64750966b754ed509d9f01662f8202e3db1acb8c408e7d8657d7/llama_index_tools_neo4j-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2dadfef924d945d4c75e97d15e18a1b384db44fa99778b4c583e82d5c120130d",
"md5": "d9203787cb7d7ca371bf2ade6ec975d3",
"sha256": "96c3a292fb0552b831b85704de56616375f5703b9b8fcb35f76d05b5d9ac7b42"
},
"downloads": -1,
"filename": "llama_index_tools_neo4j-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "d9203787cb7d7ca371bf2ade6ec975d3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.1,<4.0",
"size": 5838,
"upload_time": "2024-02-21T22:21:54",
"upload_time_iso_8601": "2024-02-21T22:21:54.358116Z",
"url": "https://files.pythonhosted.org/packages/2d/ad/fef924d945d4c75e97d15e18a1b384db44fa99778b4c583e82d5c120130d/llama_index_tools_neo4j-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-21 22:21:54",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "llama-index-tools-neo4j"
}