diff -r c55270946c9a -r cb6af351310b PluginAiOllama.py --- a/PluginAiOllama.py Thu Aug 29 13:11:10 2024 +0200 +++ b/PluginAiOllama.py Thu Aug 29 13:11:59 2024 +0200 @@ -9,7 +9,7 @@ import os -from PyQt6.QtCore import QObject, Qt, QTranslator, pyqtSignal +from PyQt6.QtCore import QCoreApplication, QObject, Qt, QTranslator, pyqtSignal from PyQt6.QtGui import QKeySequence from eric7 import Globals, Preferences @@ -50,17 +50,20 @@ ollamaInterfacePluginObject = None -def pageCreationFunction(configDlg): +def createOllamaPage(_configDlg): """ - Function to create the Translator configuration page. + Function to create the 'ollama' interface' configuration page. - @param configDlg reference to the configuration dialog + @param _configDlg reference to the configuration dialog @type ConfigurationWidget @return reference to the configuration page - @rtype TranslatorPage + @rtype OllamaPage """ - # TODO: not implemented yet - page = None # change this line to create the configuration page + from OllamaInterface.ConfigurationPage.OllamaPage import OllamaPage + + global ollamaInterfacePluginObject + + page = OllamaPage(ollamaInterfacePluginObject) return page @@ -71,12 +74,16 @@ @return dictionary containing the relevant data @rtype dict """ - # TODO: not implemented yet + usesDarkPalette = ericApp().usesDarkPalette() + iconSuffix = "dark" if usesDarkPalette else "light" + return { - "<unique key>": [ - "<display string>", - "<pixmap filename>", - pageCreationFunction, + "ollamaPage": [ + QCoreApplication.translate( + "PluginOllamaInterface", "ollama AI Interface" + ), + os.path.join("OllamaInterface", "icons", "ollama22-{0}".format(iconSuffix)), + createOllamaPage, None, None, ], @@ -282,6 +289,14 @@ self.PreferencesKey + "/" + key, self.__defaults[key] ) ) + elif key in ("OllamaHost", "OllamaModelLibraryUrl"): + value = Preferences.Prefs.settings.value( + self.PreferencesKey + "/" + key, self.__defaults[key] + ) + if not value: + # use default value if empty + value = self.__defaults[key] + return value else: return Preferences.Prefs.settings.value( self.PreferencesKey + "/" + key, self.__defaults[key]