mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-12-07 21:55:07 -05:00
Finish description of model widget
This commit is contained in:
parent
a750757d8e
commit
316287f249
@ -105,6 +105,7 @@ class Pricing(NamedTuple):
|
|||||||
class Model(NamedTuple):
|
class Model(NamedTuple):
|
||||||
name: str
|
name: str
|
||||||
id: str
|
id: str
|
||||||
|
slug: str
|
||||||
created: int
|
created: int
|
||||||
description: str
|
description: str
|
||||||
context_length: int
|
context_length: int
|
||||||
@ -126,7 +127,7 @@ class Model(NamedTuple):
|
|||||||
|
|
||||||
return Model(
|
return Model(
|
||||||
name=x['name'], id=x['id'], created=datetime.datetime.fromtimestamp(x['created'], datetime.timezone.utc),
|
name=x['name'], id=x['id'], created=datetime.datetime.fromtimestamp(x['created'], datetime.timezone.utc),
|
||||||
description=x['description'], context_length=x['context_length'],
|
description=x['description'], context_length=x['context_length'], slug=x['canonical_slug'],
|
||||||
parameters=tuple(x['supported_parameters']), pricing=Pricing.from_dict(x['pricing']),
|
parameters=tuple(x['supported_parameters']), pricing=Pricing.from_dict(x['pricing']),
|
||||||
is_moderated=x['top_provider']['is_moderated'], tokenizer=arch['tokenizer'],
|
is_moderated=x['top_provider']['is_moderated'], tokenizer=arch['tokenizer'],
|
||||||
capabilities=capabilities,
|
capabilities=capabilities,
|
||||||
|
|||||||
@ -13,6 +13,7 @@ from qt.core import (
|
|||||||
QLabel,
|
QLabel,
|
||||||
QLineEdit,
|
QLineEdit,
|
||||||
QListView,
|
QListView,
|
||||||
|
QLocale,
|
||||||
QModelIndex,
|
QModelIndex,
|
||||||
QPushButton,
|
QPushButton,
|
||||||
QSize,
|
QSize,
|
||||||
@ -32,6 +33,7 @@ from calibre.customize.ui import available_ai_provider_plugins
|
|||||||
from calibre.ebooks.txt.processor import create_markdown_object
|
from calibre.ebooks.txt.processor import create_markdown_object
|
||||||
from calibre.gui2 import Application, error_dialog, safe_open_url
|
from calibre.gui2 import Application, error_dialog, safe_open_url
|
||||||
from calibre.gui2.widgets2 import Dialog
|
from calibre.gui2.widgets2 import Dialog
|
||||||
|
from calibre.utils.date import qt_from_dt
|
||||||
from calibre.utils.icu import primary_sort_key
|
from calibre.utils.icu import primary_sort_key
|
||||||
|
|
||||||
pref = partial(pref_for_provider, OpenRouterAI.name)
|
pref = partial(pref_for_provider, OpenRouterAI.name)
|
||||||
@ -137,7 +139,6 @@ class ModelDetails(QTextBrowser):
|
|||||||
self.anchorClicked.connect(self.open_link)
|
self.anchorClicked.connect(self.open_link)
|
||||||
|
|
||||||
def show_model_details(self, m: 'AIModel'):
|
def show_model_details(self, m: 'AIModel'):
|
||||||
# we use output token price since there are typically more output than input tokens
|
|
||||||
if m.pricing.is_free:
|
if m.pricing.is_free:
|
||||||
price = f"<b>{_('Free')}</b>"
|
price = f"<b>{_('Free')}</b>"
|
||||||
else:
|
else:
|
||||||
@ -149,11 +150,17 @@ class ModelDetails(QTextBrowser):
|
|||||||
if m.pricing.image:
|
if m.pricing.image:
|
||||||
price += f'$ {m.pricing.image * 1e3:.2g}/K {_("input images")} '
|
price += f'$ {m.pricing.image * 1e3:.2g}/K {_("input images")} '
|
||||||
md = create_markdown_object(extensions=())
|
md = create_markdown_object(extensions=())
|
||||||
|
created = qt_from_dt(m.created).date()
|
||||||
html = f'''
|
html = f'''
|
||||||
<h2>{_('Description')}</h2>
|
<h2>{_('Description')}</h2>
|
||||||
<div>{md.convert(m.description)}</div>
|
<div>{md.convert(m.description)}</div>
|
||||||
<h2>{_('Price')}</h2>
|
<h2>{_('Price')}</h2>
|
||||||
<p>{price}</p>
|
<p>{price}</p>
|
||||||
|
<h2>{_('Details')}</h2>
|
||||||
|
<p>{_('Created:')} {QLocale.system().toString(created, QLocale.FormatType.ShortFormat)}<br>
|
||||||
|
{_('Context length:')} {QLocale.system().toString(m.context_length)}<br>
|
||||||
|
{_('See the model on')} <a href="https://openrouter.ai/{m.slug}">OpenRouter.ai</a>
|
||||||
|
</p>
|
||||||
'''
|
'''
|
||||||
self.setText(html)
|
self.setText(html)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user