feat(translator): add developer role support for Gemini translators
Unified · Split
| @@ -184,7 +184,7 @@ func ConvertOpenAIRequestToAntigravity(modelName string, inputRawJSON []byte, _ · 183 unmodified lines | |||
| 184 | role := m.Get("role").String() | 184 | role := m.Get("role").String() |
| 185 | content := m.Get("content") | 185 | content := m.Get("content") |
| 186 | 186 | ||
| 187 | if role == "system" && len(arr) > 1 { | 187 | if (role == "system" || role == "developer") && len(arr) > 1 { |
| 188 | // system -> request.systemInstruction as a user message style | 188 | // system -> request.systemInstruction as a user message style |
| 189 | if content.Type == gjson.String { | 189 | if content.Type == gjson.String { |
| 190 | out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user") | 190 | out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user") |
| @@ -201,7 +201,7 @@ func ConvertOpenAIRequestToAntigravity(modelName string, inputRawJSON []byte, _ · 10 unmodified lines | |||
| 201 | } | 201 | } |
| 202 | } | 202 | } |
| 203 | } | 203 | } |
| 204 | } else if role == "user" || (role == "system" && len(arr) == 1) { | 204 | } else if role == "user" || ((role == "system" || role == "developer") && len(arr) == 1) { |
| 205 | // Build single user content node to avoid splitting into multiple contents | 205 | // Build single user content node to avoid splitting into multiple contents |
| 206 | node := []byte(`{"role":"user","parts":[]}`) | 206 | node := []byte(`{"role":"user","parts":[]}`) |
| 207 | if content.Type == gjson.String { | 207 | if content.Type == gjson.String { |
| @@ -152,7 +152,7 @@ func ConvertOpenAIRequestToGeminiCLI(modelName string, inputRawJSON []byte, _ bo · 151 unmodified lines | |||
| 152 | role := m.Get("role").String() | 152 | role := m.Get("role").String() |
| 153 | content := m.Get("content") | 153 | content := m.Get("content") |
| 154 | 154 | ||
| 155 | if role == "system" && len(arr) > 1 { | 155 | if (role == "system" || role == "developer") && len(arr) > 1 { |
| 156 | // system -> request.systemInstruction as a user message style | 156 | // system -> request.systemInstruction as a user message style |
| 157 | if content.Type == gjson.String { | 157 | if content.Type == gjson.String { |
| 158 | out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user") | 158 | out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user") |
| @@ -169,7 +169,7 @@ func ConvertOpenAIRequestToGeminiCLI(modelName string, inputRawJSON []byte, _ bo · 10 unmodified lines | |||
| 169 | } | 169 | } |
| 170 | } | 170 | } |
| 171 | } | 171 | } |
| 172 | } else if role == "user" || (role == "system" && len(arr) == 1) { | 172 | } else if role == "user" || ((role == "system" || role == "developer") && len(arr) == 1) { |
| 173 | // Build single user content node to avoid splitting into multiple contents | 173 | // Build single user content node to avoid splitting into multiple contents |
| 174 | node := []byte(`{"role":"user","parts":[]}`) | 174 | node := []byte(`{"role":"user","parts":[]}`) |
| 175 | if content.Type == gjson.String { | 175 | if content.Type == gjson.String { |
| @@ -170,7 +170,7 @@ func ConvertOpenAIRequestToGemini(modelName string, inputRawJSON []byte, _ bool) · 169 unmodified lines | |||
| 170 | role := m.Get("role").String() | 170 | role := m.Get("role").String() |
| 171 | content := m.Get("content") | 171 | content := m.Get("content") |
| 172 | 172 | ||
| 173 | if role == "system" && len(arr) > 1 { | 173 | if (role == "system" || role == "developer") && len(arr) > 1 { |
| 174 | // system -> system_instruction as a user message style | 174 | // system -> system_instruction as a user message style |
| 175 | if content.Type == gjson.String { | 175 | if content.Type == gjson.String { |
| 176 | out, _ = sjson.SetBytes(out, "system_instruction.role", "user") | 176 | out, _ = sjson.SetBytes(out, "system_instruction.role", "user") |
| @@ -187,7 +187,7 @@ func ConvertOpenAIRequestToGemini(modelName string, inputRawJSON []byte, _ bool) · 10 unmodified lines | |||
| 187 | } | 187 | } |
| 188 | } | 188 | } |
| 189 | } | 189 | } |
| 190 | } else if role == "user" || (role == "system" && len(arr) == 1) { | 190 | } else if role == "user" || ((role == "system" || role == "developer") && len(arr) == 1) { |
| 191 | // Build single user content node to avoid splitting into multiple contents | 191 | // Build single user content node to avoid splitting into multiple contents |
| 192 | node := []byte(`{"role":"user","parts":[]}`) | 192 | node := []byte(`{"role":"user","parts":[]}`) |
| 193 | if content.Type == gjson.String { | 193 | if content.Type == gjson.String { |