mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
Merge pull request #850 from can1357/main
feat(translator): add developer role support for Gemini translators
This commit is contained in:
@@ -184,7 +184,7 @@ func ConvertOpenAIRequestToAntigravity(modelName string, inputRawJSON []byte, _
|
|||||||
role := m.Get("role").String()
|
role := m.Get("role").String()
|
||||||
content := m.Get("content")
|
content := m.Get("content")
|
||||||
|
|
||||||
if role == "system" && len(arr) > 1 {
|
if (role == "system" || role == "developer") && len(arr) > 1 {
|
||||||
// system -> request.systemInstruction as a user message style
|
// system -> request.systemInstruction as a user message style
|
||||||
if content.Type == gjson.String {
|
if content.Type == gjson.String {
|
||||||
out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user")
|
out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user")
|
||||||
@@ -201,7 +201,7 @@ func ConvertOpenAIRequestToAntigravity(modelName string, inputRawJSON []byte, _
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if role == "user" || (role == "system" && len(arr) == 1) {
|
} else if role == "user" || ((role == "system" || role == "developer") && len(arr) == 1) {
|
||||||
// Build single user content node to avoid splitting into multiple contents
|
// Build single user content node to avoid splitting into multiple contents
|
||||||
node := []byte(`{"role":"user","parts":[]}`)
|
node := []byte(`{"role":"user","parts":[]}`)
|
||||||
if content.Type == gjson.String {
|
if content.Type == gjson.String {
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ func ConvertOpenAIRequestToGeminiCLI(modelName string, inputRawJSON []byte, _ bo
|
|||||||
role := m.Get("role").String()
|
role := m.Get("role").String()
|
||||||
content := m.Get("content")
|
content := m.Get("content")
|
||||||
|
|
||||||
if role == "system" && len(arr) > 1 {
|
if (role == "system" || role == "developer") && len(arr) > 1 {
|
||||||
// system -> request.systemInstruction as a user message style
|
// system -> request.systemInstruction as a user message style
|
||||||
if content.Type == gjson.String {
|
if content.Type == gjson.String {
|
||||||
out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user")
|
out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user")
|
||||||
@@ -169,7 +169,7 @@ func ConvertOpenAIRequestToGeminiCLI(modelName string, inputRawJSON []byte, _ bo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if role == "user" || (role == "system" && len(arr) == 1) {
|
} else if role == "user" || ((role == "system" || role == "developer") && len(arr) == 1) {
|
||||||
// Build single user content node to avoid splitting into multiple contents
|
// Build single user content node to avoid splitting into multiple contents
|
||||||
node := []byte(`{"role":"user","parts":[]}`)
|
node := []byte(`{"role":"user","parts":[]}`)
|
||||||
if content.Type == gjson.String {
|
if content.Type == gjson.String {
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ func ConvertOpenAIRequestToGemini(modelName string, inputRawJSON []byte, _ bool)
|
|||||||
role := m.Get("role").String()
|
role := m.Get("role").String()
|
||||||
content := m.Get("content")
|
content := m.Get("content")
|
||||||
|
|
||||||
if role == "system" && len(arr) > 1 {
|
if (role == "system" || role == "developer") && len(arr) > 1 {
|
||||||
// system -> system_instruction as a user message style
|
// system -> system_instruction as a user message style
|
||||||
if content.Type == gjson.String {
|
if content.Type == gjson.String {
|
||||||
out, _ = sjson.SetBytes(out, "system_instruction.role", "user")
|
out, _ = sjson.SetBytes(out, "system_instruction.role", "user")
|
||||||
@@ -187,7 +187,7 @@ func ConvertOpenAIRequestToGemini(modelName string, inputRawJSON []byte, _ bool)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if role == "user" || (role == "system" && len(arr) == 1) {
|
} else if role == "user" || ((role == "system" || role == "developer") && len(arr) == 1) {
|
||||||
// Build single user content node to avoid splitting into multiple contents
|
// Build single user content node to avoid splitting into multiple contents
|
||||||
node := []byte(`{"role":"user","parts":[]}`)
|
node := []byte(`{"role":"user","parts":[]}`)
|
||||||
if content.Type == gjson.String {
|
if content.Type == gjson.String {
|
||||||
|
|||||||
Reference in New Issue
Block a user