Unified · Split
| @@ -19,8 +19,10 @@ func ConvertCodexResponseToOpenAIResponses(ctx context.Context, modelName string · 18 unmodified lines | ||
| 19 | 19 | if typeResult := gjson.GetBytes(rawJSON, "type"); typeResult.Exists() { |
| 20 | 20 | typeStr := typeResult.String() |
| 21 | 21 | if typeStr == "response.created" || typeStr == "response.in_progress" || typeStr == "response.completed" { |
| 22 | − instructions := selectInstructions(originalRequestRawJSON, requestRawJSON) | |
| 23 | − rawJSON, _ = sjson.SetBytes(rawJSON, "response.instructions", instructions) | |
| 22 | + if gjson.GetBytes(rawJSON, "response.instructions").Exists() { | |
| 23 | + instructions := selectInstructions(originalRequestRawJSON, requestRawJSON) | |
| 24 | + rawJSON, _ = sjson.SetBytes(rawJSON, "response.instructions", instructions) | |
| 25 | + } | |
| 24 | 26 | } |
| 25 | 27 | } |
| 26 | 28 | out := fmt.Sprintf("data: %s", string(rawJSON)) |
| @@ -39,7 +41,9 @@ func ConvertCodexResponseToOpenAIResponsesNonStream(_ context.Context, modelName · 12 unmodified lines | ||
| 39 | 41 | } |
| 40 | 42 | responseResult := rootResult.Get("response") |
| 41 | 43 | template := responseResult.Raw |
| 42 | − template, _ = sjson.Set(template, "instructions", selectInstructions(originalRequestRawJSON, requestRawJSON)) | |
| 44 | + if responseResult.Get("instructions").Exists() { | |
| 45 | + template, _ = sjson.Set(template, "instructions", selectInstructions(originalRequestRawJSON, requestRawJSON)) | |
| 46 | + } | |
| 43 | 47 | return template |
| 44 | 48 | } |
| 45 | 49 | |