@@ -13,6 +13,28 @@ import KeyValueAdapterRam from '../../adapters/adminforth-key-value-adapter-ram/
1313import AdminForthAgent from '../../plugins/adminforth-agent/index.js' ;
1414import CompletionAdapterOpenAIResponses from '../../adapters/adminforth-completion-adapter-openai-responses/index.js' ;
1515
16+ const OVH_AI_ENDPOINTS_BASE_URL = 'https://oai.endpoints.kepler.ai.cloud.ovh.net/v1' ;
17+ const ovhAiEndpointsAccessToken = process . env . OVH_AI_ENDPOINTS_ACCESS_TOKEN ;
18+ const openAiResponsesApiKey = ovhAiEndpointsAccessToken || process . env . OPENAI_API_KEY ;
19+ const usesOvhAiEndpoints = Boolean ( ovhAiEndpointsAccessToken ) ;
20+
21+ function createAgentCompletionAdapter (
22+ model : string ,
23+ effort : 'low' | 'medium' | 'xhigh' ,
24+ ) {
25+ return new CompletionAdapterOpenAIResponses ( {
26+ openAiApiKey : openAiResponsesApiKey as string ,
27+ baseUrl : usesOvhAiEndpoints ? OVH_AI_ENDPOINTS_BASE_URL : undefined ,
28+ model : usesOvhAiEndpoints ? 'gpt-oss-120b' : model ,
29+ extraRequestBodyParameters : {
30+ ...( usesOvhAiEndpoints ? { store : false } : { } ) ,
31+ reasoning : {
32+ effort,
33+ } ,
34+ } ,
35+ } ) ;
36+ }
37+
1638async function allowedForSuperAdmin ( { adminUser } : { adminUser : AdminUser } ) : Promise < boolean > {
1739 return adminUser . dbUser . role === 'superadmin' ;
1840}
@@ -202,39 +224,15 @@ export default {
202224 modes : [
203225 {
204226 name : 'Balanced' ,
205- completionAdapter : new CompletionAdapterOpenAIResponses ( {
206- openAiApiKey : process . env . OPENAI_API_KEY as string ,
207- model : 'gpt-5.4-mini' ,
208- extraRequestBodyParameters : {
209- reasoning : {
210- effort : 'medium' ,
211- } ,
212- } ,
213- } ) ,
227+ completionAdapter : createAgentCompletionAdapter ( 'gpt-5.4-mini' , 'medium' ) ,
214228 } ,
215229 {
216230 name : 'Fast' ,
217- completionAdapter : new CompletionAdapterOpenAIResponses ( {
218- openAiApiKey : process . env . OPENAI_API_KEY as string ,
219- model : 'gpt-5.4-mini' ,
220- extraRequestBodyParameters : {
221- reasoning : {
222- effort : 'low' ,
223- } ,
224- } ,
225- } ) ,
231+ completionAdapter : createAgentCompletionAdapter ( 'gpt-5.4-mini' , 'low' ) ,
226232 } ,
227233 {
228234 name : 'Smart Thinking' ,
229- completionAdapter : new CompletionAdapterOpenAIResponses ( {
230- openAiApiKey : process . env . OPENAI_API_KEY as string ,
231- model : 'gpt-5.4' ,
232- extraRequestBodyParameters : {
233- reasoning : {
234- effort : 'xhigh' ,
235- } ,
236- } ,
237- } ) ,
235+ completionAdapter : createAgentCompletionAdapter ( 'gpt-5.4' , 'xhigh' ) ,
238236 } ,
239237 ] ,
240238 maxTokens : 10000 ,
0 commit comments