run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
33.99k stars 4.79k forks source link

[Bug]: KnowledgeGraphIndex._build_index_from_nodes() got an unexpected keyword argument 'space_name' #14629

Open Aaronchangji opened 2 weeks ago

Aaronchangji commented 2 weeks ago

Bug Description

Try to create KG index via

kg_index = KnowledgeGraphIndex.from_documents(
    documents,
    storage_context=storage_context,
    max_triplets_per_chunk=10,
    space_name=space_name,
    edge_types=edge_types,
    rel_prop_names=rel_prop_names,
    tags=tags,
    include_embeddings=True,)

It reports:

KnowledgeGraphIndex._build_index_from_nodes() got an unexpected keyword argument 'space_name'.

_build_index_from_nodes() in KnowledgeGraphIndex does not take any keyword arguments except for nodes.

I think it's a similar bug with https://github.com/run-llama/llama_index/issues/14398

Version

0.10.52

Steps to Reproduce

Follow the instructions of https://docs.llamaindex.ai/en/stable/examples/query_engine/knowledge_graph_query_engine/#optionalbuild-the-knowledge-graph-with-llamaindex to build KG.

Relevant Logs/Tracbacks

Traceback (most recent call last):
  File "/data/share/users/aaron/llm/llamaindex/try_graph_rag.py", line 55, in <module>
    kg_index = KnowledgeGraphIndex.from_documents(
  File "/data/share/users/aaron/lib/spack-0.20.0/opt/spack/linux-debian9-skylake_avx512/gcc-8.2.0/python-3.10.10-4cihimz3xbhm45os3lfvczvmivfvnqmv/lib/python3.10/site-packages/llama_index/core/indices/base.py", line 145, in from_documents
    return cls(
  File "/data/share/users/aaron/lib/spack-0.20.0/opt/spack/linux-debian9-skylake_avx512/gcc-8.2.0/python-3.10.10-4cihimz3xbhm45os3lfvczvmivfvnqmv/lib/python3.10/site-packages/llama_index/core/indices/knowledge_graph/base.py", line 99, in __init__
    super().__init__(
  File "/data/share/users/aaron/lib/spack-0.20.0/opt/spack/linux-debian9-skylake_avx512/gcc-8.2.0/python-3.10.10-4cihimz3xbhm45os3lfvczvmivfvnqmv/lib/python3.10/site-packages/llama_index/core/indices/base.py", line 94, in __init__
    index_struct = self.build_index_from_nodes(
  File "/data/share/users/aaron/lib/spack-0.20.0/opt/spack/linux-debian9-skylake_avx512/gcc-8.2.0/python-3.10.10-4cihimz3xbhm45os3lfvczvmivfvnqmv/lib/python3.10/site-packages/llama_index/core/indices/base.py", line 216, in build_index_from_nodes
    return self._build_index_from_nodes(nodes, **build_kwargs)
TypeError: KnowledgeGraphIndex._build_index_from_nodes() got an unexpected keyword argument 'space_name'
Exception ignored in: <function NebulaGraphStore.__del__ at 0x7f27c1d79fc0>
Traceback (most recent call last):
  File "/data/share/users/aaron/lib/spack-0.20.0/opt/spack/linux-debian9-skylake_avx512/gcc-8.2.0/python-3.10.10-4cihimz3xbhm45os3lfvczvmivfvnqmv/lib/python3.10/site-packages/llama_index/graph_stores/nebula/nebula_graph_store.py", line 242, in __del__
  File "/data/share/users/aaron/lib/spack-0.20.0/opt/spack/linux-debian9-skylake_avx512/gcc-8.2.0/python-3.10.10-4cihimz3xbhm45os3lfvczvmivfvnqmv/lib/python3.10/site-packages/nebula3/gclient/net/SessionPool.py", line 326, in close
  File "/data/share/users/aaron/lib/spack-0.20.0/opt/spack/linux-debian9-skylake_avx512/gcc-8.2.0/python-3.10.10-4cihimz3xbhm45os3lfvczvmivfvnqmv/lib/python3.10/site-packages/nebula3/gclient/net/Session.py", line 351, in _sign_out
  File "/data/share/users/aaron/lib/spack-0.20.0/opt/spack/linux-debian9-skylake_avx512/gcc-8.2.0/python-3.10.10-4cihimz3xbhm45os3lfvczvmivfvnqmv/lib/python3.10/site-packages/nebula3/gclient/net/Connection.py", line 258, in signout
  File "/data/share/users/aaron/lib/spack-0.20.0/opt/spack/linux-debian9-skylake_avx512/gcc-8.2.0/python-3.10.10-4cihimz3xbhm45os3lfvczvmivfvnqmv/lib/python3.10/site-packages/nebula3/graph/GraphService.py", line 1603, in signout
  File "/data/share/users/aaron/lib/spack-0.20.0/opt/spack/linux-debian9-skylake_avx512/gcc-8.2.0/python-3.10.10-4cihimz3xbhm45os3lfvczvmivfvnqmv/lib/python3.10/site-packages/nebula3/graph/GraphService.py", line 1606, in send_signout
AttributeError: 'NoneType' object has no attribute 'CALL'
dosubot[bot] commented 2 weeks ago

@Aaronchangji Hello! I'm here to help you with any bugs, questions, or contributions. Let's work together to resolve your issue.

To resolve the TypeError: KnowledgeGraphIndex._build_index_from_nodes() got an unexpected keyword argument 'space_name' error, ensure that the space_name argument is not passed to the _build_index_from_nodes method. Instead, it should be used when instantiating the NebulaGraphStore.

Here is the correct way to instantiate the NebulaGraphStore and create the StorageContext:

from llama_index.legacy.storage.storage_context import StorageContext
from llama_index.legacy.graph_stores.nebula import NebulaGraphStore

space_name = "llamaindex"
edge_types, rel_prop_names = ["relationship"], ["relationship"]
tags = ["entity"]

graph_store = NebulaGraphStore(
    space_name=space_name,
    edge_types=edge_types,
    rel_prop_names=rel_prop_names,
    tags=tags,
)
storage_context = StorageContext.from_defaults(graph_store=graph_store)

Ensure that you do not pass space_name to the KnowledgeGraphIndex.from_documents method. The KnowledgeGraphIndex class does not accept space_name as a parameter, and it should be configured within the NebulaGraphStore and StorageContext as shown above [1][2][3].

To continue talking to Dosu, mention @dosu.

jagan-blip commented 2 weeks ago

Yep, same issue happening to us as well.