From bb251aec0ab60a8dd383bbcff2dafad5cd523e87 Mon Sep 17 00:00:00 2001 From: abhi1992002 Date: Mon, 23 Dec 2024 11:01:09 +0530 Subject: [PATCH] fix:lint --- .../backend/backend/server/v2/store/db.py | 7 ++++-- .../backend/backend/server/v2/store/routes.py | 22 ++++++++++++------- .../backend/backend/util/settings.py | 2 +- .../src/lib/autogpt-server-api/client.ts | 8 ++++--- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/autogpt_platform/backend/backend/server/v2/store/db.py b/autogpt_platform/backend/backend/server/v2/store/db.py index d47e70a2d5e9..1ad1cff67edb 100644 --- a/autogpt_platform/backend/backend/server/v2/store/db.py +++ b/autogpt_platform/backend/backend/server/v2/store/db.py @@ -781,7 +781,10 @@ async def get_my_agents( "Failed to fetch my agents" ) from e -async def get_agent(store_listing_version_id: str, version_id:Optional[int]) -> GraphModel: + +async def get_agent( + store_listing_version_id: str, version_id: Optional[int] +) -> GraphModel: """Get agent using the version ID and store listing version ID.""" try: store_listing_version = ( @@ -810,7 +813,7 @@ async def get_agent(store_listing_version_id: str, version_id:Optional[int]) -> graph.version = 1 graph.is_template = False graph.is_active = True - delattr(graph, 'user_id') + delattr(graph, "user_id") return graph diff --git a/autogpt_platform/backend/backend/server/v2/store/routes.py b/autogpt_platform/backend/backend/server/v2/store/routes.py index 0af5e4380766..8011970355b9 100644 --- a/autogpt_platform/backend/backend/server/v2/store/routes.py +++ b/autogpt_platform/backend/backend/server/v2/store/routes.py @@ -1,22 +1,20 @@ +import json import logging +import tempfile import typing import urllib.parse -import tempfile -import json - import autogpt_libs.auth.depends import autogpt_libs.auth.middleware import fastapi import fastapi.responses +from fastapi.encoders import jsonable_encoder import backend.data.graph import backend.server.v2.store.db import backend.server.v2.store.image_gen import backend.server.v2.store.media import backend.server.v2.store.model -from fastapi.encoders import jsonable_encoder - logger = logging.getLogger(__name__) @@ -514,9 +512,15 @@ async def generate_image( status_code=500, detail=f"Failed to generate image: {str(e)}" ) -@router.get("/download/agents/{store_listing_version_id}",tags=["store","public"],) + +@router.get( + "/download/agents/{store_listing_version_id}", + tags=["store", "public"], +) async def download_agent_file( - store_listing_version_id: str = fastapi.Path(..., description="The ID of the agent to download"), + store_listing_version_id: str = fastapi.Path( + ..., description="The ID of the agent to download" + ), version: typing.Optional[int] = fastapi.Query( None, description="Specific version of the agent" ), @@ -535,7 +539,9 @@ async def download_agent_file( HTTPException: If the agent is not found or an unexpected error occurs. """ - graph_data = await backend.server.v2.store.db.get_agent(store_listing_version_id=store_listing_version_id, version_id=version) + graph_data = await backend.server.v2.store.db.get_agent( + store_listing_version_id=store_listing_version_id, version_id=version + ) graph_date_dict = jsonable_encoder(graph_data) diff --git a/autogpt_platform/backend/backend/util/settings.py b/autogpt_platform/backend/backend/util/settings.py index 69504f528f3c..763c9e163ca0 100644 --- a/autogpt_platform/backend/backend/util/settings.py +++ b/autogpt_platform/backend/backend/util/settings.py @@ -149,7 +149,7 @@ class Config(UpdateTrackingModel["Config"], BaseSettings): ) media_gcs_bucket_name: str = Field( - default="", + default="autogpt_bucket", description="The name of the Google Cloud Storage bucket for media files", ) diff --git a/autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts b/autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts index 88fcd6817c38..1f74e67f636a 100644 --- a/autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts +++ b/autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts @@ -352,9 +352,11 @@ export default class BackendAPI { storeListingVersionId: string, version?: number, ): Promise { - return this._get( - `/download/agents/${storeListingVersionId}?version=${version}`, - ); + const url = version + ? `/store/download/agents/${storeListingVersionId}?version=${version}` + : `/store/download/agents/${storeListingVersionId}`; + + return this._get(url); } /////////////////////////////////////////