Find answers from the community

Updated last month

Issue Creating a Property Graph Index

hi,

i am facing issue when creating a property graph index

Plain Text
    kg_extractor = SchemaLLMPathExtractor(
        llm = OpenAI(model="gpt-4o", temperature=0.1),
        possible_entities=entities,
        possible_entity_props=entity_properties,
        possible_relations=relations,
        kg_validation_schema=validation_schema,
        strict=True
    )


Plain Text
    graph_store = Neo4jPropertyGraphStore(
        username=os.getenv("username"),
        password=os.getenv("password"),
        url=os.getenv("url"),
        database=os.getenv("database")
    )


Plain Text
    pg_index = PropertyGraphIndex.from_documents(
        documents,
        kg_extractors=[kg_extractor],
        embed_model = OpenAIEmbedding(model="text-embedding-3-small"),
        property_graph_store=graph_store,
        vector_store=None,
        show_progress=True,
    )


when i run it getting error
File "/home/user/.cache/pypoetry/virtualenvs/llama-graph-Kulloq32-py3.12/lib/python3.12/site-packages/llama_index/core/storage/index_store/keyval_index_store.py", line 44, in add_index_struct
key = index_struct.index_id
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'coroutine' object has no attribute 'index_id'
L
t
8 comments
Do you have the latest version of llama-index? That seems low-key impossible πŸ˜…
Yeah, I was running on latest version
Can you reproduce without neo4j? (I hate settting that up lol) -- would love to repro on google colab
this is something weired that i was facing, it works fine in colab and throws error when runned in fastapi application.

colab link - https://colab.research.google.com/drive/1VNIpaOflVOgSSLwQd8ut6HHX9Vo39_QA?usp=sharing
in colab it runs good, but when i run in fastapi i get runtime errors
Oh, I see

Put this at the top of your code
Plain Text
import nest_asyncio
nest_asyncio.apply()


And launch your app with
Plain Text
uvicorn.run(..., loop="asyncio")
Thanks Logan.
This worked
The root issue here is, python doesn't allow async constructors on python classes πŸ˜… Ideally, the index itself has async insert methods so that you can create an empty index and use async inserts to populate it. This would avoid any async nesting

But, need to make a PR to add async entry points to the base index class πŸ™‚
Add a reply
Sign up and join the conversation on Discord