Update core logic and prompts
This commit is contained in:
11
sidercall.py
11
sidercall.py
@@ -92,15 +92,16 @@ class ToolClient:
|
||||
tool_instruction = f"""
|
||||
### ⚡️ 交互协议 (必须严格遵守)
|
||||
请按照以下步骤思考并行动:
|
||||
1. **思考**: 在 `<thinking>` 标签中分析现状和策略。
|
||||
2. **行动**: 如果需要调用工具,请紧接着输出一个 **<tool_use>块**,然后结束,我会稍后给你返回<tool_result>块。
|
||||
1. **思考**: 在 `<thinking>` 标签中先进行思考,分析现状和策略。
|
||||
2. **总结**: 在 `<summary>` 中输出*极为简短*的高度概括的单行(<30字)物理快照,包括上次工具调用结果获取的新信息+本次工具调用意图和预期。此内容将进入长期工作记忆,记录关键信息,严禁输出无实际信息增量的描述。
|
||||
3. **行动**: 如果需要调用工具,请紧接着输出一个 **<tool_use>块**,然后结束,我会稍后给你返回<tool_result>块。
|
||||
格式: ```<tool_use>\n{{"function": "工具名", "arguments": {{参数}}}}\n</tool_use>\n```
|
||||
|
||||
### 🛠️ 可用工具库
|
||||
{tools_json}
|
||||
"""
|
||||
if self.auto_save_tokens and self.last_tools == tools_json:
|
||||
tool_instruction = "\n### ⚡️ 交互协议保持不变,继续使用之前的工具库。\n"
|
||||
tool_instruction = "\n### 交互协议保持不变,沿用之前的协议和工具库。\n"
|
||||
else:
|
||||
self.total_cd_tokens = 0
|
||||
self.last_tools = tools_json
|
||||
@@ -109,8 +110,8 @@ class ToolClient:
|
||||
for m in history_msgs:
|
||||
role = "USER" if m['role'] == 'user' else "ASSISTANT"
|
||||
prompt += f"=== {role} ===\n{m['content']}\n\n"
|
||||
self.total_cd_tokens += len(m['content'])
|
||||
|
||||
self.total_cd_tokens += len(prompt)
|
||||
if self.total_cd_tokens > 9000: self.last_tools = ''
|
||||
|
||||
prompt += "=== ASSISTANT ===\n"
|
||||
@@ -149,6 +150,8 @@ class ToolClient:
|
||||
except json.JSONDecodeError:
|
||||
print("[Warn] Failed to parse tool_use JSON:", json_str)
|
||||
thinking += f"[Warn] JSON 解析失败,模型输出了无效的 JSON."
|
||||
except Exception as e:
|
||||
print("[Error] Exception during tool_use parsing:", str(e), data)
|
||||
|
||||
content = remaining_text.strip()
|
||||
if not content: content = ""
|
||||
|
||||
Reference in New Issue
Block a user