mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
feat(codex): enhance input transformation and remove unused safety_identifier field
- Added logic to transform `inputResults` into structured JSON for improved processing. - Removed redundant `safety_identifier` field in executor payload to streamline requests.
This commit is contained in:
@@ -106,6 +106,7 @@ func (e *CodexExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, re
|
|||||||
body, _ = sjson.SetBytes(body, "stream", true)
|
body, _ = sjson.SetBytes(body, "stream", true)
|
||||||
body, _ = sjson.DeleteBytes(body, "previous_response_id")
|
body, _ = sjson.DeleteBytes(body, "previous_response_id")
|
||||||
body, _ = sjson.DeleteBytes(body, "prompt_cache_retention")
|
body, _ = sjson.DeleteBytes(body, "prompt_cache_retention")
|
||||||
|
body, _ = sjson.DeleteBytes(body, "safety_identifier")
|
||||||
if !gjson.GetBytes(body, "instructions").Exists() {
|
if !gjson.GetBytes(body, "instructions").Exists() {
|
||||||
body, _ = sjson.SetBytes(body, "instructions", "")
|
body, _ = sjson.SetBytes(body, "instructions", "")
|
||||||
}
|
}
|
||||||
@@ -215,6 +216,7 @@ func (e *CodexExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Au
|
|||||||
body = applyPayloadConfigWithRoot(e.cfg, baseModel, to.String(), "", body, originalTranslated)
|
body = applyPayloadConfigWithRoot(e.cfg, baseModel, to.String(), "", body, originalTranslated)
|
||||||
body, _ = sjson.DeleteBytes(body, "previous_response_id")
|
body, _ = sjson.DeleteBytes(body, "previous_response_id")
|
||||||
body, _ = sjson.DeleteBytes(body, "prompt_cache_retention")
|
body, _ = sjson.DeleteBytes(body, "prompt_cache_retention")
|
||||||
|
body, _ = sjson.DeleteBytes(body, "safety_identifier")
|
||||||
body, _ = sjson.SetBytes(body, "model", baseModel)
|
body, _ = sjson.SetBytes(body, "model", baseModel)
|
||||||
if !gjson.GetBytes(body, "instructions").Exists() {
|
if !gjson.GetBytes(body, "instructions").Exists() {
|
||||||
body, _ = sjson.SetBytes(body, "instructions", "")
|
body, _ = sjson.SetBytes(body, "instructions", "")
|
||||||
@@ -322,6 +324,7 @@ func (e *CodexExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth
|
|||||||
body, _ = sjson.SetBytes(body, "model", baseModel)
|
body, _ = sjson.SetBytes(body, "model", baseModel)
|
||||||
body, _ = sjson.DeleteBytes(body, "previous_response_id")
|
body, _ = sjson.DeleteBytes(body, "previous_response_id")
|
||||||
body, _ = sjson.DeleteBytes(body, "prompt_cache_retention")
|
body, _ = sjson.DeleteBytes(body, "prompt_cache_retention")
|
||||||
|
body, _ = sjson.DeleteBytes(body, "safety_identifier")
|
||||||
body, _ = sjson.SetBytes(body, "stream", false)
|
body, _ = sjson.SetBytes(body, "stream", false)
|
||||||
if !gjson.GetBytes(body, "instructions").Exists() {
|
if !gjson.GetBytes(body, "instructions").Exists() {
|
||||||
body, _ = sjson.SetBytes(body, "instructions", "")
|
body, _ = sjson.SetBytes(body, "instructions", "")
|
||||||
|
|||||||
@@ -74,6 +74,11 @@ func ConvertOpenAIResponsesRequestToCodex(modelName string, inputRawJSON []byte,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if hasOfficialInstructions {
|
if hasOfficialInstructions {
|
||||||
|
newInput := "[]"
|
||||||
|
for _, item := range inputResults {
|
||||||
|
newInput, _ = sjson.SetRaw(newInput, "-1", item.Raw)
|
||||||
|
}
|
||||||
|
rawJSON, _ = sjson.SetRawBytes(rawJSON, "input", []byte(newInput))
|
||||||
return rawJSON
|
return rawJSON
|
||||||
}
|
}
|
||||||
// log.Debugf("instructions not matched, %s\n", originalInstructions)
|
// log.Debugf("instructions not matched, %s\n", originalInstructions)
|
||||||
|
|||||||
Reference in New Issue
Block a user