fix(backend): update from dev

This commit is contained in:
Nicholas Tindle
2025-02-06 13:15:37 -06:00
parent bad8e6d152
commit 114c0e4e3f

View File

@@ -204,7 +204,7 @@ def execute_node(
# Charge the user for the execution before running the block.
# TODO: We assume the block is executed within 0 seconds.
# This is fine because for now, there is no block that is charged by time.
db_client.spend_credits(data, input_size + output_size, 0)
cost = db_client.spend_credits(data, input_size + output_size, 0)
for output_name, output_data in node_block.execute(
input_data, **extra_exec_kwargs
@@ -225,23 +225,15 @@ def execute_node(
yield execution
# Update execution status and spend credits
res = update_execution(ExecutionStatus.COMPLETED)
s = input_size + output_size
t = (
(res.end_time - res.start_time).total_seconds()
if res.end_time and res.start_time
else 0
)
data.data = input_data
db_client.spend_credits(data, s, t)
update_execution(ExecutionStatus.COMPLETED)
notification_service.queue_notification(
create_notification(
user_id=user_id,
type=NotificationType.AGENT_RUN,
data=AgentRunData(
agent_name=node_block.name,
credits_used=s,
execution_time=t,
credits_used=cost,
execution_time=0,
graph_id=graph_id,
node_count=1,
),