Open hungbui-io opened 3 weeks ago
Hey @hungbui-io! I'm here to help you with any bugs, questions, or contributions. Let's tackle this issue together!
To resolve the error in the upsert_triplet()
function, ensure that the obj
argument is not an empty string. The error occurs because the obj
value is empty, leading to an IndexError
when attempting to access its first or last character.
Here's how you can modify your code to check for empty strings before calling upsert_triplet
:
import pandas as pd
from llama_index.legacy.graph_stores.nebulagraph import NebulaGraphStore
# Load the xlsx file
df = pd.read_excel('path_to_your_file.xlsx')
# Initialize the NebulaGraphStore
nebula_store = NebulaGraphStore(
space_name="your_space_name",
edge_types=["relationship"],
rel_prop_names=["defined_in"],
tags=["entity"],
tag_prop_names=["name"]
)
# Iterate through the rows of the dataframe and upsert triplets
for index, row in df.iterrows():
function_name = row['function_name']
file_name = row['file_name']
function_definition = row['function_definition']
# Ensure obj is not an empty string
if function_name and file_name:
nebula_store.upsert_triplet(function_name, 'defined_in', file_name)
This code checks if function_name
and file_name
are not empty before calling upsert_triplet
. Adjust the condition based on your specific requirements to ensure that no empty strings are passed to the upsert_triplet
method [1][2][3].
To continue talking to Dosu, mention @dosu.
Hmm, guess it should filter empty entities/relations then
Bug Description
I am trying to generate a Nebulagraph knowledge graph from a code data in an xlsx file that contain function_name, file_name and function_definition columns. But an error occurs in the upsert_triplet() function saying that the created object vertex has empty string (pls check the log below)
Version
0.10.44
Steps to Reproduce
Relevant Logs/Tracbacks