MCPcopy Index your code
hub / github.com/continuedev/continue / fetch

Function fetch

core/llm/index.ts:449–529  ·  view source on GitHub ↗
(url: RequestInfo | URL, init?: RequestInit)

Source from the content-addressed store, hash-verified

447 }
448
449 fetch(url: RequestInfo | URL, init?: RequestInit): Promise<Response> {
450 // Custom Node.js fetch
451 const customFetch = async (input: URL | RequestInfo, init: any) => {
452 try {
453 const resp = await fetchwithRequestOptions(
454 new URL(input as any),
455 { ...init },
456 { ...this.requestOptions },
457 );
458
459 // Error mapping to be more helpful
460 if (!resp.ok) {
461 if (resp.status === 499) {
462 return resp; // client side cancellation
463 }
464
465 const error = await this.parseError(resp);
466 throw error;
467 }
468
469 return resp;
470 } catch (e: any) {
471 Logger.error(e, {
472 context: "llm_fetch",
473 url: String(input),
474 method: init?.method || "GET",
475 model: this.model,
476 provider: this.providerName,
477 });
478
479 // Errors to ignore
480 if (e.message.includes("/api/tags")) {
481 throw new Error(`Error fetching tags: ${e.message}`);
482 } else if (e.message.includes("/api/show")) {
483 throw new Error(
484 `HTTP ${e.response.status} ${e.response.statusText} from ${e.response.url}\n\n${e.response.body}`,
485 );
486 } else {
487 if (!isAbortError(e)) {
488 // Don't pollute console with abort errors. Check on name instead of instanceof, to avoid importing node-fetch here
489 console.debug(
490 `${e.message}\n\nCode: ${e.code}\nError number: ${e.errno}\nSyscall: ${e.erroredSysCall}\nType: ${e.type}\n\n${e.stack}`,
491 );
492 }
493 if (
494 e.code === "ECONNREFUSED" &&
495 e.message.includes("http://127.0.0.1:11434")
496 ) {
497 const message = (await isOllamaInstalled())
498 ? "Unable to connect to local Ollama instance. Ollama may not be running."
499 : "Unable to connect to local Ollama instance. Ollama may not be installed or may not running.";
500 throw new Error(message);
501 }
502 if (
503 e.code === "ECONNREFUSED" &&
504 e.message.includes("http://localhost:8000")
505 ) {
506 const isInstalled = await isLemonadeInstalled();

Callers 15

fetchOllamaModelsFunction · 0.70
fetchOpenRouterModelsFunction · 0.70
fetchAnthropicModelsFunction · 0.70
fetchGeminiModelsFunction · 0.70
autodetectApiKeyTypeMethod · 0.50
installModelMethod · 0.50
http.tsFile · 0.50
getLinksFromUrlMethod · 0.50
crawlMethod · 0.50
fetchMessagesMethod · 0.50
fetchChannelsMethod · 0.50
constructSseTransportMethod · 0.50

Calls 2

customFetchFunction · 0.70
withExponentialBackoffFunction · 0.50

Tested by

no test coverage detected