AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(backend): Add the lower cap of the user credits to zero (#8682)
Zamil Majdy6fa4b8cb1140
diff --git a/autogpt_platform/backend/backend/server/routers/v1.py b/autogpt_platform/backend/backend/server/routers/v1.pyindex 069c80b569..a59b9322b4 100644--- a/autogpt_platform/backend/backend/server/routers/v1.py+++ b/autogpt_platform/backend/backend/server/routers/v1.py@@ -124,7 +124,8 @@ def execute_graph_block(block_id: str, data: BlockInput) -> CompletedBlockOutputasync def get_user_credits(user_id: Annotated[str, Depends(get_user_id)]) -> dict[str, int]:- return {"credits": await _user_credit_model.get_or_refill_credit(user_id)}+ # Credits can go negative, so ensure it's at least 0 for user to see.+ return {"credits": max(await _user_credit_model.get_or_refill_credit(user_id), 0)}########################################################