"""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"
# 计算alarm_name占用的长度(包含换行符)
header_length=len(alarm_name)+1# +1 是换行符的长度
# Calculate the length occupied by the context prefix
header_length=len(context_prefix)
# 计算内容部分的最大长度
# Calculate the max length for the content portion