Open tamilselvanav opened 3 weeks ago
Please update to latest version of langchain_community, because I used python version 3.12.4
and faced no error when executing the below code:
from langchain_community.graphs import Neo4jGraph
graph = Neo4jGraph()
# Import movie information
movies_query = """
LOAD CSV WITH HEADERS FROM
'https://raw.githubusercontent.com/tomasonjo/blog-datasets/main/movies/movies_small.csv'
AS row
MERGE (m:Movie {id:row.movieId})
SET m.released = date(row.released),
m.title = row.title,
m.imdbRating = toFloat(row.imdbRating)
FOREACH (director in split(row.director, '|') |
MERGE (p:Person {name:trim(director)})
MERGE (p)-[:DIRECTED]->(m))
FOREACH (actor in split(row.actors, '|') |
MERGE (p:Person {name:trim(actor)})
MERGE (p)-[:ACTED_IN]->(m))
FOREACH (genre in split(row.genres, '|') |
MERGE (g:Genre {name:trim(genre)})
MERGE (m)-[:IN_GENRE]->(g))
"""
graph.query(movies_query)
Thanks for the response @keenborder786 . But I still face the same issue. I use langchain_community v0.2.4 (which is the latest as of now).
Here are some more details that might help. Python v3.12.4 (I used the one from Microsoft Store and later with the one downloaded from https://www.python.org/downloads/release/python-3124/. I hope this shouldn't make a difference. But sharing here as I tried both) OS: Windows 10 IDE: Visual Studio Code Virtual environment: venv
The requirements.txt file I use has the following content: python-dotenv==1.0.1 langchain==0.2.3 langchain-community==0.2.4 langchain-openai==0.1.8 neo4j==5.20.0
Important note: Everything works fine if I use Python v3.11.7 instead of Python v3.12.4.
@tamilselvanav can you try python 3.12.3
@keenborder786 : Yes, I tried and the same code works fine with Python v3.12.3
URL
https://python.langchain.com/v0.2/docs/tutorials/graph/
Checklist
Issue with current documentation:
Important: This happens with Python v3.12.4.
The below statement in the documentation (https://python.langchain.com/v0.2/docs/tutorials/graph/) fails graph.query(movies_query)
with the below error. 2 from typing import Any, Dict, List, Optional 4 from langchain_core.utils import get_from_dict_or_env ----> 6 from langchain_community.graphs.graph_document import GraphDocument ... 64 # Even though it is the right signature for python 3.9, mypy complains with 65 #
error: Too many arguments for "_evaluate" of "ForwardRef"
hence the cast... ---> 66 return cast(Any, type_)._evaluate(globalns, localns, set())TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'
Idea or request for content:
May be, the code in the documentation needs to be tested against latest python versions