mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-12-12 16:15:03 -05:00
Default to free-or-paid strategy
This commit is contained in:
parent
2506977e64
commit
6bba8d28ac
@ -13,7 +13,6 @@ from typing import Any, NamedTuple
|
|||||||
from urllib.request import Request
|
from urllib.request import Request
|
||||||
|
|
||||||
from calibre.ai import AICapabilities, ChatMessage, ChatMessageType, ChatResponse, NoFreeModels
|
from calibre.ai import AICapabilities, ChatMessage, ChatMessageType, ChatResponse, NoFreeModels
|
||||||
from calibre.ai.open_router import OpenRouterAI
|
|
||||||
from calibre.ai.prefs import pref_for_provider
|
from calibre.ai.prefs import pref_for_provider
|
||||||
from calibre.ai.utils import StreamedResponseAccumulator, chat_with_error_handler, get_cached_resource, read_streaming_response
|
from calibre.ai.utils import StreamedResponseAccumulator, chat_with_error_handler, get_cached_resource, read_streaming_response
|
||||||
from calibre.constants import cache_dir
|
from calibre.constants import cache_dir
|
||||||
@ -24,6 +23,7 @@ MODELS_URL = 'https://openrouter.ai/api/v1/models'
|
|||||||
|
|
||||||
|
|
||||||
def pref(key: str, defval: Any = None) -> Any:
|
def pref(key: str, defval: Any = None) -> Any:
|
||||||
|
from calibre.ai.open_router import OpenRouterAI
|
||||||
return pref_for_provider(OpenRouterAI.name, key, defval)
|
return pref_for_provider(OpenRouterAI.name, key, defval)
|
||||||
|
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ def model_choice_for_text() -> Iterator[Model, ...]:
|
|||||||
if m := get_available_models().get(model_id):
|
if m := get_available_models().get(model_id):
|
||||||
yield m
|
yield m
|
||||||
return
|
return
|
||||||
match pref('model_choice_strategy', 'free'):
|
match pref('model_choice_strategy', 'free-or-paid'):
|
||||||
case 'free-or-paid':
|
case 'free-or-paid':
|
||||||
yield from free_model_choice_for_text(allow_paid=True)
|
yield from free_model_choice_for_text(allow_paid=True)
|
||||||
case 'free-only':
|
case 'free-only':
|
||||||
|
|||||||
@ -395,7 +395,7 @@ class ConfigWidget(QWidget):
|
|||||||
ms.addItem(_('Free only'), 'free-only')
|
ms.addItem(_('Free only'), 'free-only')
|
||||||
ms.addItem(_('Free or paid'), 'free-or-paid')
|
ms.addItem(_('Free or paid'), 'free-or-paid')
|
||||||
ms.addItem(_('High quality'), 'native')
|
ms.addItem(_('High quality'), 'native')
|
||||||
if strat := pref('model_choice_strategy'):
|
if strat := pref('model_choice_strategy', 'free-or-paid'):
|
||||||
ms.setCurrentIndex(max(0, ms.findData(strat)))
|
ms.setCurrentIndex(max(0, ms.findData(strat)))
|
||||||
ms.setToolTip('<p>' + _(
|
ms.setToolTip('<p>' + _(
|
||||||
'The model choice strategy controls how a model to query is chosen when no specific'
|
'The model choice strategy controls how a model to query is chosen when no specific'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user