update config system for better fallback mech

This commit is contained in:
Kohaku-Blueleaf
2025-10-21 23:24:35 +08:00
parent a4743c6133
commit 40f4714c03
3 changed files with 289 additions and 192 deletions

View File

@@ -756,17 +756,6 @@ def generate_config_toml(config: dict) -> str:
# Generated by KohakuHub docker-compose generator
# Use this for local development server
[app]
base_url = "http://localhost:48888" # Dev server URL
api_base = "/api"
site_name = "KohakuHub"
workers = 1 # Single worker for dev
[database]
backend = "postgres"
url = "{db_url}"
auto_migrate = true # Auto-confirm migrations
[s3]
endpoint = "{s3_endpoint_internal}"
public_endpoint = "{s3_endpoint_public}"
@@ -774,6 +763,7 @@ access_key = "{config['s3_access_key']}"
secret_key = "{config['s3_secret_key']}"
bucket = "hub-storage"
region = "{s3_region}"
force_path_style = true
"""
# Add signature_version only if set (for external S3)
@@ -786,36 +776,55 @@ endpoint = "http://localhost:28000"
repo_namespace = "hf"
# Credentials auto-generated on first start
[lfs]
threshold_bytes = 1_000_000 # 1MB
keep_versions = 5
auto_gc = true
[auth]
session_secret = "{config['session_secret']}"
session_expire_hours = 168 # 7 days
token_expire_days = 365
require_email_verification = false
invitation_only = false
[admin]
enabled = true
secret_token = "{config['admin_secret']}"
[smtp]
enabled = false
host = "smtp.gmail.com"
port = 587
username = ""
password = ""
from = "noreply@kohakuhub.local"
tls = true
from_email = "noreply@kohakuhub.local"
use_tls = true
[auth]
require_email_verification = false
invitation_only = false
session_secret = "{config['session_secret']}"
session_expire_hours = 168 # 7 days
token_expire_days = 365
[admin]
enabled = true
secret_token = "{config['admin_secret']}"
[quota]
default_user_private_bytes = 10_000_000 # 10MB
default_user_public_bytes = 100_000_000 # 100MB
default_org_private_bytes = 10_000_000 # 10MB
default_org_public_bytes = 100_000_000 # 100MB
default_user_private_quota_bytes = 10_000_000 # 10MB
default_user_public_quota_bytes = 100_000_000 # 100MB
default_org_private_quota_bytes = 10_000_000 # 10MB
default_org_public_quota_bytes = 100_000_000 # 100MB
[fallback]
enabled = true
cache_ttl_seconds = 300
timeout_seconds = 10
max_concurrent_requests = 5
[app]
base_url = "http://localhost:48888" # Dev server URL
api_base = "/api"
db_backend = "postgres"
database_url = "{db_url}"
# LFS Configuration (sizes in decimal: 1MB = 1,000,000 bytes)
lfs_threshold_bytes = 5_000_000 # 5MB - files larger use LFS
lfs_multipart_threshold_bytes = 100_000_000 # 100MB - files larger use multipart upload
lfs_multipart_chunk_size_bytes = 50_000_000 # 50MB - size of each part (min 5MB except last)
lfs_keep_versions = 5 # Keep last K versions of each LFS file
lfs_auto_gc = true # Automatically delete old LFS objects on commit
# Download tracking settings
download_time_bucket_seconds = 900 # 15 minutes - session deduplication window
download_session_cleanup_threshold = 100 # Trigger cleanup when sessions > this
download_keep_sessions_days = 30 # Keep sessions from last N days
debug_log_payloads = false
site_name = "KohakuHub"
"""
return toml_content