Merge pull request #858 from Fwind43/fix/claude-stream-thinking
feat(claude): 新增 show_thinking 选项,可关闭 redact-thinking 让思考过程流式显示
This commit is contained in:
3 files changed
+4
No files matched your search
@@ -808,6 +808,7 @@ class NativeClaudeSession(BaseSession):
|
||||
self.tools = None
|
||||
if self.user_agent == self.default_ua: self.user_agent = self.native_ua
|
||||
self.api_key_header = str(cfg.get('api_key_header', 'auto')).strip().lower()
|
||||
self.show_thinking = bool(cfg.get('show_thinking')) # True: stream thinking text (like CC showThinkingSummaries)
|
||||
def raw_ask(self, messages):
|
||||
if self.max_tokens is None: self.max_tokens = 8192
|
||||
model = self.model
|
||||
@@ -815,6 +816,7 @@ class NativeClaudeSession(BaseSession):
|
||||
if 'claude' in model.lower(): messages = _drop_unsigned_thinking(messages)
|
||||
messages = _ensure_thinking_blocks(messages, self.model)
|
||||
beta_parts = ["claude-code-20250219", "interleaved-thinking-2025-05-14", "redact-thinking-2026-02-12", "thinking-token-count-2026-05-13", "context-management-2025-06-27", "prompt-caching-scope-2026-01-05", "mid-conversation-system-2026-04-07", "effort-2025-11-24", "fallback-credit-2026-06-01"]
|
||||
if self.show_thinking: beta_parts.remove("redact-thinking-2026-02-12")
|
||||
if "[1m]" in model.lower():
|
||||
beta_parts.insert(1, "context-1m-2025-08-07"); model = model.replace("[1m]", "").replace("[1M]", "")
|
||||
headers = {"Content-Type": "application/json", "anthropic-version": "2023-06-01",
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
# 'thinking_type': 'adaptive', # Claude 思考:adaptive / enabled / disabled
|
||||
# 'thinking_budget_tokens': 32768, # thinking_type='enabled' 时需要
|
||||
# 'claude_compat': 'half', # 需要 Claude Code 请求格式/指纹校验的透传渠道(simple=仅身份行,half=含 CC 主提示)
|
||||
# 'show_thinking': True, # Claude:流式显示思考过程(默认按 Claude Code 隐藏)
|
||||
# 'api_key_header': 'x-api-key', # Claude 鉴权头不匹配时指定;也支持 bearer
|
||||
# 'api_mode': 'responses', # OAI:默认 chat_completions,按渠道要求修改
|
||||
# 运行中也可临时调整,例如:/session.reasoning_effort=high
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
# 'thinking_type': 'adaptive', # Claude thinking: adaptive / enabled / disabled
|
||||
# 'thinking_budget_tokens': 32768, # Required when thinking_type='enabled'
|
||||
# 'claude_compat': 'half', # Relays requiring CC request format/fingerprint (simple=identity only, half=+CC main prompt)
|
||||
# 'show_thinking': True, # Claude: stream thinking text (hidden by default, as in Claude Code)
|
||||
# 'api_key_header': 'x-api-key', # Override Claude auth header; also supports bearer
|
||||
# 'api_mode': 'responses', # OAI: default is chat_completions; follow provider docs
|
||||
# Temporary runtime overrides also work, e.g. /session.reasoning_effort=high
|
||||
|
||||
Reference in new issue
Block a user