MCPcopy Create free account
hub / github.com/NanGePlus/LightRAGTest / process_combine_contexts

Function process_combine_contexts

LightRAG/lightrag/utils.py:275–309  ·  view source on GitHub ↗
(hl, ll)

Source from the content-addressed store, hash-verified

273
274
275def process_combine_contexts(hl, ll):
276 header = None
277 list_hl = csv_string_to_list(hl.strip())
278 list_ll = csv_string_to_list(ll.strip())
279
280 if list_hl:
281 header = list_hl[0]
282 list_hl = list_hl[1:]
283 if list_ll:
284 header = list_ll[0]
285 list_ll = list_ll[1:]
286 if header is None:
287 return ""
288
289 if list_hl:
290 list_hl = [",".join(item[1:]) for item in list_hl if item]
291 if list_ll:
292 list_ll = [",".join(item[1:]) for item in list_ll if item]
293
294 combined_sources = []
295 seen = set()
296
297 for item in list_hl + list_ll:
298 if item and item not in seen:
299 combined_sources.append(item)
300 seen.add(item)
301
302 combined_sources_result = [",\t".join(header)]
303
304 for i, item in enumerate(combined_sources, start=1):
305 combined_sources_result.append(f"{i},\t{item}")
306
307 combined_sources_result = "\n".join(combined_sources_result)
308
309 return combined_sources_result

Callers 1

combine_contextsFunction · 0.85

Calls 1

csv_string_to_listFunction · 0.85

Tested by

no test coverage detected