Skip to content

Commit 863c11d

Browse files
Add chunk position and content length in chunk Node
1 parent 3929aa0 commit 863c11d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

backend/src/make_relationships.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def create_source_chunk_entity_relationship(source_file_name :str,
1717
password : str,
1818
isFirstChunk : bool,
1919
current_chunk_id:uuid,
20-
previous_chunk_id:uuid,)-> list:
20+
previous_chunk_id:uuid)-> list:
2121
""" Create relationship between source, chunk and entity nodes
2222
Args:
2323
source_file_name (str): file name of input source

backend/src/openAI_llm.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,14 @@ def extract_graph_from_OpenAI(model_version,
275275
for i, chunk_document in tqdm(enumerate(chunks), total=len(chunks)):
276276
previous_chunk_id = current_chunk_id
277277
current_chunk_id = str(uuid.uuid1())
278+
position = i+1
278279
if i == 0:
279280
firstChunk = True
280281
else:
281282
firstChunk = False
283+
metadata = {"position": position,"length": len(chunk_document.page_content)}
284+
chunk_document = Document(page_content=chunk_document.page_content,metadata = metadata)
285+
282286
futures.append(executor.submit(extract_and_store_graph,model_version,graph,chunk_document,file_name,uri,userName,password,firstChunk,current_chunk_id,previous_chunk_id))
283287
for future in concurrent.futures.as_completed(futures):
284288
graph_document,lst_cypher_queries_chunk_relationship = future.result()

0 commit comments

Comments
 (0)