bugfix
This commit is contained in:
parent
ba00d5a672
commit
ffa48fd1e1
@ -1,13 +1,19 @@
|
|||||||
from sqlor.dbpools import DBPools
|
from sqlor.dbpools import DBPools
|
||||||
|
|
||||||
async def get_ragllms(request, **params):
|
async def get_ragllms_by_catelog(request, **params):
|
||||||
|
catelogid = params.get('catelogid')
|
||||||
|
if not catelogid:
|
||||||
|
raise 'need applies catelogid'
|
||||||
|
|
||||||
env = request._run_ns
|
env = request._run_ns
|
||||||
userid = await env.get_user()
|
userid = await env.get_user()
|
||||||
userorgid = await env.get_userorgid()
|
userorgid = await env.get_userorgid()
|
||||||
dbname = env.get_module_dbname('rag')
|
dbname = env.get_module_dbname('rag')
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
sql = '''select * from ragllm where userscope = 'unlimited' or ownerid = ${userorgid}$'''
|
sql = '''select * from ragllm
|
||||||
|
where catelogid = ${catelogid}$
|
||||||
|
and (userscope = 'unlimited' or ownerid = ${userorgid}$)'''
|
||||||
recs = await sor.sqlExe(sql, {'userorgid': userorgid})
|
recs = await sor.sqlExe(sql, {'userorgid': userorgid})
|
||||||
return recs
|
return recs
|
||||||
return []
|
return []
|
||||||
|
|||||||
43
wwwroot/ragllm_dialog.ui
Normal file
43
wwwroot/ragllm_dialog.ui
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
{% if get_user() %}
|
||||||
|
{% set llm = get_llm(params_kw.id) %}
|
||||||
|
{% if llm %}
|
||||||
|
{
|
||||||
|
"widgettype":"LlmIO",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%",
|
||||||
|
"title":"{{llm.name}}",
|
||||||
|
"list_models_url":"{{entire_url('list_paging_catelog_llms.dspy')}}",
|
||||||
|
"estimate_url":"{{entire_url('model_estimate.dspy')}}",
|
||||||
|
"input_fields":{{llm.input_fields}},
|
||||||
|
"models":[
|
||||||
|
{
|
||||||
|
"llmid":"{{llm.id}}",
|
||||||
|
"llmcatelogid":"{{llm.llmcatelogid}}",
|
||||||
|
"response_mode": "{{llm.stream}}",
|
||||||
|
"icon":"{{entire_url('/appbase/show_icon.dspy')}}?id={{llm.iconid}}",
|
||||||
|
"url":"{{entire_url('/llmage/llminference.dspy')}}",
|
||||||
|
"model":"{{llm.model}}",
|
||||||
|
"modelname":"{{llm.name}}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{% else %}
|
||||||
|
{
|
||||||
|
"widgettype":"Text",
|
||||||
|
"options":{
|
||||||
|
"otext": "没找到模型",
|
||||||
|
"i18n":true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{
|
||||||
|
"widgettype":"Text",
|
||||||
|
"options":{
|
||||||
|
"otext":"You need login to use llm",
|
||||||
|
"i18n":true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
6
wwwroot/ragllminference.dspy
Normal file
6
wwwroot/ragllminference.dspy
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
debug(f'{params_kw=}')
|
||||||
|
userid = await get_user()
|
||||||
|
if userid is None:
|
||||||
|
return UiError(title='llm inference', message='Please login first')
|
||||||
|
env = DictObject(**globals())
|
||||||
|
return await inference(request, env=env)
|
||||||
97
wwwroot/show_ragllms.ui
Normal file
97
wwwroot/show_ragllms.ui
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
{
|
||||||
|
"widgettype":"VScrollPanel",
|
||||||
|
"options":{
|
||||||
|
"width":"100%",
|
||||||
|
"height":"100%"
|
||||||
|
},
|
||||||
|
"subwidgets":[
|
||||||
|
{% for cate in get_llmcatelogs() %}
|
||||||
|
{
|
||||||
|
"widgettype": "VBox",
|
||||||
|
"options":{
|
||||||
|
"width":"100%"
|
||||||
|
},
|
||||||
|
"subwidgets":[
|
||||||
|
{
|
||||||
|
"widgettype":"Title3",
|
||||||
|
"options":{
|
||||||
|
"text":"{{cate.name}}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype":"DynamicColumn",
|
||||||
|
"options":{
|
||||||
|
"css":"filler",
|
||||||
|
"width":"100%"
|
||||||
|
},
|
||||||
|
"subwidgets":[
|
||||||
|
{% for llm in get_ragllms_by_catelog(cate.id) %}
|
||||||
|
{
|
||||||
|
"widgettype":"VScrollPanel",
|
||||||
|
"options":{
|
||||||
|
"css":"card",
|
||||||
|
"bgcolor": "#def0f0",
|
||||||
|
"cwidth":20,
|
||||||
|
"cheight":12
|
||||||
|
},
|
||||||
|
"subwidgets":[
|
||||||
|
{
|
||||||
|
"widgettype":"HBox",
|
||||||
|
"options":{
|
||||||
|
"cheight":2
|
||||||
|
},
|
||||||
|
"subwidgets":[
|
||||||
|
{
|
||||||
|
"widgettype":"Svg",
|
||||||
|
"options":{
|
||||||
|
"rate":1.5,
|
||||||
|
"url":"{{entire_url('/appbase/show_icon.dspy')}}?id={{llm.iconid}}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype":"Title6",
|
||||||
|
"options":{
|
||||||
|
"text":"{{llm.name}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype":"Text",
|
||||||
|
"options":{
|
||||||
|
"text":{{json.dumps(llm.description, ensure_ascii=False)}},
|
||||||
|
"wrap":true,
|
||||||
|
"halign":"left"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"binds":[
|
||||||
|
{
|
||||||
|
"wid":"self",
|
||||||
|
"event":"click",
|
||||||
|
"actiontype":"urlwidget",
|
||||||
|
"target":"PopupWindow",
|
||||||
|
"popup_options":{
|
||||||
|
"title":"{{llm.name}}",
|
||||||
|
"cwidth":24,
|
||||||
|
"height":"80%"
|
||||||
|
},
|
||||||
|
"options":{
|
||||||
|
"params":{
|
||||||
|
"id":"{{llm.id}}"
|
||||||
|
},
|
||||||
|
"url":"{{entire_url('./ragllm_dialog.ui')}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{% if not loop.last %}, {% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{% if not loop.last %}, {% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user