diff --git a/autogpt_platform/backend/.env.example b/autogpt_platform/backend/.env.example index c2204abae..ed87d8fb7 100644 --- a/autogpt_platform/backend/.env.example +++ b/autogpt_platform/backend/.env.example @@ -98,3 +98,5 @@ ENABLE_CLOUD_LOGGING=false ENABLE_FILE_LOGGING=false # Use to manually set the log directory # LOG_DIR=./logs + +APP_ENV=local diff --git a/autogpt_platform/backend/backend/server/rest_api.py b/autogpt_platform/backend/backend/server/rest_api.py index 4378cfb50..99dba1000 100644 --- a/autogpt_platform/backend/backend/server/rest_api.py +++ b/autogpt_platform/backend/backend/server/rest_api.py @@ -51,6 +51,7 @@ class AgentServer(AppService): await db.disconnect() def run_service(self): + docs_url = "/docs" if settings.config.app_env == "local" else None app = FastAPI( title="AutoGPT Agent Server", description=( @@ -60,6 +61,7 @@ class AgentServer(AppService): summary="AutoGPT Agent Server", version="0.1", lifespan=self.lifespan, + docs_url=docs_url, ) if self._test_dependency_overrides: diff --git a/autogpt_platform/backend/backend/server/ws_api.py b/autogpt_platform/backend/backend/server/ws_api.py index 8dfc54239..039ef718f 100644 --- a/autogpt_platform/backend/backend/server/ws_api.py +++ b/autogpt_platform/backend/backend/server/ws_api.py @@ -28,6 +28,7 @@ async def lifespan(app: FastAPI): event_queue.close() +docs_url = "/docs" if settings.config.app_env == "local" else None app = FastAPI(lifespan=lifespan) event_queue = RedisEventQueue() _connection_manager = None diff --git a/autogpt_platform/backend/backend/util/settings.py b/autogpt_platform/backend/backend/util/settings.py index 071f5a4c1..06222492b 100644 --- a/autogpt_platform/backend/backend/util/settings.py +++ b/autogpt_platform/backend/backend/util/settings.py @@ -1,5 +1,6 @@ import json import os +from enum import Enum from typing import Any, Dict, Generic, List, Set, Tuple, Type, TypeVar from pydantic import BaseModel, Field, PrivateAttr, field_validator @@ -15,6 +16,12 @@ from backend.util.data import get_config_path, get_data_path, get_secrets_path T = TypeVar("T", bound=BaseSettings) +class AppEnvironment(str, Enum): + LOCAL = "local" + DEVELOPMENT = "dev" + PRODUCTION = "prod" + + class UpdateTrackingModel(BaseModel, Generic[T]): _updated_fields: Set[str] = PrivateAttr(default_factory=set) @@ -121,6 +128,11 @@ class Config(UpdateTrackingModel["Config"], BaseSettings): "This value is then used to generate redirect URLs for OAuth flows.", ) + app_env: AppEnvironment = Field( + default=AppEnvironment.LOCAL, + description="The name of the app environment.", + ) + backend_cors_allow_origins: List[str] = Field(default_factory=list) @field_validator("backend_cors_allow_origins") diff --git a/autogpt_platform/market/.env.example b/autogpt_platform/market/.env.example index afaed399e..5522998fc 100644 --- a/autogpt_platform/market/.env.example +++ b/autogpt_platform/market/.env.example @@ -7,4 +7,6 @@ SENTRY_DSN=https://11d0640fef35640e0eb9f022eb7d7626@o4505260022104064.ingest.us. ENABLE_AUTH=true SUPABASE_JWT_SECRET=our-super-secret-jwt-token-with-at-least-32-characters-long -BACKEND_CORS_ALLOW_ORIGINS="http://localhost:3000,http://127.0.0.1:3000" \ No newline at end of file +BACKEND_CORS_ALLOW_ORIGINS="http://localhost:3000,http://127.0.0.1:3000" + +APP_ENV=local \ No newline at end of file diff --git a/autogpt_platform/market/market/app.py b/autogpt_platform/market/market/app.py index 785f3d985..864de8cb8 100644 --- a/autogpt_platform/market/market/app.py +++ b/autogpt_platform/market/market/app.py @@ -49,7 +49,7 @@ async def lifespan(app: fastapi.FastAPI): yield await db_client.disconnect() - +docs_url = "/docs" if os.environ.get("APP_ENV") == "local" else None app = fastapi.FastAPI( title="Marketplace API", description="AutoGPT Marketplace API is a service that allows users to share AI agents.", @@ -57,6 +57,7 @@ app = fastapi.FastAPI( version="0.1", lifespan=lifespan, root_path="/api/v1/market", + docs_url=docs_url, ) app.add_middleware(fastapi.middleware.gzip.GZipMiddleware, minimum_size=1000)