mirror of
https://github.com/tiennm99/ccs.git
synced 2026-08-13 06:22:49 +00:00
fix(cliproxy): dedupe variant prefix sync
This commit is contained in:
@@ -45,6 +45,17 @@ interface CliproxyProfileArgs {
|
|||||||
errors: string[];
|
errors: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const variantManagedPrefixProviders = new Set<CLIProxyProvider>();
|
||||||
|
|
||||||
|
async function ensureVariantManagedModelPrefixes(provider: CLIProxyProvider): Promise<void> {
|
||||||
|
if (variantManagedPrefixProviders.has(provider)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await ensureManagedModelPrefixes([provider]);
|
||||||
|
variantManagedPrefixProviders.add(provider);
|
||||||
|
}
|
||||||
|
|
||||||
function parseTargetValue(rawValue: string): TargetType | null {
|
function parseTargetValue(rawValue: string): TargetType | null {
|
||||||
const normalized = rawValue.trim().toLowerCase();
|
const normalized = rawValue.trim().toLowerCase();
|
||||||
if (isPersistedTargetType(normalized)) {
|
if (isPersistedTargetType(normalized)) {
|
||||||
@@ -188,7 +199,7 @@ async function selectTierConfig(
|
|||||||
let model: string | undefined;
|
let model: string | undefined;
|
||||||
if (supportsModelConfig(provider as CLIProxyProvider)) {
|
if (supportsModelConfig(provider as CLIProxyProvider)) {
|
||||||
try {
|
try {
|
||||||
await ensureManagedModelPrefixes([provider as CLIProxyProvider]);
|
await ensureVariantManagedModelPrefixes(provider as CLIProxyProvider);
|
||||||
} catch {
|
} catch {
|
||||||
// Keep interactive model selection available even when prefix repair fails.
|
// Keep interactive model selection available even when prefix repair fails.
|
||||||
}
|
}
|
||||||
@@ -449,7 +460,7 @@ export async function handleCreate(
|
|||||||
if (!model) {
|
if (!model) {
|
||||||
if (supportsModelConfig(provider as CLIProxyProvider)) {
|
if (supportsModelConfig(provider as CLIProxyProvider)) {
|
||||||
try {
|
try {
|
||||||
await ensureManagedModelPrefixes([provider as CLIProxyProvider]);
|
await ensureVariantManagedModelPrefixes(provider as CLIProxyProvider);
|
||||||
} catch {
|
} catch {
|
||||||
// Keep variant creation available even when prefix repair fails.
|
// Keep variant creation available even when prefix repair fails.
|
||||||
}
|
}
|
||||||
@@ -699,7 +710,7 @@ export async function handleEdit(
|
|||||||
const providerForModel = newProvider || (variant.provider as CLIProxyProfileName);
|
const providerForModel = newProvider || (variant.provider as CLIProxyProfileName);
|
||||||
if (supportsModelConfig(providerForModel as CLIProxyProvider)) {
|
if (supportsModelConfig(providerForModel as CLIProxyProvider)) {
|
||||||
try {
|
try {
|
||||||
await ensureManagedModelPrefixes([providerForModel as CLIProxyProvider]);
|
await ensureVariantManagedModelPrefixes(providerForModel as CLIProxyProvider);
|
||||||
} catch {
|
} catch {
|
||||||
// Keep edit flow available even when prefix repair fails.
|
// Keep edit flow available even when prefix repair fails.
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user