Cook_with_a_LLM / src /config.py
Fred1e4's picture
Complete Cook App (#5)
75c5414
"""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