fix: catelog selection logic and backward compatibility
- utils.py: get_llmage_llm - when catelogid provided, use it instead of forcing isdefaultcatelog=1 - list_paging_catelog_llms.dspy: handle missing llmid in SQL, add llmcatelogid to returned rows - llm_dialog.ui: use Jinja2 namespace for variable scoping in for loop
This commit is contained in:
parent
52312b0a06
commit
4d455da18c
@ -258,9 +258,14 @@ where 1=1
|
|||||||
"""
|
"""
|
||||||
ns = {}
|
ns = {}
|
||||||
if llmid:
|
if llmid:
|
||||||
sql += " and a.id = ${llmid}$ and m.isdefaultcatelog = '1'"
|
sql += " and a.id = ${llmid}$"
|
||||||
ns['llmid'] = llmid
|
ns['llmid'] = llmid
|
||||||
if catelogid:
|
if catelogid:
|
||||||
|
sql += " and m.llmcatelogid = ${catelogid}$"
|
||||||
|
ns['catelogid'] = catelogid
|
||||||
|
else:
|
||||||
|
sql += " and m.isdefaultcatelog = '1'"
|
||||||
|
elif catelogid:
|
||||||
sql += " and m.llmcatelogid = ${catelogid}$"
|
sql += " and m.llmcatelogid = ${catelogid}$"
|
||||||
ns['catelogid'] = catelogid
|
ns['catelogid'] = catelogid
|
||||||
sql += " order by m.llmcatelogid, a.id"
|
sql += " order by m.llmcatelogid, a.id"
|
||||||
|
|||||||
@ -33,14 +33,18 @@ where a.status = 'published'
|
|||||||
and m.llmcatelogid = ${llmcatelogid}$
|
and m.llmcatelogid = ${llmcatelogid}$
|
||||||
) x left join historyformat y on x.hfid = y.id
|
) x left join historyformat y on x.hfid = y.id
|
||||||
left join uapiio z on x.ioid = z.id
|
left join uapiio z on x.ioid = z.id
|
||||||
where x.id != ${llmid}$
|
where 1=1
|
||||||
"""
|
"""
|
||||||
|
llmid = params_kw.get('llmid')
|
||||||
|
if llmid:
|
||||||
|
sql += " and x.id != ${llmid}$"
|
||||||
ns = params_kw.copy()
|
ns = params_kw.copy()
|
||||||
ns.page = page
|
ns.page = page
|
||||||
ns.pagerows = pagerows
|
ns.pagerows = pagerows
|
||||||
recs = await sor.sqlPaging(sql, ns)
|
recs = await sor.sqlPaging(sql, ns)
|
||||||
for r in recs.get('rows', []):
|
for r in recs.get('rows', []):
|
||||||
r.llmid = r.id
|
r.llmid = r.id
|
||||||
|
r.llmcatelogid = llmcatelogid
|
||||||
r.modelname = r.name
|
r.modelname = r.name
|
||||||
r.description = ''.join(''.join(r.description.split('\n')).split('\r'))
|
r.description = ''.join(''.join(r.description.split('\n')).split('\r'))
|
||||||
r.response_mode = r.stream
|
r.response_mode = r.stream
|
||||||
|
|||||||
@ -4,12 +4,12 @@
|
|||||||
{% if params_kw.id %}
|
{% if params_kw.id %}
|
||||||
{% if checkCustomerBalance(params_kw.id, userid, userorgid) %}
|
{% if checkCustomerBalance(params_kw.id, userid, userorgid) %}
|
||||||
{% set catelogs = get_llm_catelogs(params_kw.id) %}
|
{% set catelogs = get_llm_catelogs(params_kw.id) %}
|
||||||
{% set active_catelogid = params_kw.get('catelogid', '') %}
|
{% set ns = namespace(active_catelogid=params_kw.get('catelogid', '')) %}
|
||||||
{% if not active_catelogid and catelogs %}
|
{% if not ns.active_catelogid %}
|
||||||
{% for c in catelogs %}{% if c.isdefault %}{% set active_catelogid = c.catelogid %}{% endif %}{% endfor %}
|
{% for c in catelogs %}{% if c.isdefault and not ns.active_catelogid %}{% set ns.active_catelogid = c.catelogid %}{% endif %}{% endfor %}
|
||||||
{% if not active_catelogid and catelogs %}{% set active_catelogid = catelogs[0].catelogid %}{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% set llm = get_llm(params_kw.id, active_catelogid) %}
|
{% if not ns.active_catelogid and catelogs %}{% set ns.active_catelogid = catelogs[0].catelogid %}{% endif %}
|
||||||
|
{% set llm = get_llm(params_kw.id, ns.active_catelogid) %}
|
||||||
{% set kdbs = get_user_kdbs(request) %}
|
{% set kdbs = get_user_kdbs(request) %}
|
||||||
{% if llm %}
|
{% if llm %}
|
||||||
{% if len(catelogs) > 1 %}
|
{% if len(catelogs) > 1 %}
|
||||||
@ -34,7 +34,7 @@
|
|||||||
"options":{
|
"options":{
|
||||||
"label":"{{c.catelogname}}",
|
"label":"{{c.catelogname}}",
|
||||||
"actiontype":"link",
|
"actiontype":"link",
|
||||||
{% if c.catelogid == active_catelogid %}
|
{% if c.catelogid == ns.active_catelogid %}
|
||||||
"css":"primary",
|
"css":"primary",
|
||||||
{% endif %}
|
{% endif %}
|
||||||
"url":"{{entire_url('/llmage/llm_dialog.ui')}}?id={{params_kw.id}}&catelogid={{c.catelogid}}"
|
"url":"{{entire_url('/llmage/llm_dialog.ui')}}?id={{params_kw.id}}&catelogid={{c.catelogid}}"
|
||||||
@ -54,13 +54,13 @@
|
|||||||
"kdb_setting":{},
|
"kdb_setting":{},
|
||||||
"get_kdb_url": "{{entire_url('/rag/get_my_kdbs.dspy')}}",
|
"get_kdb_url": "{{entire_url('/rag/get_my_kdbs.dspy')}}",
|
||||||
{% endif %}
|
{% endif %}
|
||||||
"list_models_url":"{{entire_url('list_paging_catelog_llms.dspy')}}?llmcatelogid={{active_catelogid}}",
|
"list_models_url":"{{entire_url('list_paging_catelog_llms.dspy')}}?llmcatelogid={{ns.active_catelogid}}",
|
||||||
"estimate_url":"{{entire_url('model_estimate.dspy')}}",
|
"estimate_url":"{{entire_url('model_estimate.dspy')}}",
|
||||||
"input_fields":{{llm.input_fields}},
|
"input_fields":{{llm.input_fields}},
|
||||||
"models":[
|
"models":[
|
||||||
{
|
{
|
||||||
"llmid":"{{llm.id}}",
|
"llmid":"{{llm.id}}",
|
||||||
"llmcatelogid":"{{active_catelogid}}",
|
"llmcatelogid":"{{ns.active_catelogid}}",
|
||||||
"response_mode": "{{llm.stream}}",
|
"response_mode": "{{llm.stream}}",
|
||||||
"icon":"{{entire_url('/appbase/show_icon.dspy')}}?id={{llm.iconid}}",
|
"icon":"{{entire_url('/appbase/show_icon.dspy')}}?id={{llm.iconid}}",
|
||||||
"url":"{{entire_url('/llmage/llminference.dspy')}}",
|
"url":"{{entire_url('/llmage/llminference.dspy')}}",
|
||||||
@ -90,14 +90,14 @@
|
|||||||
"kdb_setting":{},
|
"kdb_setting":{},
|
||||||
"get_kdb_url": "{{entire_url('/rag/get_my_kdbs.dspy')}}",
|
"get_kdb_url": "{{entire_url('/rag/get_my_kdbs.dspy')}}",
|
||||||
{% endif %}
|
{% endif %}
|
||||||
"list_models_url":"{{entire_url('list_paging_catelog_llms.dspy')}}{% if active_catelogid %}?llmcatelogid={{active_catelogid}}{% endif %}",
|
"list_models_url":"{{entire_url('list_paging_catelog_llms.dspy')}}{% if ns.active_catelogid %}?llmcatelogid={{ns.active_catelogid}}{% endif %}",
|
||||||
"estimate_url":"{{entire_url('model_estimate.dspy')}}",
|
"estimate_url":"{{entire_url('model_estimate.dspy')}}",
|
||||||
"input_fields":{{llm.input_fields}},
|
"input_fields":{{llm.input_fields}},
|
||||||
"models":[
|
"models":[
|
||||||
{
|
{
|
||||||
"llmid":"{{llm.id}}",
|
"llmid":"{{llm.id}}",
|
||||||
{% if active_catelogid %}
|
{% if ns.active_catelogid %}
|
||||||
"llmcatelogid":"{{active_catelogid}}",
|
"llmcatelogid":"{{ns.active_catelogid}}",
|
||||||
{% endif %}
|
{% endif %}
|
||||||
"response_mode": "{{llm.stream}}",
|
"response_mode": "{{llm.stream}}",
|
||||||
"icon":"{{entire_url('/appbase/show_icon.dspy')}}?id={{llm.iconid}}",
|
"icon":"{{entire_url('/appbase/show_icon.dspy')}}?id={{llm.iconid}}",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user