Normalize OAI messages before conversion and update tool-call prompt

This commit is contained in:
Liang Jiaqing
2026-04-22 17:15:12 +08:00
parent b34cffe801
commit 274d47f35f

View File

@@ -623,10 +623,9 @@ class NativeClaudeSession(BaseSession):
return MockResponse(thinking, content, tool_calls, str(content_blocks))
class NativeOAISession(NativeClaudeSession):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def raw_ask(self, messages):
"""OpenAI streaming. yields text chunks, generator return = list[content_block]"""
messages = _fix_messages(messages)
msgs = ([{"role": "system", "content": self.system}] if self.system else []) + _msgs_claude2oai(messages)
return (yield from _openai_stream(self.api_base, self.api_key, msgs, self.model, self.api_mode,
temperature=self.temperature, max_tokens=self.max_tokens,
@@ -893,17 +892,17 @@ class MixinSession:
THINKING_PROMPT_ZH = """
### 行动规范(持续有效)
每次回复请遵循
每次回复请先在回复文字中包含
1. 在 <thinking></thinking> 标签中先分析现状和策略
2. 在 <summary></summary> 中输出极简单行(<30字物理快照上次结果新信息+本次意图。此内容进入长期工作记忆。
3. 然后才能输出工具调用
\n**除了最后回答,必须进行工具调用**
""".strip()
THINKING_PROMPT_EN = """
### Action Protocol (always in effect)
For every reply, follow these steps:
The reply body should first include:
1. Analyze the current situation and strategy inside <thinking></thinking>
2. Output a minimal one-line (<30 words) physical snapshot in <summary></summary>: new info from last result + current intent. This goes into long-term working memory.
3. Then output tool calls
\n**Tool calls are required for every turn except the final answer!**
""".strip()
class NativeToolClient: