[GH-ISSUE #44] 请教关于剔除"role = system "的问题 #29

Closed
opened 2026-02-27 01:55:54 +03:00 by kerem · 4 comments
Owner

Originally created by @vank3f3 on GitHub (Feb 24, 2025).
Original GitHub issue: https://github.com/ErlichLiu/DeepClaude/issues/44

请教关于在重新打包 message 的时候,剔除"role = system " 的原因是什么?

Originally created by @vank3f3 on GitHub (Feb 24, 2025). Original GitHub issue: https://github.com/ErlichLiu/DeepClaude/issues/44 请教关于在重新打包 message 的时候,剔除"role = system " 的原因是什么?
kerem 2026-02-27 01:55:54 +03:00
Author
Owner

@GowayLee commented on GitHub (Feb 24, 2025):

According to Anthropic api doc, there is no role named system. So, we just remove the message with role = system.

As for improvement, we can add logic to convert system message to system parameter in the request body, which is supported by Anthropic.

<!-- gh-comment-id:2677682381 --> @GowayLee commented on GitHub (Feb 24, 2025): According to [Anthropic api doc](https://docs.anthropic.com/en/api/messages#body-messages), there is no role named `system`. So, we just remove the message with `role = system`. As for improvement, we can add logic to convert `system message` to `system` parameter in the request body, which is supported by Anthropic.
Author
Owner

@vank3f3 commented on GitHub (Feb 24, 2025):

非常感谢,明白了!"role"没有"system",是需要主动将system转为”system“。

import anthropic

client = anthropic.Anthropic()

response = client.messages.create(
    model="claude-3-5-sonnet-20241022",
    max_tokens=2048,
    system="You are a seasoned data scientist at a Fortune 500 company.", # <-- role prompt
    messages=[
        {"role": "user", "content": "Analyze this dataset for anomalies: <dataset>{{DATASET}}</dataset>"}
    ]
)

print(response.content)

<!-- gh-comment-id:2677778696 --> @vank3f3 commented on GitHub (Feb 24, 2025): 非常感谢,明白了!"role"没有"system",是需要主动将system转为”system“。 ``` import anthropic client = anthropic.Anthropic() response = client.messages.create( model="claude-3-5-sonnet-20241022", max_tokens=2048, system="You are a seasoned data scientist at a Fortune 500 company.", # <-- role prompt messages=[ {"role": "user", "content": "Analyze this dataset for anomalies: <dataset>{{DATASET}}</dataset>"} ] ) print(response.content) ```
Author
Owner

@ErlichLiu commented on GitHub (Feb 24, 2025):

@vank3f3 感谢反馈,说的确实非常有道理。当时图省事就移除了,确实是应该改为 system 加进去的。我们下个版本将更新进去。

<!-- gh-comment-id:2677791313 --> @ErlichLiu commented on GitHub (Feb 24, 2025): @vank3f3 感谢反馈,说的确实非常有道理。当时图省事就移除了,确实是应该改为 system 加进去的。我们下个版本将更新进去。
Author
Owner

@GowayLee commented on GitHub (Feb 25, 2025):

已添加逻辑实现兼容

<!-- gh-comment-id:2681595781 --> @GowayLee commented on GitHub (Feb 25, 2025): 已添加逻辑实现兼容
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/DeepClaude#29
No description provided.