This commit is contained in:
yumoqing 2026-03-30 14:59:57 +08:00
parent 151440964f
commit 955b3d0d65

View File

@ -152,6 +152,12 @@ async def query_task_status(request, upappid, apiname, luid, userid, taskid):
exception(f'{e}') exception(f'{e}')
raise e raise e
llmusage = recs[0] llmusage = recs[0]
llms = await sor.R('llm', {'id': llmusage.llmid})
if len(llms) == 0:
e = Exception(f'{llmusage.llmid=} not found in llm')
exception(f'{e}')
raise e
llm = llms[0]
lastoutout = get_llmusage_last_output(llmusage) lastoutout = get_llmusage_last_output(llmusage)
if lastoutout and lastoutout.status == 'SUCCEEDED': if lastoutout and lastoutout.status == 'SUCCEEDED':
return return
@ -182,12 +188,6 @@ async def query_task_status(request, upappid, apiname, luid, userid, taskid):
return return
if changed.status == 'SUCCEEDED': if changed.status == 'SUCCEEDED':
llmusage.usage = changed.output.usage llmusage.usage = changed.output.usage
llms = await sor.R('llm', {'id': llmusage.llmid})
if len(llms) == 0:
e = Exception(f'{llmusage.llmid=} not found in llm')
exception(f'{e}')
raise e
llm = llms[0]
if llm.ppid: if llm.ppid:
try: try:
charging = await llm_charging(sor, charging = await llm_charging(sor,
@ -210,5 +210,6 @@ async def query_task_status(request, upappid, apiname, luid, userid, taskid):
debug(f'{changed=} accounted ') debug(f'{changed=} accounted ')
if changed.status in ['FAILED', 'SUCCEEDED']: if changed.status in ['FAILED', 'SUCCEEDED']:
return return
await asyncio.sleep(0.1) await asyncio.sleep(llm.query_period or 30)
debug(f'{llm.query_period=} seconds will retry, {changed.status=}')