mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-09-29 15:31:08 -04:00
More granularity in the busy cursors
This commit is contained in:
parent
d3ad93759e
commit
bee185e874
@ -6,7 +6,6 @@ from qt.core import QComboBox, QDialog, QGroupBox, QHBoxLayout, QLabel, QStacked
|
|||||||
from calibre.ai import AICapabilities
|
from calibre.ai import AICapabilities
|
||||||
from calibre.ai.prefs import plugin_for_purpose, plugins_for_purpose, prefs
|
from calibre.ai.prefs import plugin_for_purpose, plugins_for_purpose, prefs
|
||||||
from calibre.gui2 import Application, error_dialog
|
from calibre.gui2 import Application, error_dialog
|
||||||
from calibre.gui2.widgets import BusyCursor
|
|
||||||
|
|
||||||
|
|
||||||
class ConfigureAI(QWidget):
|
class ConfigureAI(QWidget):
|
||||||
@ -61,9 +60,8 @@ class ConfigureAI(QWidget):
|
|||||||
return self.plugin_config_widgets[self.current_idx].validate()
|
return self.plugin_config_widgets[self.current_idx].validate()
|
||||||
|
|
||||||
def commit(self) -> bool:
|
def commit(self) -> bool:
|
||||||
with BusyCursor():
|
if not self.validate():
|
||||||
if not self.validate():
|
return False
|
||||||
return False
|
|
||||||
idx = self.current_idx
|
idx = self.current_idx
|
||||||
p, w = self.available_plugins[idx], self.plugin_config_widgets[idx]
|
p, w = self.available_plugins[idx], self.plugin_config_widgets[idx]
|
||||||
if not w.validate():
|
if not w.validate():
|
||||||
|
@ -9,6 +9,7 @@ from calibre.ai.ollama import OllamaAI
|
|||||||
from calibre.ai.prefs import pref_for_provider, set_prefs_for_provider
|
from calibre.ai.prefs import pref_for_provider, set_prefs_for_provider
|
||||||
from calibre.ai.utils import configure, plugin_for_name
|
from calibre.ai.utils import configure, plugin_for_name
|
||||||
from calibre.gui2 import error_dialog
|
from calibre.gui2 import error_dialog
|
||||||
|
from calibre.gui2.widgets import BusyCursor
|
||||||
|
|
||||||
pref = partial(pref_for_provider, OllamaAI.name)
|
pref = partial(pref_for_provider, OllamaAI.name)
|
||||||
|
|
||||||
@ -86,14 +87,18 @@ class ConfigWidget(QWidget):
|
|||||||
if not self.text_model:
|
if not self.text_model:
|
||||||
error_dialog(self, _('No model specified'), _('You specify a model to use for text based tasks.'), show=True)
|
error_dialog(self, _('No model specified'), _('You specify a model to use for text based tasks.'), show=True)
|
||||||
return False
|
return False
|
||||||
if not self.does_model_exist_locally(self.text_model):
|
with BusyCursor():
|
||||||
try:
|
exists = self.does_model_exist_locally(self.text_model)
|
||||||
avail = self.available_models()
|
|
||||||
except Exception:
|
if not exists:
|
||||||
import traceback
|
with BusyCursor():
|
||||||
det_msg = _('Failed to get list of available models with error:') + '\n' + traceback.format_exc()
|
try:
|
||||||
else:
|
avail = self.available_models()
|
||||||
det_msg = _('Available models:') + '\n' + '\n'.join(avail)
|
except Exception:
|
||||||
|
import traceback
|
||||||
|
det_msg = _('Failed to get list of available models with error:') + '\n' + traceback.format_exc()
|
||||||
|
else:
|
||||||
|
det_msg = _('Available models:') + '\n' + '\n'.join(avail)
|
||||||
|
|
||||||
error_dialog(self, _('No matching model'), _(
|
error_dialog(self, _('No matching model'), _(
|
||||||
'No model named {} found in Ollama. Click "Show details" to see a list of available models.').format(
|
'No model named {} found in Ollama. Click "Show details" to see a list of available models.').format(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user