fix(chat): stop 429 retry spiral and add get_weather coord fallback
- search_places: detect HTTP 429 and mark retryable=False to stop the retry loop immediately instead of spiraling until MAX_ITERATIONS - get_weather: extract collection coordinates (lat/lng from first location with coords) and retry when LLM omits required params; uses sync_to_async for the DB query in the async view - AITravelChat: deduplicate context-only tools (get_trip_details, get_weather) in the render pipeline to prevent duplicate place cards from appearing when the retry loop causes multiple get_trip_details calls - Tests: 5 new tests covering 429 non-retryable path and weather coord fallback; all 39 chat tests pass
This commit is contained in:
@@ -196,6 +196,10 @@ def search_places(
|
||||
"category": category,
|
||||
"results": results,
|
||||
}
|
||||
except requests.HTTPError as exc:
|
||||
if exc.response is not None and exc.response.status_code == 429:
|
||||
return {"error": f"Places API request failed: {exc}", "retryable": False}
|
||||
return {"error": f"Places API request failed: {exc}"}
|
||||
except requests.RequestException as exc:
|
||||
return {"error": f"Places API request failed: {exc}"}
|
||||
except (TypeError, ValueError) as exc:
|
||||
|
||||
Reference in New Issue
Block a user