mirror of
https://github.com/Significant-Gravitas/Auto-GPT.git
synced 2025-01-07 03:17:23 +08:00
tweak(platform): Disable docs endpoint when not local (#8265)
* disable docs endpoint * add to .env.example * use enum for app env * lint
This commit is contained in:
parent
61f1d0cdb5
commit
2aed470d26
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
|
@ -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"
|
||||
BACKEND_CORS_ALLOW_ORIGINS="http://localhost:3000,http://127.0.0.1:3000"
|
||||
|
||||
APP_ENV=local
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user