feat: add pricing display to model cards
- utils.py: get_llms_by_catelog now queries all distinct ppids for each model and calls get_pricing_display to get pricing text - show_llms_cards.ui: added Filler with pricing-box CSS to display pricing info - model_plaza.css: added styles for pricing-box and pricing-text (light/dark mode)
This commit is contained in:
parent
2792fc7bda
commit
8ee2eccc55
@ -353,6 +353,21 @@ async def get_llms_by_catelog(catelogid=None, orderby='providerid'):
|
||||
cid = ''
|
||||
x = None
|
||||
for r in recs:
|
||||
# 查询该模型的所有定价信息
|
||||
pp_sql = """select distinct m.ppid
|
||||
from llm_api_map m
|
||||
where m.llmid = ${llmid}$ and m.ppid is not null"""
|
||||
pp_recs = await sor.sqlExe(pp_sql, {'llmid': r.id})
|
||||
|
||||
pricing_list = []
|
||||
for pp in pp_recs:
|
||||
try:
|
||||
pd = await env.get_pricing_display(pp.ppid)
|
||||
pricing_list.append(pd.get('display_text', ''))
|
||||
except:
|
||||
pass
|
||||
r.pricing_display = pricing_list
|
||||
|
||||
if cid != r.catelog_id:
|
||||
x = {
|
||||
'catelogid': r.catelog_id,
|
||||
|
||||
@ -103,3 +103,26 @@
|
||||
line-height: 1.5;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
/* Pricing display area */
|
||||
.pricing-box {
|
||||
margin-top: 8px;
|
||||
padding-top: 8px;
|
||||
border-top: 1px solid var(--sage-border, #e2e8f0);
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.pricing-text {
|
||||
font-size: 0.85em;
|
||||
line-height: 1.4;
|
||||
opacity: 0.75;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .pricing-box {
|
||||
border-top-color: #475569;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .pricing-text {
|
||||
color: #94A3B8;
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
"options":{
|
||||
"css":"card plaza-card",
|
||||
"cwidth":25,
|
||||
"cheight":12
|
||||
"cheight":16
|
||||
},
|
||||
"subwidgets":[
|
||||
{
|
||||
@ -57,6 +57,25 @@
|
||||
"wrap":true,
|
||||
"halign":"left"
|
||||
}
|
||||
},
|
||||
{
|
||||
"widgettype":"Filler",
|
||||
"options":{
|
||||
"css":"pricing-box"
|
||||
},
|
||||
"subwidgets":[
|
||||
{% for pricing_text in llm.pricing_display %}
|
||||
{
|
||||
"widgettype":"Text",
|
||||
"options":{
|
||||
"text":{{json.dumps(pricing_text, ensure_ascii=False)}},
|
||||
"wrap":true,
|
||||
"halign":"left",
|
||||
"css":"pricing-text"
|
||||
}
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
]
|
||||
}
|
||||
],
|
||||
"binds":[
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user