bugfix
This commit is contained in:
parent
348867232d
commit
4db100cade
@ -29,12 +29,16 @@ where userid=${userid}$
|
|||||||
return recs
|
return recs
|
||||||
return []
|
return []
|
||||||
|
|
||||||
async def get_asynctask_status(taskid):
|
async def get_asynctask_status(request, taskid):
|
||||||
env = ServerEnv()
|
env = ServerEnv()
|
||||||
async with get_sor_context(env, 'llmage') as sor:
|
async with get_sor_context(env, 'llmage') as sor:
|
||||||
recs = await sor.R('llmusage', {'taskid': taskid})
|
recs = await sor.R('llmusage', {'taskid': taskid})
|
||||||
if recs:
|
if recs:
|
||||||
r = recs[0]
|
r = recs[0]
|
||||||
|
if r.status not in ['SUCCEEDED', 'FAILED']:
|
||||||
|
await query_task_status(request, r.id, onetime=True)
|
||||||
|
recs = await sor.R('llmusage', {'id': r.id})
|
||||||
|
r = recs[0]
|
||||||
output = await get_lastoutput(r.ioinfo)
|
output = await get_lastoutput(r.ioinfo)
|
||||||
return output
|
return output
|
||||||
return {
|
return {
|
||||||
@ -107,8 +111,7 @@ async def async_uapi_request(request, llm,
|
|||||||
if d.status == 'FAILED':
|
if d.status == 'FAILED':
|
||||||
e = Exception(f'resp={d} FFAILED')
|
e = Exception(f'resp={d} FFAILED')
|
||||||
return
|
return
|
||||||
asyncio.create_task(query_task_status(request, llm.upappid,
|
asyncio.create_task(query_task_status(request, luid))
|
||||||
llm.query_apiname, luid, userid, d.taskid))
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
ed = {"error": f"ERROR:{e}", "status": "FAILED"}
|
ed = {"error": f"ERROR:{e}", "status": "FAILED"}
|
||||||
@ -147,10 +150,14 @@ async def get_llm_llmusage(luid):
|
|||||||
llm = llms[0]
|
llm = llms[0]
|
||||||
return llm, llmusage
|
return llm, llmusage
|
||||||
|
|
||||||
async def query_task_status(request, upappid, apiname, luid, userid, taskid):
|
async def query_task_status(request, luid, onetime=False):
|
||||||
uapi = UpAppApi(request)
|
uapi = UpAppApi(request)
|
||||||
apinames = apiname.split(',')
|
|
||||||
llm, llmusage = await get_llm_llmusage(luid)
|
llm, llmusage = await get_llm_llmusage(luid)
|
||||||
|
env = ServerEnv()
|
||||||
|
userid = await env.uapi_data.get_calluserid(llm.upappid, orgid=llm.ownerid)
|
||||||
|
taskid = llmusage.taskid
|
||||||
|
upappid = llm.upappid
|
||||||
|
apinames = llm.query_apiname.split(',')
|
||||||
|
|
||||||
for apiname in apinames:
|
for apiname in apinames:
|
||||||
while True:
|
while True:
|
||||||
@ -179,6 +186,8 @@ async def query_task_status(request, upappid, apiname, luid, userid, taskid):
|
|||||||
dcritical(f'finished .. {llmusage.status=}')
|
dcritical(f'finished .. {llmusage.status=}')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if onetime:
|
||||||
|
critical(f'onetime is true, returned')
|
||||||
await asyncio.sleep(llm.query_period or 30)
|
await asyncio.sleep(llm.query_period or 30)
|
||||||
critical(f'{llm.query_period=} seconds will retry, {changed.status=}')
|
critical(f'{llm.query_period=} seconds will retry, {changed.status=}')
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ from .jimeng import jimeng_auth_headers
|
|||||||
from .utils import (
|
from .utils import (
|
||||||
llm_query_orders,
|
llm_query_orders,
|
||||||
read_webpath,
|
read_webpath,
|
||||||
|
get_owner_userid,
|
||||||
llm_query_price,
|
llm_query_price,
|
||||||
get_llm_by_model
|
get_llm_by_model
|
||||||
)
|
)
|
||||||
@ -30,7 +31,7 @@ from .accounting import (
|
|||||||
|
|
||||||
from .asyncinference import (
|
from .asyncinference import (
|
||||||
get_asynctask_status,
|
get_asynctask_status,
|
||||||
query_task_status,
|
query_task_status
|
||||||
get_today_asynctask_list
|
get_today_asynctask_list
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -60,6 +61,7 @@ def load_llmage():
|
|||||||
env.get_llms_sort_by_provider = get_llms_sort_by_provider
|
env.get_llms_sort_by_provider = get_llms_sort_by_provider
|
||||||
env.keling_token = keling_token
|
env.keling_token = keling_token
|
||||||
env.llm_query_price = llm_query_price
|
env.llm_query_price = llm_query_price
|
||||||
|
env.get_owner_userid = get_owner_userid
|
||||||
rf = RegisterFunction()
|
rf = RegisterFunction()
|
||||||
rf.register('jimeng_auth_headers', jimeng_auth_headers)
|
rf.register('jimeng_auth_headers', jimeng_auth_headers)
|
||||||
add_cleanupctx(start_backend)
|
add_cleanupctx(start_backend)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
taskid = params_kw.taskid
|
taskid = params_kw.taskid
|
||||||
s = await get_asynctask_status(taskid)
|
s = await get_asynctask_status(request, taskid)
|
||||||
return {
|
return {
|
||||||
'status': 'ok',
|
'status': 'ok',
|
||||||
'data': {
|
'data': {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user