bugfix
This commit is contained in:
parent
e6129764f5
commit
3c3b4eec93
@ -123,4 +123,6 @@ async def llm_accounting(request, llmusage):
|
|||||||
}
|
}
|
||||||
ais.append(ai1)
|
ais.append(ai1)
|
||||||
await consume_accounting(sor, orderid, ais)
|
await consume_accounting(sor, orderid, ais)
|
||||||
|
llmusage.accounting_status = 'accounted'
|
||||||
|
await sor.U('llmusage', llmusage)
|
||||||
|
|
||||||
|
|||||||
@ -117,20 +117,22 @@ async def async_uapi_request(request, llm, sor,
|
|||||||
yield f'{s}\n'
|
yield f'{s}\n'
|
||||||
return
|
return
|
||||||
|
|
||||||
async def add_new_llmusage_output(luid, rzt):
|
async def add_new_llmusage_output(luid, newd):
|
||||||
env = ServerEnv()
|
env = ServerEnv()
|
||||||
|
newd = newd.copy()
|
||||||
async with get_sor_context(env, 'llmage') as sor:
|
async with get_sor_context(env, 'llmage') as sor:
|
||||||
recs = await sor.R('llmusage', {'id': luid})
|
recs = await sor.R('llmusage', {'id': luid})
|
||||||
if recs:
|
if recs:
|
||||||
r = recs[0]
|
r = recs[0]
|
||||||
io = json.loads(r.ioinfo)
|
io = json.loads(r.ioinfo)
|
||||||
out = io.get('output', [])
|
out = io.get('output', [])
|
||||||
out.append(rzt)
|
rzt = newd.get('output')
|
||||||
|
if rzt:
|
||||||
|
out.append(rzt)
|
||||||
|
newd = {k:v for k,v in newd.items() if k != 'output'}
|
||||||
io['output'] = out
|
io['output'] = out
|
||||||
r.ioinfo = json.dumps({
|
r.ioinfo = json.dumps(io)
|
||||||
'input': io.get('input',{}),
|
r.update(newd)
|
||||||
'output': out
|
|
||||||
})
|
|
||||||
await sor.U('llmusage', r)
|
await sor.U('llmusage', r)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -183,7 +185,8 @@ async def query_task_status(request, upappid, apiname, luid, userid, taskid):
|
|||||||
else:
|
else:
|
||||||
changed.amount = 0
|
changed.amount = 0
|
||||||
changed.cost = 0
|
changed.cost = 0
|
||||||
await add_new_llmusage_output(luid, changed)
|
await add_new_llmusage_output(luid, changed)
|
||||||
|
if llmusage.accounting_status != 'accounted':
|
||||||
await llm_accounting(request, llmusage)
|
await llm_accounting(request, llmusage)
|
||||||
status = rzt.status
|
status = rzt.status
|
||||||
if rzt.status == 'FAILED':
|
if rzt.status == 'FAILED':
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user