buggix
This commit is contained in:
parent
5cc249e691
commit
b7a9bd11c7
@ -287,32 +287,61 @@ class BufferedLLMs:
|
|||||||
"""
|
"""
|
||||||
cls.llms.clear()
|
cls.llms.clear()
|
||||||
debug('BufferedLLMs cache cleared')
|
debug('BufferedLLMs cache cleared')
|
||||||
async def get_llm(self, llmid):
|
async def get_llm(self, llmid, catelogid=None):
|
||||||
today = curDateString()
|
today = curDateString()
|
||||||
|
"""
|
||||||
|
暂时不要buffered
|
||||||
k = f'{llmid}.{today}'
|
k = f'{llmid}.{today}'
|
||||||
d = BufferedLLMs.llms.get(k)
|
d = BufferedLLMs.llms.get(k)
|
||||||
if d:
|
if d:
|
||||||
return d
|
return d
|
||||||
|
"""
|
||||||
env = ServerEnv()
|
env = ServerEnv()
|
||||||
async with get_sor_context(env, 'llmage') as sor:
|
async with get_sor_context(env, 'llmage') as sor:
|
||||||
sql = """select x.*,
|
sql = """select a.id,
|
||||||
z.input_fields
|
a.name,
|
||||||
from (
|
a.model,
|
||||||
select a.*, e.ioid, e.stream, e.callbackurl, f.input_fields as inputfields
|
a.providerid,
|
||||||
|
a.description,
|
||||||
|
a.iconid,
|
||||||
|
a.upappid,
|
||||||
|
a.ownerid,
|
||||||
|
a.min_balance,
|
||||||
|
m.llmcatelogid,
|
||||||
|
m.apiname,
|
||||||
|
m.query_apiname,
|
||||||
|
m.query_period,
|
||||||
|
m.ppid,
|
||||||
|
e.ioid,
|
||||||
|
e.stream,
|
||||||
|
e.callbackurl,
|
||||||
|
f.input_fields,
|
||||||
|
lc.name as catelogname
|
||||||
from llm a
|
from llm a
|
||||||
join llm_api_map m on a.id = m.llmid
|
,llm_api_map m
|
||||||
join upapp c on a.upappid = c.id
|
,llmcatelog lc
|
||||||
join uapi e on c.apisetid = e.apisetid and m.apiname = e.name
|
,upapp c on a.upappid = c.id
|
||||||
join uapiio f on e.ioid = f.id
|
,uapi e on c.apisetid = e.apisetid and m.apiname = e.name
|
||||||
where a.expired_date > ${today}$
|
,uapiio f on e.ioid = f.id
|
||||||
|
where a.id = m.llmid
|
||||||
|
and a.upappid = c.id
|
||||||
|
and c.apisetid = e.apisetid and m.apiname = e.name
|
||||||
|
and e.ioid = f.id
|
||||||
|
and a.id = ${llmid}$
|
||||||
|
and a.expired_date > ${today}$
|
||||||
and a.enabled_date <= ${today}$
|
and a.enabled_date <= ${today}$
|
||||||
) x left join uapiio z on x.ioid = z.id
|
|
||||||
where x.id = ${llmid}$
|
|
||||||
"""
|
"""
|
||||||
ns = {'llmid': llmid, 'today': today}
|
ns = {'llmid': llmid, 'today': today}
|
||||||
|
if catelogid:
|
||||||
|
sql += ' and m.llmcatelogid = ${catelogid}$ '
|
||||||
|
ns['catelogid'] = catelogid
|
||||||
|
else:
|
||||||
|
sql += ' and a.llmcatelogid = lc.id '
|
||||||
recs = await sor.sqlExe(sql, ns.copy())
|
recs = await sor.sqlExe(sql, ns.copy())
|
||||||
if len(recs) > 0:
|
if len(recs) > 0:
|
||||||
r = recs[0]
|
r = recs[0]
|
||||||
|
return r
|
||||||
|
# 暂时不buffer
|
||||||
dates = BufferedLLMs.llms.get(llmid, [])
|
dates = BufferedLLMs.llms.get(llmid, [])
|
||||||
dates.append(today)
|
dates.append(today)
|
||||||
cnt = len(dates)
|
cnt = len(dates)
|
||||||
@ -330,9 +359,9 @@ where x.id = ${llmid}$
|
|||||||
exception(f'Error: {format_exc()}')
|
exception(f'Error: {format_exc()}')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def get_llm(llmid):
|
async def get_llm(llmid, catelogid=None):
|
||||||
bllms = BufferedLLMs()
|
bllms = BufferedLLMs()
|
||||||
return await bllms.get_llm(llmid)
|
return await bllms.get_llm(llmid, catelogid=catelogid)
|
||||||
|
|
||||||
async def write_llmusage(llmusage):
|
async def write_llmusage(llmusage):
|
||||||
env = ServerEnv()
|
env = ServerEnv()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user