diff --git a/routes/ai_summary.py b/routes/ai_summary.py index bcef04e..b146b2c 100644 --- a/routes/ai_summary.py +++ b/routes/ai_summary.py @@ -182,9 +182,10 @@ def _extract_text(file_obj, ext: str) -> str: # Office address used as origin for distance/travel-time estimates. _OFFICE_ADDRESS = "2815 Hartland Road, Falls Church, VA 22043, USA" -# Text character limit sent to the API. llama-3.3-70b supports 128K tokens (~500K chars); -# 60K chars is a safe ceiling that leaves room for the prompt and response. -_TEXT_LIMIT = 60_000 +# Text character limit sent to the API per stage-1 call. +# Groq's HTTP payload limit is ~100 KB; our prompt template adds ~2.5 KB of overhead, +# so 30K chars of document text keeps the total JSON body safely under that ceiling. +_TEXT_LIMIT = 30_000 # Analyst persona injected as the system message in every API call. _SYSTEM_PROMPT = (