mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(backend): update from dev
This commit is contained in:
@@ -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,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user