Skip to content

Node relationship id type none issue #547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions backend/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,9 @@ def processing_chunks(chunkId_chunkDoc_list,graph,file_name,model,allowedNodes,a
update_embedding_create_vector_index( graph, chunkId_chunkDoc_list, file_name)
logging.info("Get graph document list from models")
graph_documents = generate_graphDocuments(model, graph, chunkId_chunkDoc_list, allowedNodes, allowedRelationship)
save_graphDocuments_in_neo4j(graph, graph_documents)
chunks_and_graphDocuments_list = get_chunk_and_graphDocument(graph_documents, chunkId_chunkDoc_list)
cleaned_graph_documents = handle_backticks_nodes_relationship_id_type(graph_documents)
save_graphDocuments_in_neo4j(graph, cleaned_graph_documents)
chunks_and_graphDocuments_list = get_chunk_and_graphDocument(cleaned_graph_documents, chunkId_chunkDoc_list)
merge_relationship_between_chunk_and_entites(graph, chunks_and_graphDocuments_list)
# return graph_documents

Expand Down
20 changes: 20 additions & 0 deletions backend/src/shared/common_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,26 @@ def load_embedding_model(embedding_model_name: str):
def save_graphDocuments_in_neo4j(graph:Neo4jGraph, graph_document_list:List[GraphDocument]):
# graph.add_graph_documents(graph_document_list, baseEntityLabel=True)
graph.add_graph_documents(graph_document_list)

def handle_backticks_nodes_relationship_id_type(graph_document_list:List[GraphDocument]):
for graph_document in graph_document_list:
# Clean node id and types
cleaned_nodes = []
for node in graph_document.nodes:
if node.type.strip() and node.id.strip():
node.type = node.type.replace('`', '')
cleaned_nodes.append(node)
# Clean relationship id types and source/target node id and types
cleaned_relationships = []
for rel in graph_document.relationships:
if rel.type.strip() and rel.source.id.strip() and rel.source.type.strip() and rel.target.id.strip() and rel.target.type.strip():
rel.type = rel.type.replace('`', '')
rel.source.type = rel.source.type.replace('`', '')
rel.target.type = rel.target.type.replace('`', '')
cleaned_relationships.append(rel)
graph_document.relationships = cleaned_relationships
graph_document.nodes = cleaned_nodes
return graph_document_list

def delete_uploaded_local_file(merged_file_path, file_name):
file_path = Path(merged_file_path)
Expand Down