|
|
@@ -13,7 +13,7 @@ import { ApiStream } from "../transform/stream"
|
|
|
|
|
|
import { BaseProvider } from "./base-provider"
|
|
|
import type { SingleCompletionHandler, ApiHandlerCreateMessageMetadata } from "../index"
|
|
|
-import { fetchWithTimeout } from "./kilocode/fetchWithTimeout"
|
|
|
+import { fetchWithTimeout, HeadersTimeoutError } from "./kilocode/fetchWithTimeout"
|
|
|
|
|
|
import { getModels, getModelsFromCache } from "./fetchers/modelCache"
|
|
|
import { handleOpenAIError } from "./utils/openai-error-handler"
|
|
|
@@ -31,8 +31,10 @@ export class LmStudioHandler extends BaseProvider implements SingleCompletionHan
|
|
|
this.client = new OpenAI({
|
|
|
baseURL: (this.options.lmStudioBaseUrl || "http://localhost:1234") + "/v1",
|
|
|
apiKey: "noop",
|
|
|
- timeout: timeout, // kilocode_change
|
|
|
- fetch: fetchWithTimeout(timeout), // kilocode_change
|
|
|
+ // kilocode_change start
|
|
|
+ timeout: timeout,
|
|
|
+ fetch: fetchWithTimeout(timeout),
|
|
|
+ // kilocode_change end
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -138,6 +140,11 @@ export class LmStudioHandler extends BaseProvider implements SingleCompletionHan
|
|
|
outputTokens,
|
|
|
} as const
|
|
|
} catch (error) {
|
|
|
+ // kilocode_change start
|
|
|
+ if (error.cause instanceof HeadersTimeoutError) {
|
|
|
+ throw new Error("Headers timeout", { cause: error })
|
|
|
+ }
|
|
|
+ // kilocode_change end
|
|
|
throw new Error(
|
|
|
"Please check the LM Studio developer logs to debug what went wrong. You may need to load the model with a larger context length to work with Kilo Code's prompts.",
|
|
|
)
|