Add proxy configuration to more network fetches. (#7328)
This commit is contained in:
1 parent
ba98b44504
commit
67bc9932e5
21 files changed
+48
-11
No files matched your search
@@ -33,6 +33,7 @@ import { LogoutReason } from "@/services/auth/types"
|
||||
import { featureFlagsService } from "@/services/feature-flags"
|
||||
import { getDistinctId } from "@/services/logging/distinctId"
|
||||
import { telemetryService } from "@/services/telemetry"
|
||||
import { getAxiosSettings } from "@/shared/net"
|
||||
import { ShowMessageType } from "@/shared/proto/host/window"
|
||||
import { AuthState } from "@/shared/proto/index.cline"
|
||||
import { getLatestAnnouncementId } from "@/utils/announcements"
|
||||
@@ -651,6 +652,7 @@ export class Controller {
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": "cline-vscode-extension",
|
||||
},
|
||||
...getAxiosSettings(),
|
||||
})
|
||||
|
||||
if (!response.data) {
|
||||
@@ -698,7 +700,7 @@ export class Controller {
|
||||
async handleOpenRouterCallback(code: string) {
|
||||
let apiKey: string
|
||||
try {
|
||||
const response = await axios.post("https://openrouter.ai/api/v1/auth/keys", { code })
|
||||
const response = await axios.post("https://openrouter.ai/api/v1/auth/keys", { code }, getAxiosSettings())
|
||||
if (response.data && response.data.key) {
|
||||
apiKey = response.data.key
|
||||
} else {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { StringRequest } from "@shared/proto/cline/common"
|
||||
import { McpDownloadResponse } from "@shared/proto/cline/mcp"
|
||||
import axios from "axios"
|
||||
import { ClineEnv } from "@/config"
|
||||
import { getAxiosSettings } from "@/shared/net"
|
||||
import { Controller } from ".."
|
||||
import { sendChatButtonClickedEvent } from "../ui/subscribeToChatButtonClicked"
|
||||
|
||||
@@ -36,6 +37,7 @@ export async function downloadMcp(controller: Controller, request: StringRequest
|
||||
{
|
||||
headers: { "Content-Type": "application/json" },
|
||||
timeout: 10000,
|
||||
...getAxiosSettings(),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { EmptyRequest } from "@shared/proto/cline/common"
|
||||
import { OpenRouterCompatibleModelInfo, OpenRouterModelInfo } from "@shared/proto/cline/models"
|
||||
import axios from "axios"
|
||||
import { getAxiosSettings } from "@/shared/net"
|
||||
import { Controller } from ".."
|
||||
|
||||
/**
|
||||
@@ -11,7 +12,7 @@ import { Controller } from ".."
|
||||
*/
|
||||
export async function getAihubmixModels(_controller: Controller, _request: EmptyRequest): Promise<OpenRouterCompatibleModelInfo> {
|
||||
try {
|
||||
const response = await axios.get("https://aihubmix.com/call/mdl_info_platform?tag=coding")
|
||||
const response = await axios.get("https://aihubmix.com/call/mdl_info_platform?tag=coding", getAxiosSettings())
|
||||
|
||||
if (!response.data?.success || !Array.isArray(response.data?.data)) {
|
||||
console.error("Invalid response from AIhubmix API:", response.data)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { StringArray, StringRequest } from "@shared/proto/cline/common"
|
||||
import axios from "axios"
|
||||
import { getAxiosSettings } from "@/shared/net"
|
||||
import { Controller } from ".."
|
||||
|
||||
/**
|
||||
@@ -16,7 +17,7 @@ export async function getOllamaModels(_controller: Controller, request: StringRe
|
||||
return StringArray.create({ values: [] })
|
||||
}
|
||||
|
||||
const response = await axios.get(`${baseUrl}/api/tags`)
|
||||
const response = await axios.get(`${baseUrl}/api/tags`, getAxiosSettings())
|
||||
const modelsArray = response.data?.models?.map((model: any) => model.name) || []
|
||||
const models = [...new Set<string>(modelsArray)].sort()
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import axios from "axios"
|
||||
import { getAxiosSettings } from "@/shared/net"
|
||||
import { SapAiCoreModelDeployment, SapAiCoreModelsRequest, SapAiCoreModelsResponse } from "@/shared/proto/cline/models"
|
||||
import { Controller } from ".."
|
||||
|
||||
@@ -33,6 +34,7 @@ async function getToken(clientId: string, clientSecret: string, tokenUrl: string
|
||||
const url = tokenUrl.replace(/\/+$/, "") + "/oauth/token"
|
||||
const response = await axios.post(url, payload, {
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
...getAxiosSettings(),
|
||||
})
|
||||
const token = response.data as Token
|
||||
token.expires_at = Date.now() + token.expires_in * 1000
|
||||
@@ -65,7 +67,7 @@ async function fetchAiCoreDeploymentsAndOrchestration(
|
||||
const url = `${baseUrl}/v2/lm/deployments?$top=10000&$skip=0`
|
||||
|
||||
try {
|
||||
const response = await axios.get(url, { headers })
|
||||
const response = await axios.get(url, { headers, ...getAxiosSettings() })
|
||||
const allDeployments = response.data.resources
|
||||
|
||||
// Filter running deployments
|
||||
|
||||
@@ -5,6 +5,7 @@ import { parsePrice } from "@utils/model-utils"
|
||||
import axios from "axios"
|
||||
import fs from "fs/promises"
|
||||
import path from "path"
|
||||
import { getAxiosSettings } from "@/shared/net"
|
||||
import { basetenModels } from "../../../shared/api"
|
||||
import { Controller } from ".."
|
||||
|
||||
@@ -50,6 +51,7 @@ export async function refreshBasetenModels(controller: Controller): Promise<Reco
|
||||
"User-Agent": "Cline-VSCode-Extension",
|
||||
},
|
||||
timeout: 10000, // 10 second timeout
|
||||
...getAxiosSettings(),
|
||||
})
|
||||
|
||||
if (response.data?.data) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import axios from "axios"
|
||||
import fs from "fs/promises"
|
||||
import path from "path"
|
||||
import { telemetryService } from "@/services/telemetry"
|
||||
import { getAxiosSettings } from "@/shared/net"
|
||||
import { groqModels } from "../../../shared/api"
|
||||
import { Controller } from ".."
|
||||
|
||||
@@ -52,6 +53,7 @@ export async function refreshGroqModels(controller: Controller): Promise<Record<
|
||||
"User-Agent": "Cline-VSCode-Extension",
|
||||
},
|
||||
timeout: 10000, // 10 second timeout
|
||||
...getAxiosSettings(),
|
||||
})
|
||||
|
||||
if (response.data?.data) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { fileExistsAtPath } from "@utils/fs"
|
||||
import axios from "axios"
|
||||
import fs from "fs/promises"
|
||||
import path from "path"
|
||||
import { getAxiosSettings } from "@/shared/net"
|
||||
import { Controller } from ".."
|
||||
|
||||
/**
|
||||
@@ -33,6 +34,7 @@ export async function refreshHicapModels(controller: Controller, _request: Empty
|
||||
headers: {
|
||||
"api-key": hicapApiKey,
|
||||
},
|
||||
...getAxiosSettings(),
|
||||
})
|
||||
|
||||
if (response.data?.data) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import axios from "axios"
|
||||
import fs from "fs/promises"
|
||||
import path from "path"
|
||||
import { ensureCacheDirectoryExists } from "@/core/storage/disk"
|
||||
import { getAxiosSettings } from "@/shared/net"
|
||||
import { Controller } from ".."
|
||||
|
||||
/**
|
||||
@@ -26,6 +27,7 @@ export async function refreshHuggingFaceModels(
|
||||
// Fetch models from Hugging Face API
|
||||
const response = await axios.get("https://router.huggingface.co/v1/models", {
|
||||
timeout: 10000,
|
||||
...getAxiosSettings(),
|
||||
})
|
||||
|
||||
if (response.data?.data) {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { StringArray } from "@shared/proto/cline/common"
|
||||
import { OpenAiModelsRequest } from "@shared/proto/cline/models"
|
||||
import type { AxiosRequestConfig } from "axios"
|
||||
import axios from "axios"
|
||||
import { getAxiosSettings } from "@/shared/net"
|
||||
import { Controller } from ".."
|
||||
|
||||
/**
|
||||
@@ -25,7 +26,7 @@ export async function refreshOpenAiModels(_controller: Controller, request: Open
|
||||
config["headers"] = { Authorization: `Bearer ${request.apiKey}` }
|
||||
}
|
||||
|
||||
const response = await axios.get(`${request.baseUrl}/models`, config)
|
||||
const response = await axios.get(`${request.baseUrl}/models`, { ...config, ...getAxiosSettings() })
|
||||
const modelsArray = response.data?.data?.map((model: any) => model.id) || []
|
||||
const models = [...new Set<string>(modelsArray)]
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
openRouterClaudeSonnet41mModelId,
|
||||
openRouterClaudeSonnet451mModelId,
|
||||
} from "@/shared/api"
|
||||
import { getAxiosSettings } from "@/shared/net"
|
||||
import type { Controller } from ".."
|
||||
|
||||
type OpenRouterSupportedParams =
|
||||
@@ -79,7 +80,7 @@ export async function refreshOpenRouterModels(controller: Controller): Promise<R
|
||||
|
||||
const models: Record<string, ModelInfo> = {}
|
||||
try {
|
||||
const response = await axios.get("https://openrouter.ai/api/v1/models")
|
||||
const response = await axios.get("https://openrouter.ai/api/v1/models", getAxiosSettings())
|
||||
|
||||
if (response.data?.data) {
|
||||
const rawModels = response.data.data
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { EmptyRequest } from "@shared/proto/cline/common"
|
||||
import { OpenRouterCompatibleModelInfo, OpenRouterModelInfo } from "@shared/proto/cline/models"
|
||||
import axios from "axios"
|
||||
import { getAxiosSettings } from "@/shared/net"
|
||||
import { toRequestyServiceUrl } from "@/shared/clients/requesty"
|
||||
import { Controller } from ".."
|
||||
|
||||
@@ -33,7 +34,7 @@ export async function refreshRequestyModels(controller: Controller, _: EmptyRequ
|
||||
const headers = {
|
||||
Authorization: `Bearer ${apiKey}`,
|
||||
}
|
||||
const response = await axios.get(url, { headers })
|
||||
const response = await axios.get(url, { headers, ...getAxiosSettings() })
|
||||
if (response.data?.data) {
|
||||
for (const model of response.data.data) {
|
||||
const modelInfo: OpenRouterModelInfo = OpenRouterModelInfo.create({
|
||||
|
||||
@@ -4,6 +4,7 @@ import { fileExistsAtPath } from "@utils/fs"
|
||||
import axios from "axios"
|
||||
import fs from "fs/promises"
|
||||
import path from "path"
|
||||
import { getAxiosSettings } from "@/shared/net"
|
||||
import { Controller } from ".."
|
||||
|
||||
/**
|
||||
@@ -17,7 +18,7 @@ export async function refreshVercelAiGatewayModels(_controller: Controller): Pro
|
||||
let models: Record<string, ModelInfo> = {}
|
||||
|
||||
try {
|
||||
const response = await axios.get("https://ai-gateway.vercel.sh/v1/models")
|
||||
const response = await axios.get("https://ai-gateway.vercel.sh/v1/models", getAxiosSettings())
|
||||
|
||||
if (response.data?.data) {
|
||||
const rawModels = response.data.data
|
||||
|
||||
Reference in new issue
Block a user