59 lines
1.3 KiB
Python
59 lines
1.3 KiB
Python
from ahserver.serverenv import ServerEnv
|
|
from sqlor.dbpools import DBPools
|
|
from alisms import AliSMS
|
|
|
|
def PopError(title='Error', message='Error happened'):
|
|
return {
|
|
'widgettype':'Error',
|
|
'options':{
|
|
'title':title,
|
|
'timeout':4,
|
|
'message':message
|
|
}
|
|
}
|
|
|
|
def PopMessage(title='Error', message='Error happened'):
|
|
return {
|
|
'widgettype':'Message',
|
|
'options':{
|
|
'title':title,
|
|
'timeout':4,
|
|
'message':message
|
|
}
|
|
}
|
|
|
|
async def get_llm_types():
|
|
db = DBPools()
|
|
async with db.sqlorContext('sage') as sor:
|
|
ns = {
|
|
'order':'name'
|
|
}
|
|
recs = await sor.R('modeltype', ns)
|
|
return recs
|
|
return []
|
|
|
|
async def get_llminstances_by_modeltype(mtid):
|
|
db = DBPools()
|
|
userorgid = await get_userorgid()
|
|
async with db.sqlorContext('sage') as sor:
|
|
sql = """select a.* from modelinstance a, modelapi b
|
|
where
|
|
a.modelid = b.modelid and
|
|
a.orgid is null and
|
|
b.modeltypeid = ${mtid}$
|
|
order by a.name
|
|
"""
|
|
recs = await sor.sqlExe(sql, {'mtid':mtid, 'userorgid':userorgid})
|
|
return recs
|
|
return []
|
|
|
|
|
|
def set_globalvariable():
|
|
sms_engine = sms = AliSMS('LTAI5t5w7xsZgueod6uZ3TCD', 'n1HttSbQvgEbjvf62Gzl1aagfKyIyS')
|
|
g = ServerEnv()
|
|
g.sms_engine = sms_engine
|
|
g.PopError = PopError
|
|
g.PopMessage = PopMessage
|
|
g.get_llm_types = get_llm_types
|
|
g.get_llminstances_by_modeltype = get_llminstances_by_modeltype
|