From a129c3db44eaab420086c5fd9817ee03f5c26d59 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Sat, 20 Apr 2024 18:21:19 +0200 Subject: Add AbraGeoBlockedError handling --- g4f/Provider/MetaAI.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'g4f') diff --git a/g4f/Provider/MetaAI.py b/g4f/Provider/MetaAI.py index d4cca68d..e64a96d5 100644 --- a/g4f/Provider/MetaAI.py +++ b/g4f/Provider/MetaAI.py @@ -18,6 +18,9 @@ class Sources(): def __str__(self) -> str: return "\n\n" + ("\n".join([f"[{link['title']}]({link['link']})" for link in self.list])) +class AbraGeoBlockedError(Exception): + pass + class MetaAI(AsyncGeneratorProvider): url = "https://www.meta.ai" working = True @@ -136,6 +139,8 @@ class MetaAI(AsyncGeneratorProvider): async with self.session.get("https://www.meta.ai/", cookies=cookies) as response: await raise_for_status(response, "Fetch home failed") text = await response.text() + if "AbraGeoBlockedError" in text: + raise AbraGeoBlockedError("Meta AI isn't available yet in your country") if cookies is None: cookies = { "_js_datr": self.extract_value(text, "_js_datr"), -- cgit v1.2.3