File size: 2,563 Bytes
6f82324
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d5a2be2
 
 
6f82324
75c5414
 
 
6f82324
75c5414
 
 
 
 
 
 
 
 
 
 
6f82324
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
71
72
"""Paths, model IDs, and runtime constants."""
from __future__ import annotations

import os
from pathlib import Path

ROOT = Path(__file__).resolve().parent.parent
DATA_DIR = ROOT / "data"
ASSETS_DIR = ROOT / "assets"
PROMPTS_DIR = ROOT / "src" / "prompts"
CACHE_DIR = Path(os.environ.get("COOK_WITH_ME_CACHE", Path.home() / ".cache" / "cook-with-me"))
FLUX_CACHE = CACHE_DIR / "flux"
AUDIO_CACHE = CACHE_DIR / "audio"

for _d in (DATA_DIR, ASSETS_DIR, CACHE_DIR, FLUX_CACHE, AUDIO_CACHE):
    _d.mkdir(parents=True, exist_ok=True)


# --- Model identifiers ------------------------------------------------------
VISION_REPO = "openbmb/MiniCPM-V-4_6-GGUF"
VISION_MODEL_FILE = "MiniCPM-V-4_6-Q4_K_M.gguf"
VISION_MMPROJ_FILE = "mmproj-model-f16.gguf"

# Base model; set COOK_WITH_ME_PLANNER_REPO to point at a fine-tuned HF repo
PLANNER_REPO = os.environ.get("COOK_WITH_ME_PLANNER_REPO", "openbmb/MiniCPM4.1-8B")
PLANNER_FINETUNED_REPO = os.environ.get("COOK_WITH_ME_PLANNER_FT_REPO", "")  # set after fine-tune

# Modal app names
MODAL_APP_NAME = "cook-with-me-flux"
MODAL_CLS_NAME = "FluxKlein"

# Planner runs in its own Modal app (transformers 4.x, conflicts with the
# vision model's transformers 5.x — so it can't live in the same container).
PLANNER_MODAL_APP = "cook-with-me-planner"
PLANNER_MODAL_CLS = "Planner"

FLUX_REPO = os.environ.get("COOK_WITH_ME_FLUX_REPO", "black-forest-labs/FLUX.2-klein-9B")
FLUX_FALLBACK_REPO = "black-forest-labs/FLUX.1-schnell"
NARRATOR_REPO = "openbmb/VoxCPM2"
EMBED_MODEL = "sentence-transformers/all-MiniLM-L6-v2"


# --- Recipe dataset ---------------------------------------------------------
KAGGLE_DATASET = "thedevastator/better-recipes-for-a-better-life"
RECIPES_PARQUET = DATA_DIR / "recipes.parquet"
RECIPES_EMB_NPY = DATA_DIR / "recipes_emb.npy"
NUTRITION_CSV = DATA_DIR / "nutrition_table.csv"


# --- Generation knobs -------------------------------------------------------
N_THREADS = int(os.environ.get("COOK_WITH_ME_THREADS", os.cpu_count() or 4))
N_CTX = 4096
PLANNER_TEMPERATURE_PROPOSE = 0.7
PLANNER_TEMPERATURE_STRUCTURED = 0.4

FLUX_STEPS = 4
FLUX_GUIDANCE = 1.0
FLUX_RESOLUTION = 1024


# --- Runtime flags ----------------------------------------------------------
def is_mock() -> bool:
    """When True, agents return canned outputs instead of loading models."""
    return os.environ.get("COOK_WITH_ME_MOCK", "0") not in ("0", "", "false", "False")


def is_gpu_enabled() -> bool:
    try:
        import torch
        return torch.cuda.is_available()
    except Exception:
        return False