mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
- Added `examples/custom-provider/main.go` showcasing custom executor and translator integration using the SDK. - Removed redundant debug logs from translator modules to enhance code cleanliness. - Updated SDK documentation with new usage and advanced examples. - Expanded the management API with new endpoints, including request logging and GPT-5 Codex features.
37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
package responses
|
|
|
|
import (
|
|
"context"
|
|
|
|
. "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/gemini/openai/responses"
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
func ConvertGeminiCLIResponseToOpenAIResponses(ctx context.Context, modelName string, originalRequestRawJSON, requestRawJSON, rawJSON []byte, param *any) []string {
|
|
responseResult := gjson.GetBytes(rawJSON, "response")
|
|
if responseResult.Exists() {
|
|
rawJSON = []byte(responseResult.Raw)
|
|
}
|
|
return ConvertGeminiResponseToOpenAIResponses(ctx, modelName, originalRequestRawJSON, requestRawJSON, rawJSON, param)
|
|
}
|
|
|
|
func ConvertGeminiCLIResponseToOpenAIResponsesNonStream(ctx context.Context, modelName string, originalRequestRawJSON, requestRawJSON, rawJSON []byte, param *any) string {
|
|
responseResult := gjson.GetBytes(rawJSON, "response")
|
|
if responseResult.Exists() {
|
|
rawJSON = []byte(responseResult.Raw)
|
|
}
|
|
|
|
requestResult := gjson.GetBytes(originalRequestRawJSON, "request")
|
|
if responseResult.Exists() {
|
|
originalRequestRawJSON = []byte(requestResult.Raw)
|
|
}
|
|
|
|
requestResult = gjson.GetBytes(requestRawJSON, "request")
|
|
if responseResult.Exists() {
|
|
requestRawJSON = []byte(requestResult.Raw)
|
|
}
|
|
|
|
return ConvertGeminiResponseToOpenAIResponsesNonStream(ctx, modelName, originalRequestRawJSON, requestRawJSON, rawJSON, param)
|
|
}
|