diff --git a/llama_hub/llama_packs/fuzzy_citation/base.py b/llama_hub/llama_packs/fuzzy_citation/base.py index 41cc6f497f..3ec1ac51c3 100644 --- a/llama_hub/llama_packs/fuzzy_citation/base.py +++ b/llama_hub/llama_packs/fuzzy_citation/base.py @@ -59,12 +59,16 @@ def get_relevant_sentences( # concat nearby sentences top_chunks = defaultdict(list) prev_idx = -1 + prev_response_sent_idx = -1 for response_sent_idx, node_sent_idx in sorted(top_sentences.keys()): if prev_idx == -1: top_chunks[response_sent_idx].append( top_sentences[(response_sent_idx, node_sent_idx)] ) - elif node_sent_idx - prev_idx == 1: + elif ( + prev_response_sent_idx == response_sent_idx + and node_sent_idx - prev_idx == 1 + ): top_chunks[response_sent_idx][-1] += top_sentences[ (response_sent_idx, node_sent_idx) ] @@ -73,6 +77,7 @@ def get_relevant_sentences( top_sentences[(response_sent_idx, node_sent_idx)] ) prev_idx = node_sent_idx + prev_response_sent_idx = response_sent_idx # associate chunks with their nodes for response_sent_idx, chunks in top_chunks.items():