File size: 3,259 Bytes
1fe7075
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c7a38a3
 
1fe7075
 
 
c7a38a3
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from config.loader import config_value

GEMINI_API_KEY = str(config_value(
    "GEMINI_API_KEY", "gemini", "api_key", "",
)).strip()

GEMINI_IMAGE_MODEL = str(config_value(
    "GEMINI_IMAGE_MODEL", "gemini", "image_model", "gemini-3.1-flash-image",
)).strip()

GEMINI_API_BASE_URL = str(config_value(
    "GEMINI_API_BASE_URL", "gemini", "api_base_url",
    "https://generativelanguage.googleapis.com/v1beta/models",
)).rstrip("/")

GEMINI_TIMEOUT_SECONDS = float(config_value(
    "GEMINI_TIMEOUT_SECONDS", "gemini", "timeout_seconds", "60",
))

# "Enhance with AI" (routes/gemini.py). Smaller requests come back faster: the
# render is sent at most this many pixels on its long side, and the answer is
# requested at this size ("1K" or "2K"; empty = the model's default).
GEMINI_MAX_INPUT_SIDE = int(config_value(
    "GEMINI_MAX_INPUT_SIDE", "gemini", "max_input_side", "1536",
))
GEMINI_IMAGE_SIZE = str(config_value(
    "GEMINI_IMAGE_SIZE", "gemini", "image_size", "1K",
)).strip()
# Pattern-drift guard: how much of the render's structure the answer must keep
# (0..1). Below it the answer is retried once, then refused.
GEMINI_MIN_SIMILARITY = float(config_value(
    "GEMINI_MIN_SIMILARITY", "gemini", "min_similarity", "0.5",
))
# Invented-design guard: the largest area (fraction of the image) that was plain
# in the render and patterned in the answer, e.g. a wall the shopper left plain.
GEMINI_MAX_NEW_PATTERN = float(config_value(
    "GEMINI_MAX_NEW_PATTERN", "gemini", "max_new_pattern", "0.004",
))
# Swapped-design guard: the largest area (fraction of the image) whose colour,
# not brightness, changed, e.g. one wall's design repainted with another's.
GEMINI_MAX_RECOLOURED = float(config_value(
    "GEMINI_MAX_RECOLOURED", "gemini", "max_recoloured", "0.06",
))
# Enhancements per organization (or user) per hour, per renderer process.
GEMINI_ENHANCE_PER_HOUR = int(config_value(
    "GEMINI_ENHANCE_PER_HOUR", "gemini", "enhance_per_hour", "60",
))
# Hosts the reference tile images may come from (our tile CDN).
GEMINI_REFERENCE_HOSTS = tuple(
    host.strip().lower()
    for host in str(config_value(
        "GEMINI_REFERENCE_HOSTS", "gemini", "reference_hosts",
        "baetes-space-bucket.sfo3.cdn.digitaloceanspaces.com,baetes-space-bucket.sfo3.digitaloceanspaces.com,"
        "baetes-visualizer.fra1.cdn.digitaloceanspaces.com,baetes-visualizer.fra1.digitaloceanspaces.com",
    )).split(",")
    if host.strip()
)

# "Enhance with AI" v2 (routes/enhance.py): the browser sends its frozen wallpaper layers,
# the renderer repairs coverage and the AI only supplies lighting (see services/enhance).
# Concurrent enhancements per renderer process; more wait their turn.
ENHANCE_CONCURRENCY = int(config_value("ENHANCE_CONCURRENCY", "enhance", "concurrency", "2"))
# Largest multipart request accepted (all layers together).
ENHANCE_MAX_REQUEST_BYTES = int(config_value(
    "ENHANCE_MAX_REQUEST_BYTES", "enhance", "max_request_bytes", str(40 * 1024 * 1024),
))
# When set (and not on a deployed pod), every enhancement's inputs, intermediates and
# result are written to <dir>/<timestamp>-<id>/ for scripts/enhance_compare_sheet.py.
ENHANCE_DEBUG_DIR = str(config_value("ENHANCE_DEBUG_DIR", "enhance", "debug_dir", "")).strip()