mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-19 04:40:52 +08:00
refactor(codex): remove codex instructions injection support
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/misc"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/tidwall/sjson"
|
||||
)
|
||||
@@ -20,7 +19,7 @@ func ConvertCodexResponseToOpenAIResponses(ctx context.Context, modelName string
|
||||
typeStr := typeResult.String()
|
||||
if typeStr == "response.created" || typeStr == "response.in_progress" || typeStr == "response.completed" {
|
||||
if gjson.GetBytes(rawJSON, "response.instructions").Exists() {
|
||||
instructions := selectInstructions(originalRequestRawJSON, requestRawJSON)
|
||||
instructions := gjson.GetBytes(originalRequestRawJSON, "instructions").String()
|
||||
rawJSON, _ = sjson.SetBytes(rawJSON, "response.instructions", instructions)
|
||||
}
|
||||
}
|
||||
@@ -42,15 +41,8 @@ func ConvertCodexResponseToOpenAIResponsesNonStream(_ context.Context, modelName
|
||||
responseResult := rootResult.Get("response")
|
||||
template := responseResult.Raw
|
||||
if responseResult.Get("instructions").Exists() {
|
||||
template, _ = sjson.Set(template, "instructions", selectInstructions(originalRequestRawJSON, requestRawJSON))
|
||||
instructions := gjson.GetBytes(originalRequestRawJSON, "instructions").String()
|
||||
template, _ = sjson.Set(template, "instructions", instructions)
|
||||
}
|
||||
return template
|
||||
}
|
||||
|
||||
func selectInstructions(originalRequestRawJSON, requestRawJSON []byte) string {
|
||||
userAgent := misc.ExtractCodexUserAgent(originalRequestRawJSON)
|
||||
if misc.IsOpenCodeUserAgent(userAgent) {
|
||||
return gjson.GetBytes(requestRawJSON, "instructions").String()
|
||||
}
|
||||
return gjson.GetBytes(originalRequestRawJSON, "instructions").String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user