- Remove User/Quota models; quota fields now live directly on APIKey - Admin UI: login, API key management, settings (Ollama URL/model), proxy info display - .env/.env.example: ADMIN_PASSWORD, PROXY_HOST/PORT, DATABASE_URL, APP_TZ - Admin API runs on 127.0.0.1 only; proxy host/port configurable - API keys support optional expires_at; verified against Europe/Berlin timezone - Daily/monthly quota resets use Europe/Berlin midnight boundary - Fix all tests to use new flat model; add expiry tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
24 lines
657 B
Python
24 lines
657 B
Python
import os
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv(dotenv_path=os.path.join(os.path.dirname(__file__), '..', '.env'))
|
|
|
|
from database import Base, engine, SessionLocal
|
|
import models
|
|
from crud import get_setting, set_setting
|
|
|
|
def init_db():
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
db = SessionLocal()
|
|
if not get_setting(db, "ollama_url"):
|
|
set_setting(db, "ollama_url", os.getenv("OLLAMA_URL", "http://localhost:11434"))
|
|
if not get_setting(db, "default_model"):
|
|
set_setting(db, "default_model", os.getenv("DEFAULT_MODEL", "llama3"))
|
|
db.close()
|
|
|
|
print("Database initialized.")
|
|
|
|
if __name__ == "__main__":
|
|
init_db()
|