From c4acb93e65f23f5fb58d8f3bfbfa3f98e70f3c0c Mon Sep 17 00:00:00 2001 From: NguyenND Date: Mon, 29 Jun 2026 17:39:34 -0400 Subject: [PATCH] Jun 29 - Improve AI analysis function 2 --- routes/ai_summary.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 = (