diff --git a/duckduckgo_search/duckduckgo_search.py b/duckduckgo_search/duckduckgo_search.py index 4af4970..fa32993 100644 --- a/duckduckgo_search/duckduckgo_search.py +++ b/duckduckgo_search/duckduckgo_search.py @@ -122,7 +122,7 @@ def _get_url( logger.debug(f"_get_url() {resp.url} {resp.status_code} {len(resp.content)}") if resp.status_code == 200: return resp.content - elif resp.status_code in (202, 301, 403): + elif resp.status_code in (202, 301, 403, 400, 429, 418): raise RatelimitException(f"{resp.url} {resp.status_code} Ratelimit") raise DuckDuckGoSearchException(f"{resp.url} return None. {params=} {content=} {data=}") @@ -170,6 +170,8 @@ def chat_yield(self, keywords: str, model: str = "gpt-4o-mini", timeout: int = 3 if line and line.startswith("data:"): if line == "data: [DONE]": break + if line == "data: [DONE][LIMIT_CONVERSATION]": + raise ConversationLimitException("ERR_CONVERSATION_LIMIT") x = json_loads(line[5:].strip()) if isinstance(x, dict): if x.get("action") == "error":