Each operation (inpaint, txt2img, img2img, outpaint) can now use a different provider. Resolution order: per-op override → global AI_PROVIDER default. Example: txt2img→openai, inpaint→invokeai, everything else→invokeai default. Backend: - config.py: add AI_PROVIDER_INPAINT / TXT2IMG / IMG2IMG / OUTPAINT settings - remote_provider.py: get_remote_provider(operation) resolves override then default; _build_provider() extracted as shared factory; _OP_FIELD maps op→setting name - ai_tools.py: each endpoint passes its operation to _require_remote(); GET /api/config runs per-op health checks concurrently, returns operations map and overrides; POST /api/config accepts and applies per-op override fields Frontend: - ai_provider_settings.js: four new selects (inpaint/txt2img/img2img/outpaint); persists to localStorage and sends per-op fields to POST /api/config - provider-badge.js: shows override summary (e.g. "invokeai · txt2img→openai") and per-op health in tooltip - .env.example: document per-op override env vars with examples https://claude.ai/code/session_01B58MaJCU1R6KwBDJCp8AfN
66 lines
2.0 KiB
Python
66 lines
2.0 KiB
Python
from pydantic_settings import BaseSettings
|
|
from typing import List
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
# Database
|
|
database_url: str = "sqlite:///./data/ai_photo_edit.db"
|
|
|
|
# Security
|
|
secret_key: str = "your-secret-key-change-in-production"
|
|
algorithm: str = "HS256"
|
|
access_token_expire_minutes: int = 30
|
|
|
|
# AI Provider
|
|
# Local: blank or "mock" — always available, no config needed
|
|
# Remote default (used for any operation without a specific override):
|
|
# openai | invokeai | comfyui | replicate | stability
|
|
ai_provider: str = "mock"
|
|
|
|
# Per-operation provider overrides — blank means use ai_provider default.
|
|
# Operations: inpaint, txt2img, img2img, outpaint
|
|
# Example: AI_PROVIDER_TXT2IMG=openai (use OpenAI for text-to-image only)
|
|
ai_provider_inpaint: str = "" # remote inpaint / replace selection
|
|
ai_provider_txt2img: str = "" # text-to-image
|
|
ai_provider_img2img: str = "" # image-to-image
|
|
ai_provider_outpaint: str = "" # expand canvas
|
|
|
|
# Provider API Keys
|
|
openai_api_key: str = ""
|
|
openai_model: str = "dall-e-3"
|
|
stability_api_key: str = ""
|
|
replicate_api_key: str = ""
|
|
|
|
# InvokeAI (self-hosted)
|
|
invokeai_url: str = ""
|
|
invokeai_default_model: str = "flux-dev"
|
|
|
|
# ComfyUI (self-hosted)
|
|
comfyui_url: str = ""
|
|
comfyui_default_model: str = "v1-5-pruned-emaonly.ckpt"
|
|
|
|
# Model Selection (optional, provider-specific)
|
|
stability_model: str = "sdxl" # Options: sdxl, sd15, sd21
|
|
replicate_model: str = "sdxl-inpaint" # Options: sdxl-inpaint, lama, realistic-vision
|
|
|
|
# Allow per-edit model override
|
|
allow_model_override: bool = True
|
|
|
|
# File Storage
|
|
data_dir: str = "./data"
|
|
max_upload_size_mb: int = 50
|
|
|
|
# CORS
|
|
cors_origins: str = "http://localhost:3000,http://localhost:5173"
|
|
|
|
@property
|
|
def cors_origins_list(self) -> List[str]:
|
|
return [origin.strip() for origin in self.cors_origins.split(",")]
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
case_sensitive = False
|
|
|
|
|
|
settings = Settings()
|