Repository: Significant-Gravitas/Auto-GPT
File: autogpt_platform/backend/backend/server/v2/store/db.py (Python)

Code before:
    except prisma.errors.PrismaError as e:
        logger.error(f"Database error updating profile: {e}")
        raise backend.server.v2.store.exceptions.DatabaseError(
            "Failed to update profile"
        ) from e


async def get_my_agents(
    user_id: str,
    page: int = 1,
    page_size: int = 20,
) -> backend.server.v2.store.model.MyAgentsResponse:
    logger.debug(f"Getting my agents for user {user_id}, page={page}")

    try:
        search_filter = prisma.types.LibraryAgentWhereInput(
            userId=user_id,
            Agent={"is": {"StoreListing": {"none": {"isDeleted": False}}}},
            isArchived=False,
            isDeleted=False,
        )

        library_agents = await prisma.models.LibraryAgent.prisma().find_many(
            where=search_filter,
            order=[{"agentVersion": "desc"}],
            skip=(page - 1) * page_size,
            take=page_size,
            include={"Agent": True},
        )

        total = await prisma.models.LibraryAgent.prisma().count(where=search_filter)
        total_pages = (total + page_size - 1) // page_size

        my_agents = [
            backend.server.v2.store.model.MyAgent(
                agent_id=agent.id,
                agent_version=agent.version,
                agent_name=agent.name or "",
                last_edited=agent.updatedAt or agent.createdAt,
                description=agent.description or "",
                agent_image=entry.imageUrl,
            )
            for entry in library_agents
            if (agent := entry.Agent)
        ]

        return backend.server.v2.store.model.MyAgentsResponse(
            agents=my_agents,
            pagination=backend.server.v2.store.model.Pagination(
                current_page=page,
                total_items=total,

Review comment (suggestion):
This syntax has slightly different type checking behavior and gives much more opaque type checking errors. Please use normal dictionary syntax for this, like
```suggestion
        search_filter: prisma.types.LibraryAgentWhereInput = {
```

Code after:
            name=updated_profile.name,
            username=updated_profile.username,
            description=updated_profile.description,
            links=updated_profile.links,
            avatar_url=updated_profile.avatarUrl or "",
            agent_rating=0.0,
            agent_runs=0,
            top_categories=[],
        )

    except prisma.errors.PrismaError as e:
        logger.error(f"Database error updating profile: {e}")
        raise backend.server.v2.store.exceptions.DatabaseError(
            "Failed to update profile"
        ) from e


async def get_my_agents(
    user_id: str,
    page: int = 1,
    page_size: int = 20,
) -> backend.server.v2.store.model.MyAgentsResponse:
    logger.debug(f"Getting my agents for user {user_id}, page={page}")

    try:
        search_filter = prisma.types.LibraryAgentWhereInput(
            userId=user_id,
            Agent={"is": {"StoreListing": {"none": {"isDeleted": False}}}},
            isArchived=False,
            isDeleted=False,
        )

        library_agents = await prisma.models.LibraryAgent.prisma().find_many(
            where=search_filter,
            order=[{"agentVersion": "desc"}],
            skip=(page - 1) * page_size,
            take=page_size,
            include={"Agent": True},
        )

        total = await prisma.models.LibraryAgent.prisma().count(where=search_filter)
        total_pages = (total + page_size - 1) // page_size

        my_agents = [
            backend.server.v2.store.model.MyAgent(
                agent_id=agent.id,
                agent_version=agent.version,
                agent_name=agent.name or "",
                last_edited=agent.updatedAt or agent.createdAt,
                description=agent.description or "",
                agent_image=entry.imageUrl,