mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
Merge branch 'dev' into ci-chromatic
This commit is contained in:
@@ -399,16 +399,12 @@ class UserCredit(UserCreditBase):
|
||||
f"Top up amount must be at least 500 credits and multiple of 100 but is {amount}"
|
||||
)
|
||||
|
||||
if not (user := await get_user_by_id(user_id)):
|
||||
raise ValueError(f"User not found: {user_id}")
|
||||
|
||||
# Create checkout session
|
||||
# https://docs.stripe.com/checkout/quickstart?client=react
|
||||
# unit_amount param is always in the smallest currency unit (so cents for usd)
|
||||
# which is equal to amount of credits
|
||||
checkout_session = stripe.checkout.Session.create(
|
||||
customer=await get_stripe_customer_id(user_id),
|
||||
customer_email=user.email,
|
||||
line_items=[
|
||||
{
|
||||
"price_data": {
|
||||
@@ -422,13 +418,13 @@ class UserCredit(UserCreditBase):
|
||||
}
|
||||
],
|
||||
mode="payment",
|
||||
ui_mode="hosted",
|
||||
payment_intent_data={"setup_future_usage": "off_session"},
|
||||
saved_payment_method_options={"payment_method_save": "enabled"},
|
||||
success_url=settings.config.platform_base_url
|
||||
success_url=settings.config.frontend_base_url
|
||||
+ "/marketplace/credits?topup=success",
|
||||
cancel_url=settings.config.platform_base_url
|
||||
cancel_url=settings.config.frontend_base_url
|
||||
+ "/marketplace/credits?topup=cancel",
|
||||
return_url=settings.config.platform_base_url + "/marketplace/credits",
|
||||
)
|
||||
|
||||
await self._add_transaction(
|
||||
@@ -602,8 +598,6 @@ def get_block_costs() -> dict[str, list[BlockCost]]:
|
||||
|
||||
async def get_stripe_customer_id(user_id: str) -> str:
|
||||
user = await get_user_by_id(user_id)
|
||||
if not user:
|
||||
raise ValueError(f"User not found: {user_id}")
|
||||
|
||||
if user.stripeCustomerId:
|
||||
return user.stripeCustomerId
|
||||
@@ -624,8 +618,6 @@ async def set_auto_top_up(user_id: str, config: AutoTopUpConfig):
|
||||
|
||||
async def get_auto_top_up(user_id: str) -> AutoTopUpConfig:
|
||||
user = await get_user_by_id(user_id)
|
||||
if not user:
|
||||
raise ValueError("Invalid user ID")
|
||||
|
||||
if not user.topUpConfig:
|
||||
return AutoTopUpConfig(threshold=0, amount=0)
|
||||
|
||||
@@ -34,9 +34,11 @@ async def get_or_create_user(user_data: dict) -> User:
|
||||
return User.model_validate(user)
|
||||
|
||||
|
||||
async def get_user_by_id(user_id: str) -> Optional[User]:
|
||||
async def get_user_by_id(user_id: str) -> User:
|
||||
user = await prisma.user.find_unique(where={"id": user_id})
|
||||
return User.model_validate(user) if user else None
|
||||
if not user:
|
||||
raise ValueError(f"User not found with ID: {user_id}")
|
||||
return User.model_validate(user)
|
||||
|
||||
|
||||
async def create_default_user() -> Optional[User]:
|
||||
|
||||
@@ -203,6 +203,9 @@ export default function CreditsPage() {
|
||||
executions are happening.
|
||||
</p>
|
||||
<br />
|
||||
{transactionHistory.transactions.length === 0 && (
|
||||
<p className="text-neutral-600">No transactions found.</p>
|
||||
)}
|
||||
<Table
|
||||
className={
|
||||
transactionHistory.transactions.length === 0 ? "hidden" : ""
|
||||
|
||||
@@ -25,10 +25,10 @@ export async function signup(values: z.infer<typeof signupFormSchema>) {
|
||||
console.error("Error signing up", error);
|
||||
// FIXME: supabase doesn't return the correct error message for this case
|
||||
if (error.message.includes("P0001")) {
|
||||
return "Please join our waitlist for your turn: https://agpt.co/waitlist";
|
||||
return "not_allowed";
|
||||
}
|
||||
if (error.code?.includes("user_already_exists")) {
|
||||
redirect("/login");
|
||||
if (error.code === "user_already_exists") {
|
||||
return "user_already_exists";
|
||||
}
|
||||
return error.message;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ export default function SignupPage() {
|
||||
const [feedback, setFeedback] = useState<string | null>(null);
|
||||
const router = useRouter();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
//TODO: Remove after closed beta
|
||||
const [showWaitlistPrompt, setShowWaitlistPrompt] = useState(false);
|
||||
|
||||
const form = useForm<z.infer<typeof signupFormSchema>>({
|
||||
@@ -58,10 +59,16 @@ export default function SignupPage() {
|
||||
const error = await signup(data);
|
||||
setIsLoading(false);
|
||||
if (error) {
|
||||
setShowWaitlistPrompt(true);
|
||||
if (error === "user_already_exists") {
|
||||
setFeedback("User with this email already exists");
|
||||
return;
|
||||
} else {
|
||||
setShowWaitlistPrompt(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
setFeedback(null);
|
||||
setShowWaitlistPrompt(false);
|
||||
},
|
||||
[form],
|
||||
);
|
||||
|
||||
@@ -662,6 +662,20 @@ export const NodeGenericInputField: FC<{
|
||||
handleInputClick={handleInputClick}
|
||||
/>
|
||||
);
|
||||
case "object":
|
||||
return (
|
||||
<NodeKeyValueInput
|
||||
nodeId={nodeId}
|
||||
selfKey={propKey}
|
||||
schema={propSchema}
|
||||
entries={currentValue}
|
||||
errors={errors}
|
||||
className={className}
|
||||
displayName={displayName}
|
||||
connections={connections}
|
||||
handleInputChange={handleInputChange}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
console.warn(
|
||||
`Schema for '${propKey}' specifies unknown type:`,
|
||||
|
||||
@@ -70,7 +70,7 @@ export type BlockIOObjectSubSchema = BlockIOSubSchemaMeta & {
|
||||
|
||||
export type BlockIOKVSubSchema = BlockIOSubSchemaMeta & {
|
||||
type: "object";
|
||||
additionalProperties: { type: "string" | "number" | "integer" };
|
||||
additionalProperties?: { type: "string" | "number" | "integer" };
|
||||
default?: { [key: string]: string | number };
|
||||
secret?: boolean;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user