mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-21 04:57:58 -05:00
Compare commits
1 Commits
testing-cl
...
hotfix/pat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94bbfe12fb |
@@ -52,10 +52,34 @@ async def get_user_onboarding(user_id: str):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def reset_user_onboarding(user_id: str):
|
||||||
|
return await UserOnboarding.prisma().upsert(
|
||||||
|
where={"userId": user_id},
|
||||||
|
data={
|
||||||
|
"create": UserOnboardingCreateInput(userId=user_id),
|
||||||
|
"update": {
|
||||||
|
"completedSteps": [],
|
||||||
|
"walletShown": False,
|
||||||
|
"notified": [],
|
||||||
|
"usageReason": None,
|
||||||
|
"integrations": [],
|
||||||
|
"otherIntegrations": None,
|
||||||
|
"selectedStoreListingVersionId": None,
|
||||||
|
"agentInput": prisma.Json({}),
|
||||||
|
"onboardingAgentExecutionId": None,
|
||||||
|
"agentRuns": 0,
|
||||||
|
"lastRunAt": None,
|
||||||
|
"consecutiveRunDays": 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def update_user_onboarding(user_id: str, data: UserOnboardingUpdate):
|
async def update_user_onboarding(user_id: str, data: UserOnboardingUpdate):
|
||||||
update: UserOnboardingUpdateInput = {}
|
update: UserOnboardingUpdateInput = {}
|
||||||
|
onboarding = await get_user_onboarding(user_id)
|
||||||
if data.completedSteps is not None:
|
if data.completedSteps is not None:
|
||||||
update["completedSteps"] = list(set(data.completedSteps))
|
update["completedSteps"] = list(set(data.completedSteps + onboarding.completedSteps))
|
||||||
for step in (
|
for step in (
|
||||||
OnboardingStep.AGENT_NEW_RUN,
|
OnboardingStep.AGENT_NEW_RUN,
|
||||||
OnboardingStep.MARKETPLACE_VISIT,
|
OnboardingStep.MARKETPLACE_VISIT,
|
||||||
@@ -71,11 +95,11 @@ async def update_user_onboarding(user_id: str, data: UserOnboardingUpdate):
|
|||||||
OnboardingStep.RUN_AGENTS_100,
|
OnboardingStep.RUN_AGENTS_100,
|
||||||
):
|
):
|
||||||
if step in data.completedSteps:
|
if step in data.completedSteps:
|
||||||
await reward_user(user_id, step)
|
await reward_user(user_id, step, onboarding)
|
||||||
if data.walletShown is not None:
|
if data.walletShown == True:
|
||||||
update["walletShown"] = data.walletShown
|
update["walletShown"] = data.walletShown
|
||||||
if data.notified is not None:
|
if data.notified is not None:
|
||||||
update["notified"] = list(set(data.notified))
|
update["notified"] = list(set(data.notified + onboarding.notified))
|
||||||
if data.usageReason is not None:
|
if data.usageReason is not None:
|
||||||
update["usageReason"] = data.usageReason
|
update["usageReason"] = data.usageReason
|
||||||
if data.integrations is not None:
|
if data.integrations is not None:
|
||||||
@@ -88,7 +112,7 @@ async def update_user_onboarding(user_id: str, data: UserOnboardingUpdate):
|
|||||||
update["agentInput"] = SafeJson(data.agentInput)
|
update["agentInput"] = SafeJson(data.agentInput)
|
||||||
if data.onboardingAgentExecutionId is not None:
|
if data.onboardingAgentExecutionId is not None:
|
||||||
update["onboardingAgentExecutionId"] = data.onboardingAgentExecutionId
|
update["onboardingAgentExecutionId"] = data.onboardingAgentExecutionId
|
||||||
if data.agentRuns is not None:
|
if data.agentRuns is not None and data.agentRuns > onboarding.agentRuns:
|
||||||
update["agentRuns"] = data.agentRuns
|
update["agentRuns"] = data.agentRuns
|
||||||
if data.lastRunAt is not None:
|
if data.lastRunAt is not None:
|
||||||
update["lastRunAt"] = data.lastRunAt
|
update["lastRunAt"] = data.lastRunAt
|
||||||
@@ -104,7 +128,7 @@ async def update_user_onboarding(user_id: str, data: UserOnboardingUpdate):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def reward_user(user_id: str, step: OnboardingStep):
|
async def reward_user(user_id: str, step: OnboardingStep, onboarding: UserOnboarding):
|
||||||
reward = 0
|
reward = 0
|
||||||
match step:
|
match step:
|
||||||
# Reward user when they clicked New Run during onboarding
|
# Reward user when they clicked New Run during onboarding
|
||||||
@@ -138,8 +162,6 @@ async def reward_user(user_id: str, step: OnboardingStep):
|
|||||||
if reward == 0:
|
if reward == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
onboarding = await get_user_onboarding(user_id)
|
|
||||||
|
|
||||||
# Skip if already rewarded
|
# Skip if already rewarded
|
||||||
if step in onboarding.rewardedFor:
|
if step in onboarding.rewardedFor:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ from backend.data.onboarding import (
|
|||||||
get_recommended_agents,
|
get_recommended_agents,
|
||||||
get_user_onboarding,
|
get_user_onboarding,
|
||||||
onboarding_enabled,
|
onboarding_enabled,
|
||||||
|
reset_user_onboarding,
|
||||||
update_user_onboarding,
|
update_user_onboarding,
|
||||||
)
|
)
|
||||||
from backend.data.user import (
|
from backend.data.user import (
|
||||||
@@ -259,6 +260,16 @@ async def is_onboarding_enabled():
|
|||||||
return await onboarding_enabled()
|
return await onboarding_enabled()
|
||||||
|
|
||||||
|
|
||||||
|
@v1_router.post(
|
||||||
|
"/onboarding/reset",
|
||||||
|
summary="Reset onboarding progress",
|
||||||
|
tags=["onboarding"],
|
||||||
|
dependencies=[Security(requires_user)],
|
||||||
|
)
|
||||||
|
async def reset_onboarding(user_id: Annotated[str, Security(get_user_id)]):
|
||||||
|
return await reset_user_onboarding(user_id)
|
||||||
|
|
||||||
|
|
||||||
########################################################
|
########################################################
|
||||||
##################### Blocks ###########################
|
##################### Blocks ###########################
|
||||||
########################################################
|
########################################################
|
||||||
|
|||||||
@@ -1,18 +1,7 @@
|
|||||||
import BackendAPI from "@/lib/autogpt-server-api";
|
import { postV1ResetOnboardingProgress } from "@/app/api/__generated__/endpoints/onboarding/onboarding";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export default async function OnboardingResetPage() {
|
export default async function OnboardingResetPage() {
|
||||||
const api = new BackendAPI();
|
await postV1ResetOnboardingProgress();
|
||||||
await api.updateUserOnboarding({
|
|
||||||
completedSteps: [],
|
|
||||||
walletShown: false,
|
|
||||||
notified: [],
|
|
||||||
usageReason: null,
|
|
||||||
integrations: [],
|
|
||||||
otherIntegrations: "",
|
|
||||||
selectedStoreListingVersionId: null,
|
|
||||||
agentInput: {},
|
|
||||||
onboardingAgentExecutionId: null,
|
|
||||||
});
|
|
||||||
redirect("/onboarding/1-welcome");
|
redirect("/onboarding/1-welcome");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -906,6 +906,23 @@
|
|||||||
"security": [{ "HTTPBearerJWT": [] }]
|
"security": [{ "HTTPBearerJWT": [] }]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/api/onboarding/reset": {
|
||||||
|
"post": {
|
||||||
|
"tags": ["v1", "onboarding"],
|
||||||
|
"summary": "Reset onboarding progress",
|
||||||
|
"operationId": "postV1Reset onboarding progress",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Successful Response",
|
||||||
|
"content": { "application/json": { "schema": {} } }
|
||||||
|
},
|
||||||
|
"401": {
|
||||||
|
"$ref": "#/components/responses/HTTP401NotAuthenticatedError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [{ "HTTPBearerJWT": [] }]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/api/blocks": {
|
"/api/blocks": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": ["v1", "blocks"],
|
"tags": ["v1", "blocks"],
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ export function getRunMilestoneSteps(
|
|||||||
): OnboardingStep[] {
|
): OnboardingStep[] {
|
||||||
const steps: OnboardingStep[] = [];
|
const steps: OnboardingStep[] = [];
|
||||||
|
|
||||||
if (newRunCount === 10) steps.push("RUN_AGENTS");
|
if (newRunCount >= 10) steps.push("RUN_AGENTS");
|
||||||
if (newRunCount === 100) steps.push("RUN_AGENTS_100");
|
if (newRunCount >= 100) steps.push("RUN_AGENTS_100");
|
||||||
if (consecutiveDays === 3) steps.push("RUN_3_DAYS");
|
if (consecutiveDays >= 3) steps.push("RUN_3_DAYS");
|
||||||
if (consecutiveDays === 14) steps.push("RUN_14_DAYS");
|
if (consecutiveDays >= 14) steps.push("RUN_14_DAYS");
|
||||||
|
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,9 @@ export default function OnboardingProvider({
|
|||||||
|
|
||||||
updateState({
|
updateState({
|
||||||
agentRuns: newRunCount,
|
agentRuns: newRunCount,
|
||||||
completedSteps: [...state.completedSteps, ...milestoneSteps],
|
completedSteps: Array.from(
|
||||||
|
new Set([...state.completedSteps, ...milestoneSteps]),
|
||||||
|
),
|
||||||
...consecutiveData,
|
...consecutiveData,
|
||||||
});
|
});
|
||||||
}, [state, updateState]);
|
}, [state, updateState]);
|
||||||
|
|||||||
Reference in New Issue
Block a user