bugfix
This commit is contained in:
parent
449e9db1f4
commit
6031efaa67
@ -57,21 +57,24 @@ async def tpac_accounting(apikey, userid, llmid, amount, usage):
|
|||||||
'amount': amount,
|
'amount': amount,
|
||||||
'usage': usage
|
'usage': usage
|
||||||
}
|
}
|
||||||
url = config.thirdparty_accounting_center.get_user_balance_url
|
|
||||||
hc = StreamHttpClient()
|
hc = StreamHttpClient()
|
||||||
|
status = 'failed'
|
||||||
try:
|
try:
|
||||||
b = hc.request('POST', url, data=d):
|
b = hc.request('POST', url, data=d):
|
||||||
d = json.loads(b.decode('utf-8'))
|
d = json.loads(b.decode('utf-8'))
|
||||||
if d['status'] == 'ok':
|
if d['status'] == 'ok':
|
||||||
env = ServerEnv()
|
status = 'accounted'
|
||||||
async with get_sor_context(env, 'llmage') as sor:
|
|
||||||
await sor.U('llmusage', {'id': llmid, 'tpac_accounting_status': 'accounted')
|
|
||||||
return
|
|
||||||
exception(f'{apikey=}, {userid=}, {llmid=}, {amount=}, {usage=} tpac accounting error')
|
exception(f'{apikey=}, {userid=}, {llmid=}, {amount=}, {usage=} tpac accounting error')
|
||||||
return
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exception(f'{apikey=}, {userid=}, {llmid=}, {amount=}, {usage=} tpac accounting error:{e}')
|
exception(f'{apikey=}, {userid=}, {llmid=}, {amount=}, {usage=} tpac accounting error:{e}')
|
||||||
|
env = ServerEnv()
|
||||||
|
async with get_sor_context(env, 'llmage') as sor:
|
||||||
|
await sor.U('llmusage', {
|
||||||
|
'id': llmid,
|
||||||
|
'accounting_status': status
|
||||||
|
})
|
||||||
return
|
return
|
||||||
|
exception(f'{apikey=}, {userid=}, {llmid=}, {amount=}, {usage=} tpac_accounting error:update llmusage error')
|
||||||
|
|
||||||
async def append_new_llmoutput(webpath, output):
|
async def append_new_llmoutput(webpath, output):
|
||||||
fs = FileStorage()
|
fs = FileStorage()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user