Find answers from the community

d
d1n0
Offline, last seen last week
Joined September 25, 2024
Hi everyone,
I'm getting an unexpected error creating a Neo4jPropertyGraphStore.
Code:
global NEO4J_STORE
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
NEO4J_STORE = Neo4jPropertyGraphStore(
url=neo4j_url,
username=neo4j_user,
password=neo4j_password)
Error:
NEO4J_STORE = Neo4jPropertyGraphStore(
File "/usr/local/lib/python3.9/site-packages/llama_index/graph_stores/neo4j/neo4j_property_graph.py", line 169, in init
self.refresh_schema()
File "/usr/local/lib/python3.9/site-packages/llama_index/graph_stores/neo4j/neo4j_property_graph.py", line 270, in refresh_schema
enhanced_info = self.structured_query(enhanced_cypher)[0]["output"]
File "/usr/local/lib/python3.9/site-packages/llama_index/graph_stores/neo4j/neo4j_property_graph.py", line 588, in structured_query
full_result = [d.data() for d in result]
File "/usr/local/lib/python3.9/site-packages/llama_index/graph_stores/neo4j/neo4j_property_graph.py", line 588, in <listcomp>
full_result = [d.data() for d in result]
File "/usr/local/lib/python3.9/site-packages/neo4j/_sync/work/result.py", line 393, in iter
self._connection.fetch_message()
File "/usr/local/lib/python3.9/site-packages/neo4j/_sync/io/_common.py", line 184, in inner
func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/neo4j/_sync/io/_bolt.py", line 994, in fetch_message
res = self._process_message(tag, fields)
File "/usr/local/lib/python3.9/site-packages/neo4j/_sync/io/_bolt5.py", line 496, in _process_message
response.on_failure(summary_metadata or {})
File "/usr/local/lib/python3.9/site-packages/neo4j/_sync/io/_common.py", line 254, in on_failure
raise self._hydrate_error(metadata)
neo4j.exceptions.CypherTypeError: {code: Neo.ClientError.Statement.TypeError} {message: Expected a string value for substring, but got: 2024-01-01T00:00:00Z; consider converting it to a string with toString().}
2 comments
L
d
Hello everyone,
I'm encountering some problems with storing metadata in Neo4j using the VectorStoreIndex. I'm creating nodes with important metadata. Here is the relevant part of my code:
Plain Text
def get_metadata(filename):
   for item in metadata:
    if item["url"] == filename:
     return item
   return {}
documents = SimpleDirectoryReader(dir_documents, file_metadata=get_metadata).load_data()
node_parser = SentenceWindowNodeParser.from_defaults(window_size=3,window_metadata_key="window",original_text_metadata_key="original_text")
nodes = node_parser.get_nodes_from_documents(documents)
transformations = [title_extractor, qa_extractor]
neo4j_vector_store = Neo4jVectorStore(neo_username, neo_password, neo_url, embed_dim, hybrid_search=True, index_name=index_name)
storage_context = StorageContext.from_defaults(vector_store=neo4j_vector_store)
vector_index = get_vector_index(neo_username, neo_password, neo_url, embed_dim, index_name)
vector_index.insert_nodes(nodes, transformations=transformations, storage_context=storage_context)

I then built a query engine used by an agent. While the agent retrieves these nodes, the nodes do not have the metadata I imported previously. Upon checking the Neo4j created nodes, I noticed that not only do the nodes lack this metadata, but the metadata has also been vectorized as part of the content. Therefore, I don't have access to that metadata when retrieving normal chunks.
Here is the code for the query engine:
Plain Text
node_postprocessors = [MetadataReplacementPostProcessor(target_metadata_key="window"),SimilarityPostprocessor(similarity_cutoff=0.5)]
index_query_engine = index.as_query_engine(similarity_top_k=doc_similarity_top_k, node_postprocessors=node_postprocessors)

Is this an error? Is it a problem with using SentenceWindowNodeParser or how i include the metadata? What can I do to ensure that the metadata is stored correctly and can be retrieved as expected?
Any help or guidance would be greatly appreciated.
Thank you!
2 comments
L
d
Issue with Agents decisions in llama-index==0.11.5.
Hello everyone,

I am currently working on building an agent that can execute queries in a database OR perform RAG through several documents. The agent is functional, but I am struggling with enhancing the decision-making process for choosing whether to query the database or perform RAG with documents. Any advice or suggestions on how to improve this decision-making logic would be greatly appreciated. Thank you!
My db is neo4j and im executing cypher queries in one side. Also my embeddings from text are located in another neo db.
Summary of the code:
Plain Text
# Filter all the FunctionTools from a module
    tools = [getattr(module, attr_name) for attr_name in dir(module)
        if isinstance(getattr(module, attr_name), FunctionTool)]

    query_engine_tool = QueryEngineTool(query_engine=query_engine, metadata=ToolMetadata(
    name='get_document_info',
    description=(f"Useful for extract information from documents.")))

    tools.append(query_engine_tool )

    agent_worker = FunctionCallingAgentWorker.from_tools(
        tools,
        verbose=True,
        system_prompt=system_prompt,
    )
    agent = AgentRunner(agent_worker)
    agent.chat(query)
2 comments
d
L
d
d1n0
·

Hello everyone,

Hello everyone,
I am triying to create a knowledge graph using PropertyGraphIndex with SchemaLLMPathExtractor for extracting triplets from certain documents in v0.11.4
The graph has been created perfectly and seems somewhat meaningful, however, when performing a retrieval, it returns an empty list.
Plain Text
index_schema = PropertyGraphIndex.from_documents(
            documents,
            kg_extractors=[kg_extractor],
            property_graph_store=pg_store,
            vec_store=vec_store,
            show_progress=True
        )

retriever = index_schema.as_retriever().retrieve(query)


And if i try to retrieve the same kg loading it using .from_existing() from Neo4j, it appears the following empty error:

Plain Text
AssertionError:


What can i do?
4 comments
d
L
d
d1n0
·

Hello,

Hello,
I am trying to implement GraphRAG using my own knowledge graph in Neo4j. I have used Neo4jPropertyGraphStore and then the PropertyGraphIndex object with the from_existing() function to work with my own KG.

I noticed that I need to set all my nodes as __Entity__ and __Node__ for it to work correctly. However, I'm encountering the following error:

Plain Text
ValidationError: 1 validation error for EntityNode
name
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.8/v/string_type


I checked the provided URL, but I couldn't find any useful information to resolve this issue. Could you please provide guidance or help me understand what might be causing this error?

Thank you!
20 comments
d
A
L