History

Merge pull request #850 from can1357/main

feat(translator): add developer role support for Gemini translators

Luis Pater committed 10 months ago

Commit 8f8dfd02 parents 9f1b445 6762e083 files · +6 −6Browse files

Unified · Split

3 files
  1. internal/translator/antigravity/openai/chat-completions/antigravity_openai_request.go +2 −2
  2. internal/translator/gemini-cli/openai/chat-completions/gemini-cli_openai_request.go +2 −2
  3. internal/translator/gemini/openai/chat-completions/gemini_openai_request.go +2 −2
internal/translator/antigravity/openai/chat-completions/antigravity_openai_request.go+2−2
@@ -184,7 +184,7 @@ func ConvertOpenAIRequestToAntigravity(modelName string, inputRawJSON []byte, _ · 183 unmodified lines
184184 role := m.Get("role").String()
185185 content := m.Get("content")
186186
187− if role == "system" && len(arr) > 1 {
187+ if (role == "system" || role == "developer") && len(arr) > 1 {
188188 // system -> request.systemInstruction as a user message style
189189 if content.Type == gjson.String {
190190 out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user")
@@ -201,7 +201,7 @@ func ConvertOpenAIRequestToAntigravity(modelName string, inputRawJSON []byte, _ · 10 unmodified lines
201201 }
202202 }
203203 }
204− } else if role == "user" || (role == "system" && len(arr) == 1) {
204+ } else if role == "user" || ((role == "system" || role == "developer") && len(arr) == 1) {
205205 // Build single user content node to avoid splitting into multiple contents
206206 node := []byte(`{"role":"user","parts":[]}`)
207207 if content.Type == gjson.String {
internal/translator/gemini-cli/openai/chat-completions/gemini-cli_openai_request.go+2−2
@@ -152,7 +152,7 @@ func ConvertOpenAIRequestToGeminiCLI(modelName string, inputRawJSON []byte, _ bo · 151 unmodified lines
152152 role := m.Get("role").String()
153153 content := m.Get("content")
154154
155− if role == "system" && len(arr) > 1 {
155+ if (role == "system" || role == "developer") && len(arr) > 1 {
156156 // system -> request.systemInstruction as a user message style
157157 if content.Type == gjson.String {
158158 out, _ = sjson.SetBytes(out, "request.systemInstruction.role", "user")
@@ -169,7 +169,7 @@ func ConvertOpenAIRequestToGeminiCLI(modelName string, inputRawJSON []byte, _ bo · 10 unmodified lines
169169 }
170170 }
171171 }
172− } else if role == "user" || (role == "system" && len(arr) == 1) {
172+ } else if role == "user" || ((role == "system" || role == "developer") && len(arr) == 1) {
173173 // Build single user content node to avoid splitting into multiple contents
174174 node := []byte(`{"role":"user","parts":[]}`)
175175 if content.Type == gjson.String {
internal/translator/gemini/openai/chat-completions/gemini_openai_request.go+2−2
@@ -170,7 +170,7 @@ func ConvertOpenAIRequestToGemini(modelName string, inputRawJSON []byte, _ bool) · 169 unmodified lines
170170 role := m.Get("role").String()
171171 content := m.Get("content")
172172
173− if role == "system" && len(arr) > 1 {
173+ if (role == "system" || role == "developer") && len(arr) > 1 {
174174 // system -> system_instruction as a user message style
175175 if content.Type == gjson.String {
176176 out, _ = sjson.SetBytes(out, "system_instruction.role", "user")
@@ -187,7 +187,7 @@ func ConvertOpenAIRequestToGemini(modelName string, inputRawJSON []byte, _ bool) · 10 unmodified lines
187187 }
188188 }
189189 }
190− } else if role == "user" || (role == "system" && len(arr) == 1) {
190+ } else if role == "user" || ((role == "system" || role == "developer") && len(arr) == 1) {
191191 // Build single user content node to avoid splitting into multiple contents
192192 node := []byte(`{"role":"user","parts":[]}`)
193193 if content.Type == gjson.String {