mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 13:00:52 +08:00
docs: add GPT-5 Codex guidelines for internal usage
- Added comprehensive instructions for Codex CLI harness, sandboxing, approvals, and editing constraints to `internal/misc/codex_instructions/`. - Clarified `approval_policy` configurations and scenarios requiring escalated permissions. - Provided detailed style and structure guidelines for presenting results in the Codex CLI.
This commit is contained in:
@@ -39,8 +39,8 @@ func ConvertClaudeRequestToCodex(modelName string, inputRawJSON []byte, _ bool)
|
||||
|
||||
template := `{"model":"","instructions":"","input":[]}`
|
||||
|
||||
instructions := misc.CodexInstructions(modelName)
|
||||
template, _ = sjson.SetRaw(template, "instructions", instructions)
|
||||
_, instructions := misc.CodexInstructionsForModel(modelName, "")
|
||||
template, _ = sjson.Set(template, "instructions", instructions)
|
||||
|
||||
rootResult := gjson.ParseBytes(rawJSON)
|
||||
template, _ = sjson.Set(template, "model", modelName)
|
||||
|
||||
@@ -42,8 +42,8 @@ func ConvertGeminiRequestToCodex(modelName string, inputRawJSON []byte, _ bool)
|
||||
out := `{"model":"","instructions":"","input":[]}`
|
||||
|
||||
// Inject standard Codex instructions
|
||||
instructions := misc.CodexInstructions(modelName)
|
||||
out, _ = sjson.SetRaw(out, "instructions", instructions)
|
||||
_, instructions := misc.CodexInstructionsForModel(modelName, "")
|
||||
out, _ = sjson.Set(out, "instructions", instructions)
|
||||
|
||||
root := gjson.ParseBytes(rawJSON)
|
||||
|
||||
|
||||
@@ -96,8 +96,8 @@ func ConvertOpenAIRequestToCodex(modelName string, inputRawJSON []byte, stream b
|
||||
|
||||
// Extract system instructions from first system message (string or text object)
|
||||
messages := gjson.GetBytes(rawJSON, "messages")
|
||||
instructions := misc.CodexInstructions(modelName)
|
||||
out, _ = sjson.SetRaw(out, "instructions", instructions)
|
||||
_, instructions := misc.CodexInstructionsForModel(modelName, "")
|
||||
out, _ = sjson.Set(out, "instructions", instructions)
|
||||
// if messages.IsArray() {
|
||||
// arr := messages.Array()
|
||||
// for i := 0; i < len(arr); i++ {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/misc"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/tidwall/sjson"
|
||||
)
|
||||
@@ -23,8 +24,6 @@ func ConvertOpenAIResponsesRequestToCodex(modelName string, inputRawJSON []byte,
|
||||
rawJSON, _ = sjson.DeleteBytes(rawJSON, "temperature")
|
||||
rawJSON, _ = sjson.DeleteBytes(rawJSON, "top_p")
|
||||
|
||||
instructions := misc.CodexInstructions(modelName)
|
||||
|
||||
originalInstructions := ""
|
||||
originalInstructionsText := ""
|
||||
originalInstructionsResult := gjson.GetBytes(rawJSON, "instructions")
|
||||
@@ -33,6 +32,8 @@ func ConvertOpenAIResponsesRequestToCodex(modelName string, inputRawJSON []byte,
|
||||
originalInstructionsText = originalInstructionsResult.String()
|
||||
}
|
||||
|
||||
hasOfficialInstructions, instructions := misc.CodexInstructionsForModel(modelName, originalInstructionsResult.String())
|
||||
|
||||
inputResult := gjson.GetBytes(rawJSON, "input")
|
||||
var inputResults []gjson.Result
|
||||
if inputResult.Exists() {
|
||||
@@ -70,10 +71,10 @@ func ConvertOpenAIResponsesRequestToCodex(modelName string, inputRawJSON []byte,
|
||||
}
|
||||
}
|
||||
|
||||
if instructions == originalInstructions {
|
||||
if hasOfficialInstructions {
|
||||
return rawJSON
|
||||
}
|
||||
// log.Debugf("instructions not matched, %s\n", originalInstructions)
|
||||
log.Debugf("instructions not matched, %s\n", originalInstructions)
|
||||
|
||||
if len(inputResults) > 0 {
|
||||
newInput := "[]"
|
||||
@@ -98,7 +99,7 @@ func ConvertOpenAIResponsesRequestToCodex(modelName string, inputRawJSON []byte,
|
||||
rawJSON, _ = sjson.SetRawBytes(rawJSON, "input", []byte(newInput))
|
||||
}
|
||||
|
||||
rawJSON, _ = sjson.SetRawBytes(rawJSON, "instructions", []byte(instructions))
|
||||
rawJSON, _ = sjson.SetBytes(rawJSON, "instructions", instructions)
|
||||
|
||||
return rawJSON
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user