doOpenAIRequest builds + sends the upstream request. Returns the raw response on success; caller handles status / body.
(ctx context.Context, cfg *proxyConfig, body []byte)
| 180 | // doOpenAIRequest builds + sends the upstream request. Returns the |
| 181 | // raw response on success; caller handles status / body. |
| 182 | func (c *CloudProxy) doOpenAIRequest(ctx context.Context, cfg *proxyConfig, body []byte) (*http.Response, error) { |
| 183 | req, err := http.NewRequestWithContext(ctx, http.MethodPost, cfg.upstreamURL, bytes.NewReader(body)) |
| 184 | if err != nil { |
| 185 | return nil, fmt.Errorf("cloud-proxy: build request: %w", err) |
| 186 | } |
| 187 | req.Header.Set("Content-Type", "application/json") |
| 188 | req.Header.Set("Accept", "*/*") |
| 189 | if cfg.apiKey != "" { |
| 190 | applyAuthHeader(req, cfg.provider, cfg.apiKey) |
| 191 | } |
| 192 | resp, err := c.client.Do(req) |
| 193 | if err != nil { |
| 194 | return nil, fmt.Errorf("cloud-proxy: upstream request: %w", err) |
| 195 | } |
| 196 | return resp, nil |
| 197 | } |
| 198 | |
| 199 | // predictOpenAIRich is the non-streaming translate path. Returns a |
| 200 | // fully-populated *pb.Reply with assistant content, tool calls, and |
no test coverage detected