Fixed: #1758
fix(codex): filter billing headers from system result text and update template logic
This commit is contained in:
@@ -46,16 +46,24 @@ func ConvertClaudeRequestToCodex(modelName string, inputRawJSON []byte, _ bool)
|
|||||||
if systemsResult.IsArray() {
|
if systemsResult.IsArray() {
|
||||||
systemResults := systemsResult.Array()
|
systemResults := systemsResult.Array()
|
||||||
message := `{"type":"message","role":"developer","content":[]}`
|
message := `{"type":"message","role":"developer","content":[]}`
|
||||||
|
contentIndex := 0
|
||||||
for i := 0; i < len(systemResults); i++ {
|
for i := 0; i < len(systemResults); i++ {
|
||||||
systemResult := systemResults[i]
|
systemResult := systemResults[i]
|
||||||
systemTypeResult := systemResult.Get("type")
|
systemTypeResult := systemResult.Get("type")
|
||||||
if systemTypeResult.String() == "text" {
|
if systemTypeResult.String() == "text" {
|
||||||
message, _ = sjson.Set(message, fmt.Sprintf("content.%d.type", i), "input_text")
|
text := systemResult.Get("text").String()
|
||||||
message, _ = sjson.Set(message, fmt.Sprintf("content.%d.text", i), systemResult.Get("text").String())
|
if strings.HasPrefix(text, "x-anthropic-billing-header: ") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
message, _ = sjson.Set(message, fmt.Sprintf("content.%d.type", contentIndex), "input_text")
|
||||||
|
message, _ = sjson.Set(message, fmt.Sprintf("content.%d.text", contentIndex), text)
|
||||||
|
contentIndex++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if contentIndex > 0 {
|
||||||
template, _ = sjson.SetRaw(template, "input.-1", message)
|
template, _ = sjson.SetRaw(template, "input.-1", message)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Process messages and transform their contents to appropriate formats.
|
// Process messages and transform their contents to appropriate formats.
|
||||||
messagesResult := rootResult.Get("messages")
|
messagesResult := rootResult.Get("messages")
|
||||||
|
|||||||
Reference in New Issue
Block a user