@ggboy123/dsh-paper-reader 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,7 @@
18
18
  环境变量(都可选):
19
19
  DPR_MAX_OUTPUT_TOKENS 单次请求的 max_tokens 上限,默认 8192;0 = 不传该参数
20
20
  DPR_SPLIT_TOKENS 触发拆分的输入上限(估算 token),默认 3000
21
+ DPR_OPENCODE_SESSION OpenCode Go 的稳定会话 ID;设置后每次 LLM 请求都带 x-opencode-session
21
22
  DPR_DEBUG=1 额外把补丁动作打到 stderr
22
23
  """
23
24
 
@@ -81,6 +82,7 @@ def _env_int(name: str, default: int) -> int:
81
82
 
82
83
  MAX_OUT = _env_int("DPR_MAX_OUTPUT_TOKENS", 8192)
83
84
  SPLIT_TOKENS = max(200, _env_int("DPR_SPLIT_TOKENS", 3000))
85
+ OPENCODE_SESSION = os.environ.get("DPR_OPENCODE_SESSION", "").strip()
84
86
  DEBUG = os.environ.get("DPR_DEBUG", "") not in ("", "0", "false", "False")
85
87
  REPORT_MIN_INTERVAL = 0.35 # 进度事件最小间隔(秒),别把 stdout 刷爆
86
88
 
@@ -239,6 +241,9 @@ def install_translation() -> None:
239
241
  extra_headers["X-DashScope-DataInspection"] = (
240
242
  '{"input": "disable", "output": "disable"}'
241
243
  )
244
+ if OPENCODE_SESSION:
245
+ # OpenCode Go:稳定会话 ID(整篇翻译的每次 LLM 请求都带),用于路由与提示词缓存
246
+ extra_headers["x-opencode-session"] = OPENCODE_SESSION
242
247
  extra_body = dict(getattr(self, "extra_body", {}) or {})
243
248
  if getattr(self, "_dpr_drop_thinking", False):
244
249
  # 端点明确拒绝 thinking 开关(如常思考模型)时彻底不提这个字段