mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-06-02 21:13:44 +08:00
fix(translator): handle system role as developer in Claude request conversion
- Updated `ConvertClaudeRequestToGemini` logic to treat `system` role as `developer`. - Added unit test case to validate the behavior. Closes: #3510
This commit is contained in:
@@ -87,6 +87,9 @@ func ConvertClaudeRequestToCodex(modelName string, inputRawJSON []byte, _ bool)
|
||||
for i := 0; i < len(messageResults); i++ {
|
||||
messageResult := messageResults[i]
|
||||
messageRole := messageResult.Get("role").String()
|
||||
if messageRole == "system" {
|
||||
messageRole = "developer"
|
||||
}
|
||||
|
||||
newMessage := func() []byte {
|
||||
msg := []byte(`{"type":"message","role":"","content":[]}`)
|
||||
|
||||
@@ -42,6 +42,18 @@ func TestConvertClaudeRequestToCodex_SystemMessageScenarios(t *testing.T) {
|
||||
wantHasDeveloper: true,
|
||||
wantTexts: []string{"Be helpful"},
|
||||
},
|
||||
{
|
||||
name: "System role in messages",
|
||||
inputJSON: `{
|
||||
"model": "claude-3-opus",
|
||||
"messages": [
|
||||
{"role": "system", "content": "Follow the project instructions"},
|
||||
{"role": "user", "content": "hello"}
|
||||
]
|
||||
}`,
|
||||
wantHasDeveloper: true,
|
||||
wantTexts: []string{"Follow the project instructions"},
|
||||
},
|
||||
{
|
||||
name: "Array system field with filtered billing header",
|
||||
inputJSON: `{
|
||||
|
||||
Reference in New Issue
Block a user