1313use OCA \OpenAi \AppInfo \Application ;
1414use OCA \OpenAi \Service \OpenAiAPIService ;
1515use OCA \OpenAi \Service \OpenAiSettingsService ;
16+ use OCP \IAppConfig ;
1617use OCP \ICacheFactory ;
17- use OCP \IConfig ;
1818use OCP \L10N \IFactory ;
1919use OCP \Translation \IDetectLanguageProvider ;
2020use OCP \Translation \ITranslationProvider ;
@@ -28,7 +28,7 @@ public function __construct(
2828 private IFactory $ l10nFactory ,
2929 private OpenAiAPIService $ openAiAPIService ,
3030 private LoggerInterface $ logger ,
31- private IConfig $ config ,
31+ private IAppConfig $ appConfig ,
3232 private ?string $ userId ,
3333 private OpenAiSettingsService $ openAiSettingsService ,
3434 ) {
@@ -71,7 +71,7 @@ public function getAvailableLanguages(): array {
7171
7272 public function detectLanguage (string $ text ): ?string {
7373 $ prompt = 'What language is this (answer with the language name only, in English): ' . $ text ;
74- $ adminModel = $ this ->config -> getAppValue (Application::APP_ID , 'default_completion_model_id ' , Application::DEFAULT_COMPLETION_MODEL_ID ) ?: Application::DEFAULT_COMPLETION_MODEL_ID ;
74+ $ adminModel = $ this ->appConfig -> getValueString (Application::APP_ID , 'default_completion_model_id ' , Application::DEFAULT_MODEL_ID , lazy: true ) ?: Application::DEFAULT_MODEL_ID ;
7575 try {
7676 if ($ this ->openAiAPIService ->isUsingOpenAi () || $ this ->openAiSettingsService ->getChatEndpointEnabled ()) {
7777 $ completion = $ this ->openAiAPIService ->createChatCompletion ($ this ->userId , $ adminModel , $ prompt , null , null , 1 , 100 );
@@ -118,7 +118,7 @@ public function translate(?string $fromLanguage, string $toLanguage, string $tex
118118 $ this ->logger ->debug ('OpenAI translation TO[ ' . $ toLanguage . '] ' , ['app ' => Application::APP_ID ]);
119119 $ prompt = 'Translate to ' . $ toLanguage . ': ' . $ text ;
120120 }
121- $ adminModel = $ this ->config -> getAppValue (Application::APP_ID , 'default_completion_model_id ' , Application::DEFAULT_COMPLETION_MODEL_ID ) ?: Application::DEFAULT_COMPLETION_MODEL_ID ;
121+ $ adminModel = $ this ->appConfig -> getValueString (Application::APP_ID , 'default_completion_model_id ' , Application::DEFAULT_MODEL_ID , lazy: true ) ?: Application::DEFAULT_MODEL_ID ;
122122
123123 if ($ this ->openAiAPIService ->isUsingOpenAi () || $ this ->openAiSettingsService ->getChatEndpointEnabled ()) {
124124 $ completion = $ this ->openAiAPIService ->createChatCompletion ($ this ->userId , $ adminModel , $ prompt , null , null , 1 , PHP_INT_MAX );
0 commit comments