bugfix
This commit is contained in:
parent
955b3d0d65
commit
fe93d69c54
@ -209,57 +209,3 @@ async def llm_query_price(llmid, config_data):
|
|||||||
prices = await env.pricing_program_charging(sor, llm.ppid, config_data)
|
prices = await env.pricing_program_charging(sor, llm.ppid, config_data)
|
||||||
return prices
|
return prices
|
||||||
|
|
||||||
async def add_new_llmusage_output(luid, rzt):
|
|
||||||
env = ServerEnv()
|
|
||||||
async with get_sor_context(env, 'llmage') as sor:
|
|
||||||
recs = await sor.R('llmusage', {'id': luid})
|
|
||||||
if recs:
|
|
||||||
r = recs[0]
|
|
||||||
io = json.loads(r.ioinfo)
|
|
||||||
out = io.get('output', [])
|
|
||||||
out.append(out)
|
|
||||||
io['output'] = out
|
|
||||||
r.ioinfo = json.dumps({
|
|
||||||
'input': io.get('input',{}),
|
|
||||||
'output': out
|
|
||||||
})
|
|
||||||
await sor.U('llmusage', r)
|
|
||||||
return
|
|
||||||
|
|
||||||
async def query_task_status(request, upappid, apinames, luid, userid, taskid):
|
|
||||||
async with get_sor_context(env, 'llmage') as sor:
|
|
||||||
uapi = UAPI(request, sor)
|
|
||||||
for apiname in apinames:
|
|
||||||
try:
|
|
||||||
ns = {'taskid': taskid}
|
|
||||||
b = await uapi.call(upappid, apiname, userid, params=ns)
|
|
||||||
if isinstance(b, bytes):
|
|
||||||
b = b.decode('utf-8')
|
|
||||||
d = json.loads(b)
|
|
||||||
rzt = DictObject(**d)
|
|
||||||
await add_new_llmusage_output(luid, rzt)
|
|
||||||
if rzt.status == 'FAILED':
|
|
||||||
return
|
|
||||||
if rzt.status == 'SUCCEEDED':
|
|
||||||
if llm.ppid:
|
|
||||||
try:
|
|
||||||
chargings = await llm_charging(sor,
|
|
||||||
llm.ppid, callerid, usage)
|
|
||||||
llmusage.amount = chargings.amount
|
|
||||||
llmusage.cost = chargings.cost
|
|
||||||
except Exception as e:
|
|
||||||
e = Exception(f'{llm.pid} charging error{e}')
|
|
||||||
exception(f'{e}')
|
|
||||||
else:
|
|
||||||
llmusage.amount = 0
|
|
||||||
llmusage.cost = 0
|
|
||||||
await llm_accounting(request, llmusage)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
exception(f'{e=},{format_exc()}')
|
|
||||||
estr = erase_apikey(e)
|
|
||||||
recs = sor.R('llmusage', {'id': luid})
|
|
||||||
ed = {"error": f"ERROR:{estr}", "status": "FAILED", 'taskid': taskid}
|
|
||||||
await add_new_llmusage_output(luid, ed)
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user