@@ -75,6 +75,32 @@ export function shouldContributeArceeTrinityLargeThinkingCompat(params: {
7575 return normalizeBaseUrl ( params . model . baseUrl ) === normalizeBaseUrl ( ARCEE_BASE_URL ) ;
7676}
7777
78+ export function applyArceeTrinityLargeThinkingCompat < T extends { id : string ; compat ?: unknown } > (
79+ model : T ,
80+ ) : T {
81+ if ( ! isArceeTrinityLargeThinkingModelId ( model . id ) ) {
82+ return model ;
83+ }
84+ const compat =
85+ model . compat && typeof model . compat === "object"
86+ ? ( model . compat as Record < string , unknown > )
87+ : undefined ;
88+ if (
89+ compat ?. supportsReasoningEffort ===
90+ ARCEE_TRINITY_LARGE_THINKING_COMPAT . supportsReasoningEffort &&
91+ compat ?. supportsTools === ARCEE_TRINITY_LARGE_THINKING_COMPAT . supportsTools
92+ ) {
93+ return model ;
94+ }
95+ return {
96+ ...model ,
97+ compat : {
98+ ...compat ,
99+ ...ARCEE_TRINITY_LARGE_THINKING_COMPAT ,
100+ } as T extends { compat ?: infer TCompat } ? TCompat : never ,
101+ } as T ;
102+ }
103+
78104export function normalizeArceeProviderConfig (
79105 providerConfig : ModelProviderConfig ,
80106) : ModelProviderConfig {
@@ -91,24 +117,12 @@ export function normalizeArceeProviderConfig(
91117 const hasModels = Array . isArray ( providerConfig . models ) ;
92118 const models = hasModels
93119 ? providerConfig . models . map ( ( model ) => {
94- if ( ! isArceeTrinityLargeThinkingModelId ( model . id ) ) {
95- return model ;
96- }
97- if (
98- model . compat ?. supportsReasoningEffort ===
99- ARCEE_TRINITY_LARGE_THINKING_COMPAT . supportsReasoningEffort &&
100- model . compat ?. supportsTools === ARCEE_TRINITY_LARGE_THINKING_COMPAT . supportsTools
101- ) {
120+ const normalizedModel = applyArceeTrinityLargeThinkingCompat ( model ) ;
121+ if ( normalizedModel === model ) {
102122 return model ;
103123 }
104124 changed = true ;
105- return {
106- ...model ,
107- compat : {
108- ...model . compat ,
109- ...ARCEE_TRINITY_LARGE_THINKING_COMPAT ,
110- } ,
111- } ;
125+ return normalizedModel ;
112126 } )
113127 : providerConfig . models ;
114128
0 commit comments