Traceback (most recent call last): File "/home/cdhd/PythonCode/pythonProject/Knowledge/Neo4j/neo4j_vectore.py", line 80, in <module> graph_documents = llm_transformer.convert_to_graph_documents(document) File "/home/cdhd/PythonCode/pythonProject/.venv/lib/python3.10/site-packages/langchain_experimental/graph_transformers/llm.py", line 762, in convert_to_graph_documents return [self.process_response(document) for document in documents] File "/home/cdhd/PythonCode/pythonProject/.venv/lib/python3.10/site-packages/langchain_experimental/graph_transformers/llm.py", line 762, in <listcomp> return [self.process_response(document) for document in documents] File "/home/cdhd/PythonCode/pythonProject/.venv/lib/python3.10/site-packages/langchain_experimental/graph_transformers/llm.py", line 714, in process_response nodes_set.add((rel["head"], rel["head_type"])) TypeError: list indices must be integers or slices, not str #24055
Replies: 1 comment 2 replies
-
The error In the {
"head": "entity_name",
"head_type": "entity_type",
"relation": "relationship_type",
"tail": "entity_name",
"tail_type": "entity_type"
} Here's a snippet from the for rel in parsed_json:
nodes_set.add((rel["head"], rel["head_type"]))
nodes_set.add((rel["tail"], rel["tail_type"]))
source_node = Node(id=rel["head"], type=rel["head_type"])
target_node = Node(id=rel["tail"], type=rel["tail_type"])
relationships.append(
Relationship(
source=source_node, target=target_node, type=rel["relation"]
)
) To resolve the issue, ensure that the data being passed to Additionally, make sure that your from langchain_community.graphs.index_creator import GraphIndexCreator
from langchain_core.documents import Document
# Assuming you have a list of documents
documents = [
Document(page_content="Adam is a software engineer in Microsoft since 2009."),
Document(page_content="Microsoft Word is a lightweight app that is accessible offline.")
]
# Create an instance of GraphIndexCreator
graph_index_creator = GraphIndexCreator()
# Convert documents into graph documents
graph_documents = graph_index_creator.convert_to_graph_documents(documents) Ensure that your |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
我在执行上面的代码时,显示该错误,官方案例运行之后也发生了同样的错误,这是因为什么原因造成的呢?可以怎么取解决?
System Info
Package Version
accelerate 0.31.0
aiohttp 3.9.5
aiosignal 1.3.1
annotated-types 0.7.0
anyio 4.4.0
argon2-cffi 23.1.0
argon2-cffi-bindings 21.2.0
arrow 1.3.0
asgiref 3.8.1
asttokens 2.4.1
async-lru 2.0.4
async-timeout 4.0.3
attrs 23.2.0
Babel 2.15.0
backoff 2.2.1
bcrypt 4.1.3
beautifulsoup4 4.12.3
bleach 6.1.0
boto3 1.34.136
botocore 1.34.136
build 1.2.1
bz2file 0.98
cachetools 5.3.3
certifi 2024.6.2
cffi 1.16.0
chardet 5.2.0
charset-normalizer 3.3.2
chroma-hnswlib 0.7.3
chromadb 0.5.3
ci-info 0.3.0
click 8.1.7
cohere 5.5.8
colorama 0.4.6
coloredlogs 15.0.1
comm 0.2.2
configobj 5.0.8
configparser 7.0.0
contourpy 1.2.1
cycler 0.12.1
dataclasses-json 0.6.7
datasets 2.20.0
debugpy 1.8.2
decorator 5.1.1
deepdiff 7.0.1
defusedxml 0.7.1
Deprecated 1.2.14
dill 0.3.8
dirtyjson 1.0.8
distro 1.9.0
dnspython 2.6.1
docx 0.2.4
docx2txt 0.8
email_validator 2.2.0
emoji 2.12.1
et-xmlfile 1.1.0
etelemetry 0.3.1
exceptiongroup 1.2.1
executing 2.0.1
fastapi 0.110.3
fastapi-cli 0.0.4
fastavro 1.9.4
fastjsonschema 2.20.0
filelock 3.15.4
filetype 1.2.0
fitz 0.0.1.dev2
FlagEmbedding 1.2.10
flatbuffers 24.3.25
fonttools 4.53.1
fqdn 1.5.1
frozenlist 1.4.1
fsspec 2024.5.0
gitdb 4.0.11
GitPython 3.1.43
google-auth 2.31.0
googleapis-common-protos 1.63.2
greenlet 3.0.3
grpcio 1.64.1
h11 0.14.0
html2text 2024.2.26
httpcore 1.0.5
httplib2 0.22.0
httptools 0.6.1
httpx 0.27.0
httpx-sse 0.4.0
huggingface-hub 0.23.4
humanfriendly 10.0
idna 3.7
importlib_metadata 7.1.0
importlib_resources 6.4.0
interchange 2021.0.4
ipykernel 6.29.5
ipython 8.26.0
isodate 0.6.1
isoduration 20.11.0
jedi 0.19.1
Jinja2 3.1.4
jmespath 1.0.1
joblib 1.4.2
json_repair 0.25.2
json5 0.9.25
jsonpatch 1.33
jsonpath-python 1.0.6
jsonpickle 3.2.2
jsonpointer 3.0.0
jsonschema 4.22.0
jsonschema-specifications 2023.12.1
jupyter_client 8.6.2
jupyter_core 5.7.2
jupyter-events 0.10.0
jupyter-lsp 2.2.5
jupyter_server 2.14.1
jupyter_server_terminals 0.5.3
jupyterlab 4.2.3
jupyterlab_pygments 0.3.0
jupyterlab_server 2.27.2
kaleido 0.2.1
kiwisolver 1.4.5
kubernetes 30.1.0
langchain 0.2.7
langchain-cli 0.0.25
langchain-community 0.2.7
langchain-core 0.2.12
langchain-experimental 0.0.62
langchain-huggingface 0.0.3
langchain-openai 0.1.14
langchain-text-splitters 0.2.2
Beta Was this translation helpful? Give feedback.
All reactions