Compare commits

...

2 Commits

Author SHA1 Message Date
28af0c1e37 bugfix 2026-03-29 20:12:11 +08:00
f52a0e824c bugfix 2026-03-29 20:07:12 +08:00
4 changed files with 18 additions and 9 deletions

View File

@ -147,10 +147,13 @@ async def query_task_status(request, upappid, apinames, luid, userid, taskid):
if rzt.status == 'SUCCEEDED':
if llm.ppid:
try:
chargings = await llm_charging(sor,
charging = await llm_charging(sor,
llm.ppid, llmusage)
llmusage.amount = chargings.amount
llmusage.cost = chargings.cost
if charging:
llmusage.amount = charging.amount
llmusage.cost = charging.cost
else:
llmusage.amount = cost = 0.0
except Exception as e:
e = Exception(f'{llm.pid} charging error{e}')
exception(f'{e}')

View File

@ -97,8 +97,11 @@ async def uapi_request(request, llm, sor, callerid, callerorgid, params_kw=None)
if llm.ppid and callerorgid:
try:
chargings = await llm_charging(sor, llm.ppid, llmusage)
if chargings:
llmusage.amount = chargings.amount
llmusage.cost = chargings.cost
else:
llmusage.amount = llmusage.cost = 0.00
except Exception as e:
e = Exception(f'{llm.pid} charging error{e}')
exception(f'{e}')

View File

@ -59,9 +59,12 @@ async def sync_uapi_request(request, llm, sor, callerid, callerorgid, params_kw=
llmusage.status = 'SUCCEEDED'
if llm.ppid:
try:
chargings = await llm_charging(sor, llm.ppid, llmusage)
llmusage.amount = chargings.amount
llmusage.cost = chargings.cost
charging = await llm_charging(sor, llm.ppid, llmusage)
if charging:
llmusage.amount = charging.amount
llmusage.cost = charging.cost
else:
llmusage.amount = llmusage.cost = 0.0
except Exception as e:
e = Exception(f'{llm.pid} charging error{e}')
exception(f'{e}')

View File

@ -149,5 +149,5 @@ where a.upappid=b.id
async def write_llmusage(llmusage):
env = ServerEnv()
async with get_sor_context(env, 'llmage') as sor:
await sor.C('llmusage', d)
await sor.C('llmusage', llmusage)