Changesets · Branches · Tags · Compare
| Changeset | 6496d1ed92c1bebc42bcfd7c76e1bd4fa9376137ce609df9cd18dd711dd51cc5 |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-06-25 15:41 -07:00 |
| Committer | Dallin Romney <dallinromney@gmail.com> · 2025-06-25 15:41 -07:00 |
| Parents | 607dd12e068c |
2 files changed
modified packages/openai-adapters/src/apis/Relace.ts +1 −2
| @@ -67,7 +67,6 @@ | ||
| 67 | 67 | body: ChatCompletionCreateParamsStreaming, |
| 68 | 68 | signal: AbortSignal, |
| 69 | 69 | ): AsyncGenerator<ChatCompletionChunk> { |
| 70 | - const fetch = customFetch(this.config.requestOptions); | |
| 71 | 70 | const headers = { |
| 72 | 71 | "Content-Type": "application/json", |
| 73 | 72 | Authorization: `Bearer ${this.config.apiKey}`, |
| @@ -98,7 +97,7 @@ | ||
| 98 | 97 | }; |
| 99 | 98 | |
| 100 | 99 | const url = this.apiBase + "code/apply"; |
| 101 | - const response = await fetch(url, { | |
| 100 | + const response = await customFetch(this.config.requestOptions)(url, { | |
| 102 | 101 | method: "POST", |
| 103 | 102 | headers, |
| 104 | 103 | body: JSON.stringify(data), |
modified packages/openai-adapters/src/util.ts +22 −3
| @@ -1,11 +1,18 @@ | ||
| 1 | 1 | import { RequestOptions } from "@continuedev/config-types"; |
| 2 | 2 | import { fetchwithRequestOptions } from "@continuedev/fetch"; |
| 3 | +import fetch from "node-fetch"; | |
| 4 | +import { | |
| 5 | + type RequestInfo, | |
| 6 | + type RequestInit, | |
| 7 | + type Response, | |
| 8 | +} from "openai/_shims/index"; | |
| 3 | 9 | import { |
| 4 | 10 | ChatCompletionChunk, |
| 5 | 11 | CompletionUsage, |
| 6 | 12 | CreateEmbeddingResponse, |
| 7 | 13 | Model, |
| 8 | 14 | } from "openai/resources/index"; |
| 15 | + | |
| 9 | 16 | import { ChatCompletion } from "openai/src/resources/index.js"; |
| 10 | 17 | import { CreateRerankResponse } from "./apis/base.js"; |
| 11 | 18 | |
| @@ -136,7 +143,19 @@ | ||
| 136 | 143 | }; |
| 137 | 144 | } |
| 138 | 145 | |
| 139 | -export function customFetch(requestOptions: RequestOptions | undefined) { | |
| 140 | - return (url: any, init: any) => | |
| 141 | - fetchwithRequestOptions(url, init, requestOptions); | |
| 146 | +export function customFetch( | |
| 147 | + requestOptions: RequestOptions | undefined, | |
| 148 | +): (req: URL | RequestInfo, init?: RequestInit) => Promise<Response> { | |
| 149 | + if (process.env.FEATURE_FLAG_DISABLE_CUSTOM_FETCH) { | |
| 150 | + return fetch; | |
| 151 | + } | |
| 152 | + return (req: URL | RequestInfo, init?: RequestInit) => { | |
| 153 | + if (typeof req === "string") { | |
| 154 | + return fetchwithRequestOptions(req, init, requestOptions); | |
| 155 | + } else if (req instanceof URL) { | |
| 156 | + return fetchwithRequestOptions(req, init, requestOptions); | |
| 157 | + } else { | |
| 158 | + return fetchwithRequestOptions(req.url, req, requestOptions); | |
| 159 | + } | |
| 160 | + }; | |
| 142 | 161 | } |