bugfix
This commit is contained in:
parent
4fa220b985
commit
081ac3a773
@ -1,9 +1,8 @@
|
|||||||
from ahserver.serverenv import ServerEnv
|
from ahserver.serverenv import ServerEnv
|
||||||
from appPublic.dictObject import DictObject
|
from appPublic.dictObject import DictObject
|
||||||
from sqlor.dbpools import get_sor_context
|
from sqlor.dbpools import get_sor_context
|
||||||
from .accounting import llm_charging, llm_accounting
|
|
||||||
|
|
||||||
async def asynctask_callbacka(appname, apiname, params_kw)
|
async def asynctask_callback(appname, apiname, params_kw)
|
||||||
env = ServerEnv()
|
env = ServerEnv()
|
||||||
llmusage = None
|
llmusage = None
|
||||||
async with get_sor_context(env, 'llmage') as sor:
|
async with get_sor_context(env, 'llmage') as sor:
|
||||||
@ -20,28 +19,9 @@ async def asynctask_callbacka(appname, apiname, params_kw)
|
|||||||
io = json.loads(llmusage.ioinfo)
|
io = json.loads(llmusage.ioinfo)
|
||||||
out = io.get('output')
|
out = io.get('output')
|
||||||
out.append(d)
|
out.append(d)
|
||||||
|
llmusage.ioinfo = json.dumps(io, ensure_ascii=False)
|
||||||
llmusage.status = d.status
|
llmusage.status = d.status
|
||||||
if d.status == 'SUCCEEDED':
|
await sor.U('llmusage', llmusage)
|
||||||
llms = await sor.R('llm', {'id': llmusage.llmid})
|
|
||||||
if len(llms) == 0:
|
|
||||||
e = Exception(f'{llmusage.llmid} llm not found')
|
|
||||||
exception(f'{e}')
|
|
||||||
raise e
|
|
||||||
llm = llms[0]
|
|
||||||
if llm.ppid:
|
|
||||||
try:
|
|
||||||
chargings = await llm_charging(sor, llm.ppid,
|
|
||||||
llmusage.userid, d.usage)
|
|
||||||
llmusage.amount = chargings.amount
|
|
||||||
llmusage.cost = chargings.cost
|
|
||||||
except Exception as e:
|
|
||||||
e = Exception(f'{llm.pid} charging error{e}')
|
|
||||||
exception(f'{e}')
|
|
||||||
else:
|
|
||||||
llmusage.amount = 0
|
|
||||||
llmusage.cost = 0
|
|
||||||
sor.U('llmusage', llmusage)
|
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
e = Exception(f'{uapi.response=}, {params_kw=} render error')
|
e = Exception(f'{uapi.response=}, {params_kw=} render error')
|
||||||
@ -51,4 +31,3 @@ async def asynctask_callbacka(appname, apiname, params_kw)
|
|||||||
if llmusage:
|
if llmusage:
|
||||||
await llm_accounting(llmusage)
|
await llm_accounting(llmusage)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user