| |
| |
| |
| |
| |
| package geminiCLI |
|
|
| import ( |
| "bytes" |
|
|
| . "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/openai/gemini" |
| "github.com/tidwall/gjson" |
| "github.com/tidwall/sjson" |
| ) |
|
|
| |
| |
| |
| func ConvertGeminiCLIRequestToOpenAI(modelName string, inputRawJSON []byte, stream bool) []byte { |
| rawJSON := bytes.Clone(inputRawJSON) |
| rawJSON = []byte(gjson.GetBytes(rawJSON, "request").Raw) |
| rawJSON, _ = sjson.SetBytes(rawJSON, "model", modelName) |
| if gjson.GetBytes(rawJSON, "systemInstruction").Exists() { |
| rawJSON, _ = sjson.SetRawBytes(rawJSON, "system_instruction", []byte(gjson.GetBytes(rawJSON, "systemInstruction").Raw)) |
| rawJSON, _ = sjson.DeleteBytes(rawJSON, "systemInstruction") |
| } |
|
|
| return ConvertGeminiRequestToOpenAI(modelName, rawJSON, stream) |
| } |
|
|