Compare commits

..

No commits in common. "28af0c1e37d60314815930a97ffddfb45350b119" and "afa77f9d4384b118ca845f7644318e73de46dddf" have entirely different histories.

4 changed files with 9 additions and 18 deletions

View File

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

View File

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

View File

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

View File

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