"""Split content into segments with overlap control. Each segment starts with alarm_name followed by a newline. Total length does not exceed RERANK_MAX_LENGTH."""
segments=[]
start=0
content_length=len(content)
# Handle empty alarm name
ifnotalarm_name:
alarm_name=""
label_str=",".join(labels)iflabelselse"无"
# Context template
context_prefix=f"{alarm_name}\n标签:{label_str}\n"
# Calculate the length occupied by the context prefix
header_length=len(context_prefix)
# Calculate the max length for the content portion