bugfix
This commit is contained in:
parent
28a9cb52ae
commit
7c7db5bd67
@ -10,17 +10,18 @@ from .utils import (
|
|||||||
read_webpath,
|
read_webpath,
|
||||||
llm_query_price,
|
llm_query_price,
|
||||||
get_llm_by_model,
|
get_llm_by_model,
|
||||||
|
get_llms_by_catelog,
|
||||||
|
get_llms_sort_by_provider,
|
||||||
|
get_llmcatelogs,
|
||||||
|
get_llms_by_catelog_to_customer,
|
||||||
|
get_llmproviders,
|
||||||
|
get_llm,
|
||||||
BufferedLLMs
|
BufferedLLMs
|
||||||
)
|
)
|
||||||
|
|
||||||
from .llmclient import (
|
from .llmclient import (
|
||||||
get_llm,
|
|
||||||
inference_generator,
|
inference_generator,
|
||||||
inference,
|
inference
|
||||||
get_llmproviders,
|
|
||||||
get_llms_sort_by_provider,
|
|
||||||
get_llmcatelogs,
|
|
||||||
get_llms_by_catelog
|
|
||||||
)
|
)
|
||||||
from .accounting import (
|
from .accounting import (
|
||||||
checkCustomerBalance,
|
checkCustomerBalance,
|
||||||
|
|||||||
@ -141,7 +141,45 @@ async def get_llmcatelogs():
|
|||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
async def get_llms_by_catelog(catelogid=None):
|
async def get_llms_by_catelog_to_customer(catelogid=None, orderby='providerid'):
|
||||||
|
env = ServerEnv()
|
||||||
|
async with get_sor_context(env, 'llmage') as sor:
|
||||||
|
today = curDateString()
|
||||||
|
# Join with llm_catalog_rel to support multiple catalogs per LLM
|
||||||
|
sql = """select a.*, b.name as catelogname, rel.llmcatelogid as catelog_id
|
||||||
|
from llm a
|
||||||
|
join llm_catalog_rel rel on a.id = rel.llmid
|
||||||
|
join llmcatelog b on rel.llmcatelogid = b.id
|
||||||
|
where a.enabled_date <= ${today}$
|
||||||
|
and a.ppid is not null
|
||||||
|
and a.expired_date > ${today}$
|
||||||
|
"""
|
||||||
|
params = {'today': today, 'sort': orderby}
|
||||||
|
if catelogid:
|
||||||
|
sql += " and rel.llmcatelogid = ${catelogid}$"
|
||||||
|
params['catelogid'] = catelogid
|
||||||
|
|
||||||
|
sql += " order by rel.llmcatelogid, a.id"
|
||||||
|
|
||||||
|
recs = await sor.sqlExe(sql, params)
|
||||||
|
d = []
|
||||||
|
cid = ''
|
||||||
|
x = None
|
||||||
|
for r in recs:
|
||||||
|
if cid != r.catelog_id:
|
||||||
|
x = {
|
||||||
|
'catelogid': r.catelog_id,
|
||||||
|
'catelogname': r.catelogname,
|
||||||
|
'llms': [r]
|
||||||
|
}
|
||||||
|
d.append(x)
|
||||||
|
cid = r.catelog_id
|
||||||
|
else:
|
||||||
|
x['llms'].append(r)
|
||||||
|
return d
|
||||||
|
return []
|
||||||
|
|
||||||
|
async def get_llms_by_catelog(catelogid=None, orderby='providerid'):
|
||||||
env = ServerEnv()
|
env = ServerEnv()
|
||||||
async with get_sor_context(env, 'llmage') as sor:
|
async with get_sor_context(env, 'llmage') as sor:
|
||||||
today = curDateString()
|
today = curDateString()
|
||||||
@ -152,7 +190,7 @@ async def get_llms_by_catelog(catelogid=None):
|
|||||||
join llmcatelog b on rel.llmcatelogid = b.id
|
join llmcatelog b on rel.llmcatelogid = b.id
|
||||||
where a.enabled_date <= ${today}$
|
where a.enabled_date <= ${today}$
|
||||||
and a.expired_date > ${today}$"""
|
and a.expired_date > ${today}$"""
|
||||||
params = {'today': today}
|
params = {'today': today, 'sort': orderby}
|
||||||
if catelogid:
|
if catelogid:
|
||||||
sql += " and rel.llmcatelogid = ${catelogid}$"
|
sql += " and rel.llmcatelogid = ${catelogid}$"
|
||||||
params['catelogid'] = catelogid
|
params['catelogid'] = catelogid
|
||||||
|
|||||||
3
wwwroot/list_llms/index.dspy
Normal file
3
wwwroot/list_llms/index.dspy
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
lctype=params_kw.lctype
|
||||||
|
order_by=params_kw.orderby or 'providerid'
|
||||||
|
return await get_llms_by_catelog_to_customer(catelogid=lctype, orderby=orderby)
|
||||||
Loading…
x
Reference in New Issue
Block a user