chore: format code
This commit is contained in:
@@ -78,18 +78,12 @@ export namespace Provider {
|
||||
}
|
||||
},
|
||||
"amazon-bedrock": async () => {
|
||||
if (
|
||||
!process.env["AWS_PROFILE"] &&
|
||||
!process.env["AWS_ACCESS_KEY_ID"] &&
|
||||
!process.env["AWS_BEARER_TOKEN_BEDROCK"]
|
||||
)
|
||||
if (!process.env["AWS_PROFILE"] && !process.env["AWS_ACCESS_KEY_ID"] && !process.env["AWS_BEARER_TOKEN_BEDROCK"])
|
||||
return { autoload: false }
|
||||
|
||||
const region = process.env["AWS_REGION"] ?? "us-east-1"
|
||||
|
||||
const { fromNodeProviderChain } = await import(
|
||||
await BunProc.install("@aws-sdk/credential-providers")
|
||||
)
|
||||
const { fromNodeProviderChain } = await import(await BunProc.install("@aws-sdk/credential-providers"))
|
||||
return {
|
||||
autoload: true,
|
||||
options: {
|
||||
@@ -125,13 +119,9 @@ export namespace Provider {
|
||||
"eu-south-1",
|
||||
"eu-south-2",
|
||||
].some((r) => region.includes(r))
|
||||
const modelRequiresPrefix = [
|
||||
"claude",
|
||||
"nova-lite",
|
||||
"nova-micro",
|
||||
"llama3",
|
||||
"pixtral",
|
||||
].some((m) => modelID.includes(m))
|
||||
const modelRequiresPrefix = ["claude", "nova-lite", "nova-micro", "llama3", "pixtral"].some((m) =>
|
||||
modelID.includes(m),
|
||||
)
|
||||
if (regionRequiresPrefix && modelRequiresPrefix) {
|
||||
modelID = `${regionPrefix}.${modelID}`
|
||||
}
|
||||
@@ -141,15 +131,13 @@ export namespace Provider {
|
||||
const isAustraliaRegion = ["ap-southeast-2", "ap-southeast-4"].includes(region)
|
||||
if (
|
||||
isAustraliaRegion &&
|
||||
["anthropic.claude-sonnet-4-5", "anthropic.claude-haiku"].some((m) =>
|
||||
modelID.includes(m),
|
||||
)
|
||||
["anthropic.claude-sonnet-4-5", "anthropic.claude-haiku"].some((m) => modelID.includes(m))
|
||||
) {
|
||||
regionPrefix = "au"
|
||||
modelID = `${regionPrefix}.${modelID}`
|
||||
} else {
|
||||
const modelRequiresPrefix = ["claude", "nova-lite", "nova-micro", "nova-pro"].some(
|
||||
(m) => modelID.includes(m),
|
||||
const modelRequiresPrefix = ["claude", "nova-lite", "nova-micro", "nova-pro"].some((m) =>
|
||||
modelID.includes(m),
|
||||
)
|
||||
if (modelRequiresPrefix) {
|
||||
regionPrefix = "apac"
|
||||
@@ -187,12 +175,8 @@ export namespace Provider {
|
||||
}
|
||||
},
|
||||
"google-vertex": async () => {
|
||||
const project =
|
||||
process.env["GOOGLE_CLOUD_PROJECT"] ??
|
||||
process.env["GCP_PROJECT"] ??
|
||||
process.env["GCLOUD_PROJECT"]
|
||||
const location =
|
||||
process.env["GOOGLE_CLOUD_LOCATION"] ?? process.env["VERTEX_LOCATION"] ?? "us-east5"
|
||||
const project = process.env["GOOGLE_CLOUD_PROJECT"] ?? process.env["GCP_PROJECT"] ?? process.env["GCLOUD_PROJECT"]
|
||||
const location = process.env["GOOGLE_CLOUD_LOCATION"] ?? process.env["VERTEX_LOCATION"] ?? "us-east5"
|
||||
const autoload = Boolean(project)
|
||||
if (!autoload) return { autoload: false }
|
||||
return {
|
||||
@@ -208,12 +192,8 @@ export namespace Provider {
|
||||
}
|
||||
},
|
||||
"google-vertex-anthropic": async () => {
|
||||
const project =
|
||||
process.env["GOOGLE_CLOUD_PROJECT"] ??
|
||||
process.env["GCP_PROJECT"] ??
|
||||
process.env["GCLOUD_PROJECT"]
|
||||
const location =
|
||||
process.env["GOOGLE_CLOUD_LOCATION"] ?? process.env["VERTEX_LOCATION"] ?? "us-east5"
|
||||
const project = process.env["GOOGLE_CLOUD_PROJECT"] ?? process.env["GCP_PROJECT"] ?? process.env["GCLOUD_PROJECT"]
|
||||
const location = process.env["GOOGLE_CLOUD_LOCATION"] ?? process.env["VERTEX_LOCATION"] ?? "us-east5"
|
||||
const autoload = Boolean(project)
|
||||
if (!autoload) return { autoload: false }
|
||||
return {
|
||||
@@ -408,10 +388,7 @@ export namespace Provider {
|
||||
|
||||
// Load for the main provider if auth exists
|
||||
if (auth) {
|
||||
const options = await plugin.auth.loader(
|
||||
() => Auth.get(providerID) as any,
|
||||
database[plugin.auth.provider],
|
||||
)
|
||||
const options = await plugin.auth.loader(() => Auth.get(providerID) as any, database[plugin.auth.provider])
|
||||
mergeProvider(plugin.auth.provider, options ?? {}, "custom")
|
||||
}
|
||||
|
||||
@@ -442,14 +419,12 @@ export namespace Provider {
|
||||
// Filter out blacklisted models
|
||||
.filter(
|
||||
([modelID]) =>
|
||||
modelID !== "gpt-5-chat-latest" &&
|
||||
!(providerID === "openrouter" && modelID === "openai/gpt-5-chat"),
|
||||
modelID !== "gpt-5-chat-latest" && !(providerID === "openrouter" && modelID === "openai/gpt-5-chat"),
|
||||
)
|
||||
// Filter out experimental models
|
||||
.filter(
|
||||
([, model]) =>
|
||||
((!model.experimental && model.status !== "alpha") ||
|
||||
Flag.OPENCODE_ENABLE_EXPERIMENTAL_MODELS) &&
|
||||
((!model.experimental && model.status !== "alpha") || Flag.OPENCODE_ENABLE_EXPERIMENTAL_MODELS) &&
|
||||
model.status !== "deprecated",
|
||||
),
|
||||
)
|
||||
@@ -496,9 +471,7 @@ export namespace Provider {
|
||||
// In addition, Bun's dynamic import logic does not support subpath imports,
|
||||
// so we patch the import path to load directly from `dist`.
|
||||
const modPath =
|
||||
provider.id === "google-vertex-anthropic"
|
||||
? `${installedPath}/dist/anthropic/index.mjs`
|
||||
: installedPath
|
||||
provider.id === "google-vertex-anthropic" ? `${installedPath}/dist/anthropic/index.mjs` : installedPath
|
||||
const mod = await import(modPath)
|
||||
if (options["timeout"] !== undefined && options["timeout"] !== null) {
|
||||
// Preserve custom fetch if it exists, wrap it with timeout logic
|
||||
@@ -597,14 +570,7 @@ export namespace Provider {
|
||||
|
||||
const provider = await state().then((state) => state.providers[providerID])
|
||||
if (!provider) return
|
||||
let priority = [
|
||||
"claude-haiku-4-5",
|
||||
"claude-haiku-4.5",
|
||||
"3-5-haiku",
|
||||
"3.5-haiku",
|
||||
"gemini-2.5-flash",
|
||||
"gpt-5-nano",
|
||||
]
|
||||
let priority = ["claude-haiku-4-5", "claude-haiku-4.5", "3-5-haiku", "3.5-haiku", "gemini-2.5-flash", "gpt-5-nano"]
|
||||
// claude-haiku-4.5 is considered a premium model in github copilot, we shouldn't use premium requests for title gen
|
||||
if (providerID === "github-copilot") {
|
||||
priority = priority.filter((m) => m !== "claude-haiku-4.5")
|
||||
|
||||
Reference in New Issue
Block a user