Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(platform): Implement library add, update, remove, archive functionality #9218

Conversation

Swiftyos
Copy link
Contributor

@Swiftyos Swiftyos commented Jan 8, 2025

Changes 🏗️

  1. Core Features:

    • Add agents to the user's library.
    • Update library agents (auto-update, favorite, archive, delete).
    • Paginate library agents and presets.
    • Execute graphs using presets.
  2. Refactoring:

    • Replaced UserAgent with LibraryAgent.
    • Separated routes for agents and presets.
  3. Schema Changes:

    • Added LibraryAgent table with fields like isArchived, isDeleted, etc.
    • Soft delete functionality for AgentPreset.
  4. Testing:

    • Updated tests for LibraryAgent operations.
    • Added edge case tests for deletion, archiving, and pagination.
  5. Database Migrations:

    • Migration to drop UserAgent and add LibraryAgent.
    • Added fields for soft deletion and auto-update.

Note this includes the changes from the following PR's to avoid merge conflicts with them:

#9179
#9211

Swiftyos and others added 19 commits January 3, 2025 11:26
…without-agent-ownership' of github.com:Significant-Gravitas/AutoGPT into swiftyos/open-2276-add-ability-to-execute-store-agents-without-agent-ownership
…without-agent-ownership' into swiftyos/open-2277-implement-library-add-update-remove-archive-functionality
@Swiftyos Swiftyos requested a review from a team as a code owner January 8, 2025 09:45
@Swiftyos Swiftyos requested review from ntindle and aarushik93 and removed request for a team January 8, 2025 09:45
@github-actions github-actions bot added platform/backend AutoGPT Platform - Back end size/xl and removed platform/backend AutoGPT Platform - Back end labels Jan 8, 2025
Copy link

qodo-merge-pro bot commented Jan 8, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Access Control

The updated graph access logic needs careful review to ensure proper authorization - it now checks both user ownership and store listing access but the logic flow could potentially have edge cases.

if graph.userId == user_id:
    return GraphModel.from_db(graph, for_export) if graph else None

# If the graph is not owned by the user, we need to check if it's a store listing.
if not version:
    version = graph.version

store_listing_where: StoreListingWhereInput = {
    "agentId": graph_id,
    "agentVersion": version,
}

store_listing = await StoreListing.prisma().find_first(where=store_listing_where)

# If it does not belong to the user nor is not a store listing, return None
if not store_listing:
    return None

# If it is a store listing, return the graph model
Input Validation

The preset execution endpoint merges preset inputs with node inputs without validation. Need to verify this doesn't allow overriding critical preset values.

merged_input = {**preset.inputs, **node_input}
Error Handling

The library agent update function needs review of error cases, particularly around version conflicts when auto-updating agents.

async def update_agent_version_in_library(
    user_id: str, agent_id: str, agent_version: int
) -> None:
    """
    Updates the agent version in the library
    """
    try:
        await prisma.models.LibraryAgent.prisma().update(
            where={
                "userId": user_id,
                "agentId": agent_id,
                "useGraphIsActiveVersion": True,
            },
            data=prisma.types.LibraryAgentUpdateInput(
                Agent=prisma.types.AgentGraphUpdateOneWithoutRelationsInput(
                    connect=prisma.types.AgentGraphWhereUniqueInput(
                        id=agent_id,
                        version=agent_version,
                    ),
                ),
            ),
        )
    except prisma.errors.PrismaError as e:
        logger.error(f"Database error updating agent version in library: {str(e)}")
        raise backend.server.v2.store.exceptions.DatabaseError(
            "Failed to update agent version in library"
        ) from e

Copy link

netlify bot commented Jan 8, 2025

Deploy Preview for auto-gpt-docs-dev ready!

Name Link
🔨 Latest commit f1ce98e
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs-dev/deploys/67810c4db3110f00080686ec
😎 Deploy Preview https://deploy-preview-9218--auto-gpt-docs-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 8, 2025

Deploy Preview for auto-gpt-docs ready!

Name Link
🔨 Latest commit f1ce98e
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/67810c4daa0a4c0008ca7048
😎 Deploy Preview https://deploy-preview-9218--auto-gpt-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the platform/backend AutoGPT Platform - Back end label Jan 8, 2025
@aarushik93 aarushik93 removed their request for review January 8, 2025 09:57
@Pwuts
Copy link
Member

Pwuts commented Jan 9, 2025

I'll wait with reviewing this one until #9211 is merged

@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Jan 10, 2025
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@Swiftyos Swiftyos force-pushed the swiftyos/open-2277-implement-library-add-update-remove-archive-functionality branch from d5ac76b to bc8043b Compare January 10, 2025 11:54
Copy link
Contributor

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

@github-actions github-actions bot added size/s and removed conflicts Automatically applied to PRs with merge conflicts size/xl labels Jan 10, 2025
@Swiftyos Swiftyos enabled auto-merge January 10, 2025 12:02
@Swiftyos Swiftyos disabled auto-merge January 10, 2025 12:02
@Swiftyos Swiftyos merged commit fd6f28f into dev Jan 10, 2025
11 checks passed
@Swiftyos Swiftyos deleted the swiftyos/open-2277-implement-library-add-update-remove-archive-functionality branch January 10, 2025 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants