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): Remove hardcoded auto-top-up config definition on set_auto_top_up (#9361)
Zamil Majdyc31a2ec56559
diff --git a/autogpt_platform/backend/backend/data/credit.py b/autogpt_platform/backend/backend/data/credit.pyindex dbde81eee9..b4953eed29 100644--- a/autogpt_platform/backend/backend/data/credit.py+++ b/autogpt_platform/backend/backend/data/credit.py@@ -517,10 +517,10 @@ async def get_stripe_customer_id(user_id: str) -> str:return customer.id-async def set_auto_top_up(user_id: str, threshold: int, amount: int):+async def set_auto_top_up(user_id: str, config: AutoTopUpConfig):await User.prisma().update(where={"id": user_id},- data={"topUpConfig": Json({"threshold": threshold, "amount": amount})},+ data={"topUpConfig": Json(config.model_dump())},)diff --git a/autogpt_platform/backend/backend/server/routers/v1.py b/autogpt_platform/backend/backend/server/routers/v1.pyindex 795c824902..39d16632b8 100644--- a/autogpt_platform/backend/backend/server/routers/v1.py+++ b/autogpt_platform/backend/backend/server/routers/v1.py@@ -183,7 +183,9 @@ async def configure_user_auto_top_up(else:await _user_credit_model.top_up_credits(user_id, 0)- await set_auto_top_up(user_id, threshold=request.threshold, amount=request.amount)+ await set_auto_top_up(+ user_id, AutoTopUpConfig(threshold=request.threshold, amount=request.amount)+ )return "Auto top-up settings updated"