mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-09 15:17:59 -05:00
Merge branch 'master' into dev
This commit is contained in:
@@ -1778,6 +1778,7 @@ class AIListGeneratorBlock(AIBlockBase):
|
||||
|```
|
||||
|
||||
|Do not include any explanations or additional text, just respond with the list in the format specified above.
|
||||
|Do not include code fences or any other formatting, just the raw list.
|
||||
"""
|
||||
# If a focus is provided, add it to the prompt
|
||||
if input_data.focus:
|
||||
|
||||
@@ -52,10 +52,36 @@ 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):
|
||||
update: UserOnboardingUpdateInput = {}
|
||||
onboarding = await get_user_onboarding(user_id)
|
||||
if data.completedSteps is not None:
|
||||
update["completedSteps"] = list(set(data.completedSteps))
|
||||
update["completedSteps"] = list(
|
||||
set(data.completedSteps + onboarding.completedSteps)
|
||||
)
|
||||
for step in (
|
||||
OnboardingStep.AGENT_NEW_RUN,
|
||||
OnboardingStep.MARKETPLACE_VISIT,
|
||||
@@ -71,11 +97,11 @@ async def update_user_onboarding(user_id: str, data: UserOnboardingUpdate):
|
||||
OnboardingStep.RUN_AGENTS_100,
|
||||
):
|
||||
if step in data.completedSteps:
|
||||
await reward_user(user_id, step)
|
||||
if data.walletShown is not None:
|
||||
await reward_user(user_id, step, onboarding)
|
||||
if data.walletShown:
|
||||
update["walletShown"] = data.walletShown
|
||||
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:
|
||||
update["usageReason"] = data.usageReason
|
||||
if data.integrations is not None:
|
||||
@@ -88,7 +114,7 @@ async def update_user_onboarding(user_id: str, data: UserOnboardingUpdate):
|
||||
update["agentInput"] = SafeJson(data.agentInput)
|
||||
if data.onboardingAgentExecutionId is not None:
|
||||
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
|
||||
if data.lastRunAt is not None:
|
||||
update["lastRunAt"] = data.lastRunAt
|
||||
@@ -104,7 +130,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
|
||||
match step:
|
||||
# Reward user when they clicked New Run during onboarding
|
||||
@@ -138,8 +164,6 @@ async def reward_user(user_id: str, step: OnboardingStep):
|
||||
if reward == 0:
|
||||
return
|
||||
|
||||
onboarding = await get_user_onboarding(user_id)
|
||||
|
||||
# Skip if already rewarded
|
||||
if step in onboarding.rewardedFor:
|
||||
return
|
||||
|
||||
@@ -52,6 +52,7 @@ from backend.data.onboarding import (
|
||||
get_recommended_agents,
|
||||
get_user_onboarding,
|
||||
onboarding_enabled,
|
||||
reset_user_onboarding,
|
||||
update_user_onboarding,
|
||||
)
|
||||
from backend.data.user import (
|
||||
@@ -259,6 +260,16 @@ async def is_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 ###########################
|
||||
########################################################
|
||||
|
||||
@@ -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";
|
||||
|
||||
export default async function OnboardingResetPage() {
|
||||
const api = new BackendAPI();
|
||||
await api.updateUserOnboarding({
|
||||
completedSteps: [],
|
||||
walletShown: false,
|
||||
notified: [],
|
||||
usageReason: null,
|
||||
integrations: [],
|
||||
otherIntegrations: "",
|
||||
selectedStoreListingVersionId: null,
|
||||
agentInput: {},
|
||||
onboardingAgentExecutionId: null,
|
||||
});
|
||||
await postV1ResetOnboardingProgress();
|
||||
redirect("/onboarding/1-welcome");
|
||||
}
|
||||
|
||||
@@ -906,6 +906,23 @@
|
||||
"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": {
|
||||
"get": {
|
||||
"tags": ["v1", "blocks"],
|
||||
|
||||
@@ -52,10 +52,10 @@ export function getRunMilestoneSteps(
|
||||
): OnboardingStep[] {
|
||||
const steps: OnboardingStep[] = [];
|
||||
|
||||
if (newRunCount === 10) steps.push("RUN_AGENTS");
|
||||
if (newRunCount === 100) steps.push("RUN_AGENTS_100");
|
||||
if (consecutiveDays === 3) steps.push("RUN_3_DAYS");
|
||||
if (consecutiveDays === 14) steps.push("RUN_14_DAYS");
|
||||
if (newRunCount >= 10) steps.push("RUN_AGENTS");
|
||||
if (newRunCount >= 100) steps.push("RUN_AGENTS_100");
|
||||
if (consecutiveDays >= 3) steps.push("RUN_3_DAYS");
|
||||
if (consecutiveDays >= 14) steps.push("RUN_14_DAYS");
|
||||
|
||||
return steps;
|
||||
}
|
||||
|
||||
@@ -188,7 +188,9 @@ export default function OnboardingProvider({
|
||||
|
||||
updateState({
|
||||
agentRuns: newRunCount,
|
||||
completedSteps: [...state.completedSteps, ...milestoneSteps],
|
||||
completedSteps: Array.from(
|
||||
new Set([...state.completedSteps, ...milestoneSteps]),
|
||||
),
|
||||
...consecutiveData,
|
||||
});
|
||||
}, [state, updateState]);
|
||||
|
||||
Reference in New Issue
Block a user