This commit is contained in:
zyp
2026-11-02 09:28:08 +08:00
parent e343640105
commit 53ba04606b
56 changed files with 49973 additions and 2 deletions
@@ -0,0 +1,82 @@
"""User-facing wording only; raw evidence remains available to planning and audit."""
import re
from decimal import Decimal, InvalidOperation
def numeric_display(value, unit=''):
"""Format declared measures without float rounding or guessing their units."""
if value in (None, ''):
return '未提供'
try:
amount = Decimal(str(value))
if not amount.is_finite():
return '未提供'
places = max(2 if unit in {'元', '万元'} else 0, -amount.as_tuple().exponent)
return f'{amount:,.{places}f}' + (f' {unit}' if unit else '')
except InvalidOperation:
return str(value)
ANSWER_STYLE = (
"保留充分的业务分析、具体依据、相关明细和表格,不为了简短删减有用内容。"
"answer正文使用Markdown排版:先用简短一段直接回答,重点数量、金额或结论可用**加粗**;"
"按内容需要分段、使用小标题和列表,不把整篇挤在一个段落,也不要每句话都加标题。"
"同类多条记录适合用表格;字段较多时只将关键字段放入表格,必要说明放在表格外。"
"表格前后必须换行,表头、分隔行及每条数据各占一行,不能把多行表格拼成一行;"
"JSON字符串中用合法的\\n表示换行,解析后应为真实换行,不输出双重转义的换行符或包裹全文的代码块。"
"排版不能新增业务事实或指标。只展示本题有关且证据中实际存在的字段;缺失值不得补成0。"
"本题涉及且已提供的数值保留原始单位和精度,可用千位分隔;不引入用户未询问的其他指标。"
"面向实际使用者表达,不介绍接口、字段键、资源ID、权限实现、审校过程或系统内部规则。"
"只说明本题实际缺少的信息,不引入其他业务的限制或术语。"
"限制说明仅在影响本题结论时出现,并就具体缺少的信息说一次;不要在开头、正文、表格后重复免责声明。"
"没有评价标准时,区分可观察的内容问题与正式考核结论,不重复‘不能认定敷衍’。"
"不要固定追加‘查询范围:当前登录账号有权查看的信息’、数据时间或‘以实际数据为准’;"
"实际筛选的人、部门、日期与重要统计口径仍应自然写入答案。"
"空结果有必要时给一个贴合问题的下一步建议;结果正常时不固定邀请用户继续提问。"
"输出前检查重复:开头已说的结论不再在结尾写‘结论’复述;多条明细共有的缺失项只在表格外说明一次,"
"不在每行写‘正文为空’。用户需要的是业务结果,不能把同一限制扩写成几个段落。"
"按实际问题组织为结论、必要明细和影响结论的缺失信息,不套用其他业务的答案。"
"用户询问具体内容时,answer必须包含已取得的实际内容,不能只写‘具体内容如下’就结束。"
"全部用户可见文字、列表和表格都写在answer字符串内部;source_ids只用于引用,不能代替正文。"
)
_BOILERPLATE = (
"当前仅展示可读取的记录;完成所问判断仍缺少必要的业务依据,请以说明的数据范围为准。",
)
def display_note(note, definition=None):
"""Remove known presentation boilerplate, never discard unknown business caveats."""
text = (note or '').strip()
for phrase in _BOILERPLATE:
text = text.replace(phrase, '')
# Only remove an exact registered scope description consisting solely of access
# mechanics. Descriptions containing business limitations remain untouched.
scope = (definition or {}).get('scope_description', '')
if scope and re.fullmatch(r'[^;。\n]*(?:权限|数据范围|DataScope)[。]?', scope) and not any(
word in scope for word in ('仅', '不包含', '不等于', '未', '不能', '只', '除')
):
text = text.replace(scope, '')
text = re.sub(r'已读取当前授权条件内全部\d+条记录后计算,最后分页展示;?', '', text)
text = text.replace('结果总数为分组数;缺失数值不当作0。', '')
text = text.replace('按读取时状态统计,不代表历史快照。', '按目前登记的状态统计。')
return text.replace('。;', '。').strip(';; \n')
def append_note(blocks, note, definition=None):
text = display_note(note, definition)
if text and text not in '\n\n'.join(blocks):
blocks.append(text)
def answer_footer(payload):
# The panel already communicates permission scope. Keep specific scopes and
# freshness, but avoid repeating the generic permission banner in every answer.
scope = payload.scope_label.strip()
generic = {'当前登录账号有权查看的信息', '当前账号授权范围', '当前权限', '授权范围'}
parts = []
if scope and scope not in generic:
parts.append(f'查询范围:{scope}')
if payload.data_time:
parts.append(f'数据时间:{payload.data_time}')
return '\n'.join(parts)