openmaic-custom/lib/utils/model-config.ts
wyuc e613b7578f
[codex] add per-model thinking config (#494)
* add per-model thinking config

* Refine thinking model controls

---------

Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
2026-04-26 19:41:10 +08:00

35 lines
1.1 KiB
TypeScript

import { useSettingsStore } from '@/lib/store/settings';
import {
getThinkingConfigKey,
normalizeThinkingConfig,
supportsConfigurableThinking,
} from '@/lib/ai/thinking-config';
/**
* Get current model configuration from settings store
*/
export function getCurrentModelConfig() {
const { providerId, modelId, providersConfig, thinkingConfigs } = useSettingsStore.getState();
const modelString = `${providerId}:${modelId}`;
// Get current provider's config
const providerConfig = providersConfig[providerId];
const modelInfo = providerConfig?.models.find((model) => model.id === modelId);
const thinking = modelInfo?.capabilities?.thinking;
const thinkingConfig = supportsConfigurableThinking(thinking)
? normalizeThinkingConfig(thinking, thinkingConfigs[getThinkingConfigKey(providerId, modelId)])
: undefined;
return {
providerId,
modelId,
modelString,
apiKey: providerConfig?.apiKey || '',
baseUrl: providerConfig?.baseUrl || '',
providerType: providerConfig?.type,
requiresApiKey: providerConfig?.requiresApiKey,
isServerConfigured: providerConfig?.isServerConfigured,
thinkingConfig,
};
}