llmage/wwwroot/llm_dialog.ui
yumoqing 52312b0a06 feat: llm_dialog.ui catelog tabs + get_llm_catelogs + inference passes catelogid
- utils.py: get_llmcatelogid -> get_llm_catelogs (returns ALL catelogs with name+isdefault)
- llmclient.py: inference() passes params_kw.llmcatelogid to get_llm()
- llm_dialog.ui: renders catelog tab buttons when model has multiple catelogs,
  defaults to isdefaultcatelog, passes llmcatelogid to both LlmIO models and list_models_url
- init.py: export get_llm_catelogs
2026-06-11 19:22:17 +08:00

154 lines
3.7 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% if get_user() %}
{% set userid = get_user() %}
{% set userorgid = get_userorgid() %}
{% if params_kw.id %}
{% if checkCustomerBalance(params_kw.id, userid, userorgid) %}
{% set catelogs = get_llm_catelogs(params_kw.id) %}
{% set active_catelogid = params_kw.get('catelogid', '') %}
{% if not active_catelogid and catelogs %}
{% for c in catelogs %}{% if c.isdefault %}{% set active_catelogid = c.catelogid %}{% endif %}{% endfor %}
{% if not active_catelogid and catelogs %}{% set active_catelogid = catelogs[0].catelogid %}{% endif %}
{% endif %}
{% set llm = get_llm(params_kw.id, active_catelogid) %}
{% set kdbs = get_user_kdbs(request) %}
{% if llm %}
{% if len(catelogs) > 1 %}
{
"widgettype":"VBox",
"options":{
"width":"100%",
"height":"100%"
},
"subwidgets":[
{
"widgettype":"HBox",
"options":{
"cheight":3,
"css":"card",
"padding":"8px"
},
"subwidgets":[
{% for c in catelogs %}
{
"widgettype":"Button",
"options":{
"label":"{{c.catelogname}}",
"actiontype":"link",
{% if c.catelogid == active_catelogid %}
"css":"primary",
{% endif %}
"url":"{{entire_url('/llmage/llm_dialog.ui')}}?id={{params_kw.id}}&catelogid={{c.catelogid}}"
}
}{% if not loop.last %},{% endif %}
{% endfor %}
]
},
{
"widgettype":"LlmIO",
"options":{
"width":"100%",
"height":"100%",
"title":"{{llm.name}}",
{% if len(kdbs) > 0 %}
"enabled_kdb": true,
"kdb_setting":{},
"get_kdb_url": "{{entire_url('/rag/get_my_kdbs.dspy')}}",
{% endif %}
"list_models_url":"{{entire_url('list_paging_catelog_llms.dspy')}}?llmcatelogid={{active_catelogid}}",
"estimate_url":"{{entire_url('model_estimate.dspy')}}",
"input_fields":{{llm.input_fields}},
"models":[
{
"llmid":"{{llm.id}}",
"llmcatelogid":"{{active_catelogid}}",
"response_mode": "{{llm.stream}}",
"icon":"{{entire_url('/appbase/show_icon.dspy')}}?id={{llm.iconid}}",
"url":"{{entire_url('/llmage/llminference.dspy')}}",
{% if llm.stream == 'stream' %}
"stream": true,
{% endif %}
{% if llm.stream =='async' %}
"query_url": "{{entire_url('/llmage/tasks')}}",
{% endif %}
"model":"{{llm.model}}",
"modelname":"{{llm.name}}"
}
]
}
}
]
}
{% else %}
{
"widgettype":"LlmIO",
"options":{
"width":"100%",
"height":"100%",
"title":"{{llm.name}}",
{% if len(kdbs) > 0 %}
"enabled_kdb": true,
"kdb_setting":{},
"get_kdb_url": "{{entire_url('/rag/get_my_kdbs.dspy')}}",
{% endif %}
"list_models_url":"{{entire_url('list_paging_catelog_llms.dspy')}}{% if active_catelogid %}?llmcatelogid={{active_catelogid}}{% endif %}",
"estimate_url":"{{entire_url('model_estimate.dspy')}}",
"input_fields":{{llm.input_fields}},
"models":[
{
"llmid":"{{llm.id}}",
{% if active_catelogid %}
"llmcatelogid":"{{active_catelogid}}",
{% endif %}
"response_mode": "{{llm.stream}}",
"icon":"{{entire_url('/appbase/show_icon.dspy')}}?id={{llm.iconid}}",
"url":"{{entire_url('/llmage/llminference.dspy')}}",
{% if llm.stream == 'stream' %}
"stream": true,
{% endif %}
{% if llm.stream =='async' %}
"query_url": "{{entire_url('/llmage/tasks')}}",
{% endif %}
"model":"{{llm.model}}",
"modelname":"{{llm.name}}"
}
]
}
}
{% endif %}
{% else %}
{
"widgettype":"Text",
"options":{
"otext": "没找到模型",
"i18n":true
}
}
{% endif %}
{% else %}
{
"widgettype":"Text",
"options":{
"otext":"Not enrogh balance to use llm",
"i18n":true
}
}
{% endif %}
{% else %}
{
"widgettype":"Text",
"options":{
"otext":"无效的参数未找到模型ID",
"i18n":true
}
}
{% endif %}
{% else %}
{
"widgettype":"Text",
"options":{
"otext":"You need login to use llm",
"i18n":true
}
}
{% endif %}