feat: integrate Redis balance finalize_balance after consume_accounting
This commit is contained in:
parent
327f77dac1
commit
86057eaa3b
@ -1527,6 +1527,15 @@ WHERE resource_ref_id = ${llm_id}$ AND product_type = 'llm_model' LIMIT 1"""
|
|||||||
await sor.C('biz_orderdetail', orderdetail)
|
await sor.C('biz_orderdetail', orderdetail)
|
||||||
await consume_accounting(sor, orderid, accounting_items)
|
await consume_accounting(sor, orderid, accounting_items)
|
||||||
|
|
||||||
|
# Finalize Redis balance reservation (non-critical)
|
||||||
|
try:
|
||||||
|
luid = getattr(llmusage, 'id', None)
|
||||||
|
if luid:
|
||||||
|
from llmage.balance import finalize_balance
|
||||||
|
await finalize_balance(ServerEnv(), luid, customer_amount)
|
||||||
|
except Exception as e:
|
||||||
|
exception(f'finalize_balance failed (non-critical): {e}')
|
||||||
|
|
||||||
# Mark llmusage as accounted
|
# Mark llmusage as accounted
|
||||||
lmage_dbname = ServerEnv().get_module_dbname('llmage')
|
lmage_dbname = ServerEnv().get_module_dbname('llmage')
|
||||||
async with db.sqlorContext(lmage_dbname) as sor:
|
async with db.sqlorContext(lmage_dbname) as sor:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user