def merge_struct()

in src/models/struxgpt_v1.py [0:0]


    def merge_struct(title: Optional[str], struct_list: Union[List["StructItem"], List[dict]]):
        assert len(struct_list)
        if isinstance(struct_list[0], dict):
            struct_list = [StructItem(struct_dict=data_res) for data_res in struct_list]
        if not title:
            title = ', '.join([struct_item.scope for struct_item in struct_list])

        data_dict = {
            'scope': title,
            'aspects': []
        }
        for struct_res in struct_list:
            data_dict['aspects'].extend([aspect.to_json() for aspect in struct_res.aspects])

        return StructItem(struct_dict=data_dict)