(respCopy *responseCopier)
| 149 | } |
| 150 | |
| 151 | func (i *responsesInterceptionBase) requestOptions(respCopy *responseCopier) []option.RequestOption { |
| 152 | opts := []option.RequestOption{ |
| 153 | // Sends original payload to solve json re-encoding issues |
| 154 | // eg. Codex CLI produces requests without ID set in reasoning items: https://platform.openai.com/docs/api-reference/responses/create#responses_create-input-input_item_list-item-reasoning-id |
| 155 | // when re-encoded, ID field is set to empty string which results |
| 156 | // in bad request while not sending ID field at all somehow works. |
| 157 | option.WithRequestBody("application/json", []byte(i.reqPayload)), |
| 158 | |
| 159 | // copyMiddleware copies body of original response body to the buffer in responseCopier, |
| 160 | // also reference to headers and status code is kept responseCopier. |
| 161 | // responseCopier is used by interceptors to forward response as it was received, |
| 162 | // eliminating any possibility of JSON re-encoding issues. |
| 163 | option.WithMiddleware(respCopy.copyMiddleware), |
| 164 | } |
| 165 | if !i.reqPayload.Stream() { |
| 166 | opts = append(opts, option.WithRequestTimeout(requestTimeout)) |
| 167 | } |
| 168 | return opts |
| 169 | } |
| 170 | |
| 171 | func (i *responsesInterceptionBase) recordUserPrompt(ctx context.Context, responseID string, prompt string) { |
| 172 | if responseID == "" { |
no test coverage detected