mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-29 17:19:36 +02:00
9 lines
357 B
Python
9 lines
357 B
Python
def flatten_child_categories(category: dict) -> list[dict]:
|
|
if not category["child_categories"]:
|
|
return [category]
|
|
else:
|
|
flattened_categories = [category]
|
|
for child_category in category["child_categories"]:
|
|
flattened_categories.extend(flatten_child_categories(child_category))
|
|
return flattened_categories
|