Feat: Implement token tracking, soft delete, and Admin UI improvements

This commit is contained in:
2026-02-10 01:00:26 +08:00
parent 6924e86b8d
commit 968eb173dd
14 changed files with 1763 additions and 180 deletions

20
run.py
View File

@@ -6,21 +6,21 @@ from dotenv import load_dotenv
def setup_environment():
"""Ensure dependencies are installed and .env exists."""
print("🚀 Initializing Storyline AI Gateway...")
print(">> Initializing Storyline AI Gateway...")
# 1. Check for .env file
if not os.path.exists(".env"):
print("⚠️ Warning: .env file not found!")
print("!! Warning: .env file not found!")
print("Please create a .env file based on the documentation.")
# 2. Check for virtual environment and install dependencies if requested
if len(sys.argv) > 1 and sys.argv[1] == "--install":
print("📦 Installing dependencies from requirements.txt...")
print(">> Installing dependencies from requirements.txt...")
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
print(" Dependencies installed successfully.")
print("++ Dependencies installed successfully.")
except Exception as e:
print(f" Error installing dependencies: {e}")
print(f"-- Error installing dependencies: {e}")
sys.exit(1)
def run_server():
@@ -28,16 +28,16 @@ def run_server():
load_dotenv()
# Configuration
host = os.getenv("HOST", "0.0.0.0")
host = os.getenv("HOST", "127.0.0.1")
port = int(os.getenv("PORT", 8000))
# On a server, we usually don't want reload=True by default for performance
# But for a 'test server', it might be useful.
reload = os.getenv("DEBUG", "false").lower() == "true"
print(f"\n🌐 Gateway starting at http://{host}:{port}")
print(f"🛠️ Admin Dashboard: http://{host}:{port}/admin")
print(f"📚 API Docs: http://{host}:{port}/docs")
print(f"🔄 Mode: {'Development (Reload On)' if reload else 'Production (Reload Off)'}\n")
print(f"\n>> Gateway starting at http://{host}:{port}")
print(f">> Admin Dashboard: http://{host}:{port}/admin")
print(f">> API Docs: http://{host}:{port}/docs")
print(f">> Mode: {'Development (Reload On)' if reload else 'Production (Reload Off)'}\n")
uvicorn.run(
"app.main:app",