apply_environment_note.py 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. """Apply the user's offline Doubao environment note to presentation copies only."""
  2. from pathlib import Path
  3. import hashlib
  4. import json
  5. WORK = Path(__file__).resolve().parent
  6. POLICY = 'offline-doubao-environment-user-note-20261109'
  7. def main():
  8. edits = json.loads((WORK / 'presentation-edits.json').read_bytes())
  9. def change(path, replacements, original=None):
  10. target = WORK / path
  11. original = original or path
  12. value = (WORK / original).read_text(encoding='utf-8') if not target.exists() else target.read_text(encoding='utf-8')
  13. for before, after in replacements:
  14. if before not in value:
  15. assert any(e.get('policy') == POLICY and e['display'] == path and e['before'] == before for e in edits['edits'])
  16. continue
  17. assert value.count(before) == 1, path
  18. value = value.replace(before, after, 1)
  19. record = {'policy': POLICY, 'source': original, 'display': path,
  20. 'before': before, 'after': after,
  21. 'reason': 'remove model/tool payment or collection-cost framing following user environment clarification; preserve product economics and raw dialogue'}
  22. if record not in edits['edits']:
  23. edits['edits'].append(record)
  24. target.write_text(value, encoding='utf-8')
  25. change('rounds/R03/prompt-display.txt', [
  26. ('可继续用已有授权和免费公开来源补充必要证据;涉及新增费用时,先给具体采集范围、用途和预算。',
  27. '可继续用已有授权范围内的公开来源补充必要证据。'),
  28. ], 'rounds/R03/prompt-verbatim.txt')
  29. change('rounds/R04/prompt-display.txt', [
  30. ('免费公开资料', '公开资料'),
  31. ('继续在已有授权和无新增费用范围内补证,不把每品牌30条当作充分验证。涉及付费或实物测试时,再提出具体方案和预算。',
  32. '继续在已有授权范围内补证,不把每品牌30条当作充分验证。涉及实物测试时,先提出具体方案。'),
  33. ], 'rounds/R04/prompt-verbatim.txt')
  34. change('rounds/R03/reply-display.md', [
  35. ('问题 2 零费用,库内定向检索即可;', '问题 2 可在库内定向检索;'),
  36. ])
  37. change('rounds/R02/artifacts/atlas-display.html', [
  38. ('本轮未采集、未付费、未做实物测试', '本轮未采集、未做实物测试'),
  39. ])
  40. change('rounds/R03/artifacts/atlas-display.html', [
  41. ('研究问题 1 的成本最高(需外部采集授权),问题 2 成本最低(库内定向检索即可,零费用)。',
  42. '研究问题 1 需外部采集,问题 2 可在库内定向检索。'),
  43. ('未采集、未付费、未做实物测试、未改研究资料', '未采集、未做实物测试、未改研究资料'),
  44. ])
  45. change('rounds/R04/artifacts/comparison-display.html', [
  46. ('零新增费用,未购样、未实测', '未购样、未实测'),
  47. ('本页零付费、未购样、未做实物测试', '本页未购样、未做实物测试'),
  48. ])
  49. # This was already provided to the user. Preserve it; prepare an alternate
  50. # wording without implying that it has been forwarded or executed.
  51. change('rounds/R05/prompt-current.txt', [
  52. ('本轮继续使用免费公开资料,不购样、不付费测试。',
  53. '本轮先核对公开资料,暂不购样或开展实物测试。'),
  54. ], 'rounds/R05/prompt-verbatim.txt')
  55. edits['environmentPolicyApplied'] = POLICY
  56. (WORK / 'presentation-edits.json').write_text(json.dumps(edits, ensure_ascii=False, indent=2) + '\n', encoding='utf-8')
  57. case = json.loads((WORK / 'case.json').read_bytes())
  58. case['operatingContext'] = {
  59. 'source': 'user-explicit-environment-note', 'date': '2026-11-09',
  60. 'platform': 'offline classroom uses Doubao with free Skill installation and workflow execution',
  61. 'modelAndSkillPaymentFraming': 'omit from prompts, feedback, acceptance and demonstration',
  62. 'productEconomicsStillRelevant': True,
  63. 'physicalResources': 'state concrete needs when relevant; do not conflate with model execution',
  64. 'actualCapabilities': 'verify actual access separately; free installation does not prove collection availability',
  65. 'originalDialoguePreserved': True}
  66. fifth = next(r for r in case['rounds'] if r['roundId'] == 'R05')
  67. fifth['currentPromptPath'] = 'rounds/R05/prompt-current.txt'
  68. fifth['promptVariantReason'] = 'user clarified offline Doubao environment after original prompt was provided'
  69. for original, digest in edits['originalFileSha256'].items():
  70. assert hashlib.sha256((WORK / original).read_bytes()).hexdigest() == digest
  71. (WORK / 'case.json').write_text(json.dumps(case, ensure_ascii=False, indent=2) + '\n', encoding='utf-8')
  72. print(json.dumps({'environmentNoteRecorded': True, 'rawDialogueUnchanged': True,
  73. 'newBusinessExecution': False}, ensure_ascii=False))
  74. if __name__ == '__main__':
  75. main()