File size: 753 Bytes
6085b61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Modified _merge_all_parts function to deduplicate sections
def _merge_all_parts(parts):
    seen_sections = set()
    merged_output = []
    for part in parts:
        for section in part:
            if section["title"] not in seen_sections:
                merged_output.append(section)
                seen_sections.add(section["title"])
    return merged_output


# Modified _generate_continuation function to keep track of written sections
def _generate_continuation(previous_part, current_part):
    written_sections = set([section["title"] for section in previous_part])
    continuation = []
    for section in current_part:
        if section["title"] not in written_sections:
            continuation.append(section)
    return continuation