@@ -308,7 +308,7 @@ def extract_graph_from_file(uri, userName, password, model, file=None,source_url
308308 graph_documents = extract_graph_from_OpenAI (model_version ,graph ,chunks ,file_name ,uri ,userName ,password )
309309
310310 #update_similarity_graph for the KNN Graph
311- update_graph ()
311+ update_graph (graph )
312312
313313 distinct_nodes = set ()
314314 relations = []
@@ -393,14 +393,21 @@ def get_documents_from_youtube(url):
393393 print ("Youtube pages = " ,pages )
394394 return file_name , file_key , pages
395395
396- def get_source_list_from_graph ():
396+ def get_source_list_from_graph (uri , userName , password ):
397397 """
398+ Args:
399+ uri: URI of the graph to extract
400+ userName: Username to use for graph creation ( if None will use username from config file )
401+ password: Password to use for graph creation ( if None will use password from config file )
402+ file: File object containing the PDF file to be used
403+ model: Type of model to use ('Diffbot'or'OpenAI GPT')
404+ Returns:
398405 Returns a list of sources that are in the database by querying the graph and
399406 sorting the list by the last updated date.
400407 """
401408 logging .info ("Get existing files list from graph" )
402409 try :
403- graph = Neo4jGraph ()
410+ graph = Neo4jGraph (url = uri , username = userName , password = password )
404411 query = "MATCH(d:Document) RETURN d ORDER BY d.updatedAt DESC"
405412 result = graph .query (query )
406413 list_of_json_objects = [entry ['d' ] for entry in result ]
@@ -411,14 +418,14 @@ def get_source_list_from_graph():
411418 logging .exception ('Exception' )
412419 return create_api_response (job_status ,error = error_message )
413420
414- def update_graph ():
421+ def update_graph (graph ):
415422 """
416423 Update the graph node with SIMILAR relationship where embedding scrore match
417424 """
418425 knn_min_score = os .environ .get ('KNN_MIN_SCORE' )
419426
420427 query = "WHERE node <> c and score >= {} MERGE (c)-[rel:SIMILAR]-(node) SET rel.score = score"
421- graph = Neo4jGraph ()
428+ # graph = Neo4jGraph()
422429 result = graph .query ("""MATCH (c:Chunk)
423430 WHERE c.embedding IS NOT NULL AND count { (c)-[:SIMILAR]-() } < 5
424431 CALL db.index.vector.queryNodes('vector', 6, c.embedding) yield node, score """ + query .format (knn_min_score ))
0 commit comments