fix: avoid common/provider-models circular import
This commit is contained in:
parent
7ae03c814f
commit
465bbaef2b
1 changed files with 24 additions and 1 deletions
|
|
@ -6,7 +6,6 @@ import logger from './logger.js';
|
||||||
import { convertData, getOpenAIStreamChunkStop } from '../convert/convert.js';
|
import { convertData, getOpenAIStreamChunkStop } from '../convert/convert.js';
|
||||||
import { ProviderStrategyFactory } from './provider-strategies.js';
|
import { ProviderStrategyFactory } from './provider-strategies.js';
|
||||||
import { getPluginManager } from '../core/plugin-manager.js';
|
import { getPluginManager } from '../core/plugin-manager.js';
|
||||||
import { getConfiguredSupportedModels, usesManagedModelList } from '../providers/provider-models.js';
|
|
||||||
|
|
||||||
// ==================== 网络错误处理 ====================
|
// ==================== 网络错误处理 ====================
|
||||||
|
|
||||||
|
|
@ -77,6 +76,30 @@ export const MODEL_PROVIDER = {
|
||||||
AUTO: 'auto',
|
AUTO: 'auto',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MANAGED_MODEL_LIST_PROVIDER_TYPES = new Set([
|
||||||
|
'openai-custom',
|
||||||
|
'openaiResponses-custom'
|
||||||
|
]);
|
||||||
|
|
||||||
|
function usesManagedModelList(providerType = '') {
|
||||||
|
return [...MANAGED_MODEL_LIST_PROVIDER_TYPES].some(baseType =>
|
||||||
|
providerType === baseType || providerType.startsWith(baseType + '-')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getConfiguredSupportedModels(providerType, providerConfig = {}) {
|
||||||
|
if (!usesManagedModelList(providerType)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...new Set(
|
||||||
|
(Array.isArray(providerConfig?.supportedModels) ? providerConfig.supportedModels : [])
|
||||||
|
.filter(model => typeof model === 'string')
|
||||||
|
.map(model => model.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
)].sort((a, b) => a.localeCompare(b));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the protocol prefix from a given model provider string.
|
* Extracts the protocol prefix from a given model provider string.
|
||||||
* This is used to determine if two providers belong to the same underlying protocol (e.g., gemini, openai, claude).
|
* This is used to determine if two providers belong to the same underlying protocol (e.g., gemini, openai, claude).
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue