Skip to content

Commit 4f51b80

Browse files
Fixed issue for out of range in KNN API
1 parent f669c37 commit 4f51b80

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

backend/src/graphDB_dataAccess.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def update_KNN_graph(self):
128128
index = self.graph.query("""show indexes yield * where type = 'VECTOR' and name = 'vector'""")
129129
# logging.info(f'show index vector: {index}')
130130
knn_min_score = os.environ.get('KNN_MIN_SCORE')
131-
if index[0]['name'] == 'vector':
131+
if len(index) > 0:
132132
logging.info('update KNN graph')
133133
result = self.graph.query("""MATCH (c:Chunk)
134134
WHERE c.embedding IS NOT NULL AND count { (c)-[:SIMILAR]-() } < 5
@@ -138,6 +138,8 @@ def update_KNN_graph(self):
138138
{"score":float(knn_min_score)}
139139
)
140140
logging.info(f"result : {result}")
141+
else:
142+
logging.info("Vector index does not exist, So KNN graph not update")
141143

142144
def connection_check(self):
143145
"""

0 commit comments

Comments
 (0)