bugfix
This commit is contained in:
parent
42f6633813
commit
9ec7d2f686
@ -1,3 +1,11 @@
|
||||
from llmage.llmclient import get_llm, inference, get_llmcatelogs, \
|
||||
get_llms_by_catelog
|
||||
from ahserver.serverenv import ServerEnv
|
||||
|
||||
def load_llmage():
|
||||
pass
|
||||
env = ServerEnv()
|
||||
env.get_llm = get_llm
|
||||
env.inference = inference
|
||||
env.get_llms_by_catelog = get_llms_by_catelog
|
||||
eng.get_llmcatelogs = get_llmcatelogs
|
||||
|
||||
|
||||
@ -1,8 +1,49 @@
|
||||
from traceback import format_exc
|
||||
from sqlor.dbpools import DBPools
|
||||
from appPublic.log import debug, exception
|
||||
from uapi.appapi import UAPI
|
||||
from uapi.appapi import UAPI, sor_get_callerid, sor_get_uapi
|
||||
from ahserver.serverenv get_serverenv
|
||||
|
||||
async def get_llmcatelogs():
|
||||
db = DBPools()
|
||||
dbname = get_serverenv('get_module_dbname')('llmage')
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
recs = await sor.R('llmcatelog', {})
|
||||
return recs
|
||||
|
||||
return []
|
||||
|
||||
async def get_llms_by_catelog(catelogid):
|
||||
db = DBPools()
|
||||
dbname = get_serverenv('get_module_dbname')('llmage')
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
recs = await sor.R('llm', {'catelogid': catelogid})
|
||||
return recs
|
||||
return []
|
||||
|
||||
async def get_llm(llmid):
|
||||
db = DBPools()
|
||||
dbname = get_serverenv('get_module_dbname')('llmage')
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
sql = """select a.*,
|
||||
b.input_view, b.output_view, b.system_message,
|
||||
b.user_message,
|
||||
b.assisant_message from llm a, llmcatelog b
|
||||
where a.catelogid = b.id
|
||||
and a.id = ${llmid}$"""
|
||||
recs = await sor.sqlExe(sql, {'llmid': llmid})
|
||||
if len(recs) > 0:
|
||||
r = recs[0]
|
||||
apis = await sor_get_uapi(sor, r.upappid, r.apiname)
|
||||
if len(apis) == 0:
|
||||
e = Exception(f'{r.upappid=},{r.apiname=} uapi not found')
|
||||
exception(f'{e=}\n{format_exc()}')
|
||||
raise e
|
||||
api = apis[0]
|
||||
r.inputfields = api.paramsdesc
|
||||
return recs[0]
|
||||
return None
|
||||
|
||||
async def inference(request, env):
|
||||
uapi = UAPI(request, env)
|
||||
params = env.params_kw
|
||||
|
||||
Binary file not shown.
30
wwwroot/llm_dialog.ui
Normal file
30
wwwroot/llm_dialog.ui
Normal file
@ -0,0 +1,30 @@
|
||||
{% set llm = get_llm(params_kw.id) %}
|
||||
{% if llm %}
|
||||
{
|
||||
"widgettype":"LlmIO",
|
||||
"options":{
|
||||
"width":"100%",
|
||||
"height":"100%",
|
||||
"list_models_url":"{{entire_url('list_mti_models.dspy')}}",
|
||||
"estimate_url":"/estimate/model_estimate.dspy",
|
||||
"input_fields":{{llm.input_fields}},
|
||||
"input_view":{{llm.input_view}},
|
||||
"models":[
|
||||
{
|
||||
"llmidid":"{{llm.id}}",
|
||||
"modeltypeid":"{{llm.catelogid}}",
|
||||
"output_view":{{llm.output_view}},
|
||||
"input_from":"userinput",
|
||||
"system_message_format":{{llm.system_message}},
|
||||
"user_message_format":{{llm.user_message}},
|
||||
"llm_message_format":{{llm.assisant_message}},
|
||||
"icon":"{{entire_url('/appbase/get_icon.dspy')}}?id={{llm.iconid}}",
|
||||
"url":"{{entire_url('/llmage/llminference.dspy')}}",
|
||||
"model":"{{llm.model}}",
|
||||
"modelname":"{{llm.name}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
{% else %}
|
||||
{% endif %}
|
||||
2
wwwroot/llminference.dspy
Normal file
2
wwwroot/llminference.dspy
Normal file
@ -0,0 +1,2 @@
|
||||
env = DictObject(**globals())
|
||||
return inference(request, env=env)
|
||||
76
wwwroot/show_llms.ui
Normal file
76
wwwroot/show_llms.ui
Normal file
@ -0,0 +1,76 @@
|
||||
{
|
||||
"widgettype":"VBox",
|
||||
"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_llms_by_catelog(cate.id) %}
|
||||
{
|
||||
"widgettype":"VBox",
|
||||
"options":{
|
||||
"cwidth":16,
|
||||
"cheight":8
|
||||
},
|
||||
"subwidgets":[
|
||||
{
|
||||
"widgettype":"Title5",
|
||||
"options":{"text":"{{llm.name}}"
|
||||
},
|
||||
{
|
||||
"widgettype":"Text",
|
||||
"options":{
|
||||
"text":"{{llm.description}}",
|
||||
"wrap":true,
|
||||
"halign":"left"
|
||||
}
|
||||
}
|
||||
],
|
||||
"binds":[
|
||||
{
|
||||
"wid":"self",
|
||||
"event":"click",
|
||||
"actiontype":"urlwidget",
|
||||
"target":"PopupWindow",
|
||||
"popup_options":{
|
||||
"width":"90%",
|
||||
"height":"90%"
|
||||
},
|
||||
"options":{
|
||||
"params":{
|
||||
"id":"{{llm.id}}"
|
||||
},
|
||||
"url":"{{entire_url('./llminference.dspy')}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
{% if not loop.last %}, {% endif %}
|
||||
{% endfor %}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
{% endfor %}
|
||||
]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user