Clamp Pixabay per_page to API-required 3-200 range

Pixabay rejects per_page outside 3-200 with HTTP 400. The stock_sources
adapter already clamped, but the PixabayVideo and PixabayImage tools
passed the value through raw, so callers using per_page < 3 got a 400.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
mojahurtowniapl
2026-07-02 09:31:11 +02:00
parent dc1cbca657
commit f95505c3ca
3 changed files with 66 additions and 2 deletions

View File

@@ -127,7 +127,8 @@ class PixabayImage(BaseTool):
params: dict[str, Any] = {
"key": api_key,
"q": query,
"per_page": inputs.get("per_page", 5),
# Pixabay rejects per_page outside 3-200 with HTTP 400
"per_page": max(3, min(inputs.get("per_page", 5), 200)),
"page": inputs.get("page", 1),
"safesearch": str(inputs.get("safesearch", True)).lower(),
}

View File

@@ -130,7 +130,8 @@ class PixabayVideo(BaseTool):
params: dict[str, Any] = {
"key": api_key,
"q": query,
"per_page": inputs.get("per_page", 5),
# Pixabay rejects per_page outside 3-200 with HTTP 400
"per_page": max(3, min(inputs.get("per_page", 5), 200)),
"page": inputs.get("page", 1),
"safesearch": str(inputs.get("safesearch", True)).lower(),
}