Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ On model/auth/timeout failure the service returns HTTP 502 with
| `GCP_LOCATION` | `us-east1` | Vertex AI region |
| `GEMINI_MODEL` | `gemini-2.5-flash` | Model id |
| `GEMINI_TIMEOUT_MS` | `30000` | Per-request model timeout (ms) |
| `GEMINI_MAX_OUTPUT_TOKENS` | `700` | Analysis output cap for the single structured call |
| `GEMINI_CHAT_MAX_OUTPUT_TOKENS` | `512` | Result-chat output cap |
| `GEMINI_MAX_OUTPUT_TOKENS` | `4096` | Analysis output cap (shared by gemini-2.5-flash thinking + JSON answer) |
| `GEMINI_CHAT_MAX_OUTPUT_TOKENS` | `2048` | Result-chat output cap (shared by thinking + answer) |
| `ENABLE_OPENAPI_DOCS` | `false` | Enables `/docs`, `/redoc`, and `/openapi.json` only for local/dev use |
| `CORS_ALLOWED_ORIGINS` | empty | Comma-separated browser origins allowed to call the API; empty disables CORS middleware |
| `PORT` | `8080` | Server port (set by Cloud Run) |
Expand Down
8 changes: 6 additions & 2 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@
GCP_LOCATION = os.getenv("GCP_LOCATION", "us-east1")
GEMINI_MODEL = os.getenv("GEMINI_MODEL", "gemini-2.5-flash")
REQUEST_TIMEOUT_MS = int(os.getenv("GEMINI_TIMEOUT_MS", "30000"))
FULL_ANALYSIS_MAX_OUTPUT_TOKENS = int(os.getenv("GEMINI_MAX_OUTPUT_TOKENS", "700"))
CHAT_MAX_OUTPUT_TOKENS = int(os.getenv("GEMINI_CHAT_MAX_OUTPUT_TOKENS", "512"))
# ponytail: gemini-2.5-flash "thinking" tokens share this output budget. 700/512 let thinking
# eat the whole cap on complex labels, truncating the JSON to garbage -> 502 model_response_unparseable.
# Raised to comfortably fit thinking + answer for real OCR inputs. If a pathological label still
# truncates, bound thinking with types.ThinkingConfig(thinking_budget=N) on the generate_content calls.
FULL_ANALYSIS_MAX_OUTPUT_TOKENS = int(os.getenv("GEMINI_MAX_OUTPUT_TOKENS", "4096"))
CHAT_MAX_OUTPUT_TOKENS = int(os.getenv("GEMINI_CHAT_MAX_OUTPUT_TOKENS", "2048"))
MAX_INGREDIENT_CHARS = 20_000
MAX_CHAT_QUESTION_CHARS = 1_000
MAX_CHAT_HISTORY_MESSAGES = 12
Expand Down
Loading