diff --git a/.github/workflows/re_edge_gpt_dev_python3_10.yml b/.github/workflows/re_edge_gpt_dev_python3_10.yml index cca73a9..a657f93 100644 --- a/.github/workflows/re_edge_gpt_dev_python3_10.yml +++ b/.github/workflows/re_edge_gpt_dev_python3_10.yml @@ -24,7 +24,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip wheel - pip install -r dev_requirements.txt + pip install -r ./test/dev_requirements.txt - name: Test Bot env: EDGE_COOKIES: ${{ secrets.EDGE_COOKIES }} diff --git a/.github/workflows/re_edge_gpt_dev_python3_11.yml b/.github/workflows/re_edge_gpt_dev_python3_11.yml index 5711ee7..53d13f1 100644 --- a/.github/workflows/re_edge_gpt_dev_python3_11.yml +++ b/.github/workflows/re_edge_gpt_dev_python3_11.yml @@ -24,7 +24,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip wheel - pip install -r dev_requirements.txt + pip install -r ./test/dev_requirements.txt - name: Test Bot env: EDGE_COOKIES: ${{ secrets.EDGE_COOKIES }} diff --git a/.github/workflows/re_edge_gpt_dev_python3_9.yml b/.github/workflows/re_edge_gpt_dev_python3_9.yml index 9b725f8..ef92525 100644 --- a/.github/workflows/re_edge_gpt_dev_python3_9.yml +++ b/.github/workflows/re_edge_gpt_dev_python3_9.yml @@ -24,7 +24,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip wheel - pip install -r dev_requirements.txt + pip install -r ./test/dev_requirements.txt - name: Test Bot env: EDGE_COOKIES: ${{ secrets.EDGE_COOKIES }} diff --git a/dev.toml b/dev.toml index 96b52e6..e266f40 100644 --- a/dev.toml +++ b/dev.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" [project] name = "re_edge_gpt_dev" -version = "0.0.37" +version = "0.0.41" authors = [ { name = "JE-Chen", email = "jechenmailman@gmail.com" }, ] diff --git a/pyproject.toml b/pyproject.toml index 0e859b0..bfb680f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" [project] name = "re_edge_gpt" -version = "0.0.33" +version = "0.0.34" authors = [ { name = "JE-Chen", email = "jechenmailman@gmail.com" }, ] diff --git a/re_edge_gpt/chat/conversation.py b/re_edge_gpt/chat/conversation.py index b42a8cd..989ef4e 100644 --- a/re_edge_gpt/chat/conversation.py +++ b/re_edge_gpt/chat/conversation.py @@ -7,7 +7,7 @@ from re_edge_gpt.chat.constants import HEADERS_INIT_CONVER, BUNDLE_VERSION, SYDNEY_INIT_HEADER from re_edge_gpt.chat.proxy import get_proxy -from re_edge_gpt.utils.exception.exceptions import NotAllowedToAccess, NoAuthCookieFound +from re_edge_gpt.utils.exception.exceptions import NotAllowedToAccess, AuthCookieError class Conversation: @@ -66,7 +66,7 @@ def __init__( print(f"Status code: {response.status_code}") print(response.text) print(response.url) - raise NoAuthCookieFound("Authentication failed") + raise AuthCookieError("Authentication failed") try: self.struct = response.json() if self.struct.get("conversationSignature") is None: @@ -74,7 +74,7 @@ def __init__( self.struct["encryptedConversationSignature"] = response.headers[ "X-Sydney-Encryptedconversationsignature"] except (json.decoder.JSONDecodeError, NotAllowedToAccess) as exc: - raise NoAuthCookieFound( + raise AuthCookieError( "Authentication failed. You have not been accepted into the beta.", ) from exc if self.struct["result"]["value"] == "UnauthorizedRequest": @@ -127,7 +127,7 @@ async def create( print(f"Status code: {response.status_code}") print(response.text) print(response.url) - raise NoAuthCookieFound("Authentication failed") + raise AuthCookieError("Authentication failed") try: self.struct = response.json() if self.struct.get("conversationSignature") is None: @@ -136,7 +136,7 @@ async def create( "X-Sydney-Encryptedconversationsignature"] except (json.decoder.JSONDecodeError, NotAllowedToAccess) as exc: print(response.text) - raise NoAuthCookieFound( + raise AuthCookieError( "Authentication failed. You have not been accepted into the beta.", ) from exc if self.struct["result"]["value"] == "UnauthorizedRequest": diff --git a/re_edge_gpt/chat/re_edge_gpt.py b/re_edge_gpt/chat/re_edge_gpt.py index 8a367c7..acfd261 100644 --- a/re_edge_gpt/chat/re_edge_gpt.py +++ b/re_edge_gpt/chat/re_edge_gpt.py @@ -69,8 +69,9 @@ async def create( self.proxy = proxy self.mode = mode conversation = await Conversation.create(self.proxy, cookies=cookies, mode=mode) - plugins_id = [PLUGINS[plugin] if plugin in PLUGINS else plugin for plugin in plugins_id] - await self.add_plugins(cookies, mode, conversation.struct["conversationId"], plugin_ids) + if plugin_ids is not None: + new_plugin_list = [PLUGINS.get(plugin, plugin) for plugin in plugin_ids] + await self.add_plugins(cookies, mode, conversation.struct["conversationId"], new_plugin_list) self.chat_hub = ChatHub( conversation, proxy=self.proxy, diff --git a/re_edge_gpt/image/image_genearation.py b/re_edge_gpt/image/image_genearation.py index ec952b8..0d9a3e5 100644 --- a/re_edge_gpt/image/image_genearation.py +++ b/re_edge_gpt/image/image_genearation.py @@ -20,7 +20,7 @@ error_blocked_prompt, \ error_unsupported_lang, error_timeout, error_noresults, error_no_images, download_message, error_image_create_failed from re_edge_gpt.utils.exception.exceptions import UnSupportLanguage, PromptBlocked, ImageCreateFailed, NoResultsFound, \ - NoAuthCookieFound, LimitExceeded, InappropriateContentType, ResponseError + AuthCookieError, LimitExceeded, InappropriateContentType, ResponseError FORWARDED_IP = f"1.0.0.{random.randint(0, 255)}" @@ -262,7 +262,7 @@ def __init__( proxy: str = None ) -> None: if auth_cookie is None and not all_cookies: - raise NoAuthCookieFound("No auth cookie provided") + raise AuthCookieError("No auth cookie provided") self.proxy: str = get_proxy(proxy) self.session = httpx.AsyncClient( proxies=self.proxy, @@ -441,7 +441,7 @@ def main(): cookie_json = json.load(file) if args.U is None and args.cookie_file is None: - raise NoAuthCookieFound("Could not find auth cookie") + raise AuthCookieError("Could not find auth cookie") if args.download_count > 4: raise LimitExceeded("The number of downloads must be less than five") diff --git a/re_edge_gpt/utils/exception/exceptions.py b/re_edge_gpt/utils/exception/exceptions.py index 7533288..006c5ed 100644 --- a/re_edge_gpt/utils/exception/exceptions.py +++ b/re_edge_gpt/utils/exception/exceptions.py @@ -18,7 +18,7 @@ class NoResultsFound(Exception): pass -class NoAuthCookieFound(Exception): +class AuthCookieError(Exception): pass diff --git a/dev_requirements.txt b/test/dev_requirements.txt similarity index 100% rename from dev_requirements.txt rename to test/dev_requirements.txt diff --git a/test/self_test_requirements.txt b/test/self_test_requirements.txt new file mode 100644 index 0000000..ef00360 --- /dev/null +++ b/test/self_test_requirements.txt @@ -0,0 +1,18 @@ +aiohttp +certifi +httpx +prompt_toolkit +requests +rich +regex +# GUI +PySide6 +qt-material +SpeechRecognition +# API +flask[async] +apispec +apispec-webframeworks +marshmallow +Flask-CORS +gunicorn diff --git a/test/unit_test/back-end/manual_test/test_bot_with_plugins_manual.py b/test/unit_test/back-end/manual_test/test_bot_with_plugins_manual.py index 64ff4ea..8f66331 100644 --- a/test/unit_test/back-end/manual_test/test_bot_with_plugins_manual.py +++ b/test/unit_test/back-end/manual_test/test_bot_with_plugins_manual.py @@ -1,8 +1,6 @@ import asyncio import json from pathlib import Path -from random import choice -from string import ascii_uppercase from re_edge_gpt import Chatbot from re_edge_gpt import ConversationStyle @@ -17,7 +15,7 @@ async def test_ask() -> None: try: cookies: list[dict] = json.loads(open( str(Path(str(Path.cwd()) + "/bing_cookies.json")), encoding="utf-8").read()) - bot = await Chatbot.create(cookies=cookies, mode="Bing", plugin_ids=["c310c353-b9f0-4d76-ab0d-1dd5e979cf68"]) + bot = await Chatbot.create(cookies=cookies, mode="Bing", plugin_ids=["notebook"]) prompt = """Rome (Italian and Latin: Roma, Italian: [ˈroːma] ⓘ) is the capital city of Italy. It is also the capital of the Lazio region, the centre of the Metropolitan City of Rome Capital, and a special comune (municipality) named Comune di Roma Capitale. With 2,860,009 residents in 1,285 km2 (496.1 sq mi),[2] Rome is the country's most populated comune and the third most populous city in the European Union by population within city limits. The Metropolitan City of Rome, with a population of 4,355,725 residents, is the most populous metropolitan city in Italy.[3] Its metropolitan area is the third-most populous within Italy.[5] Rome is located in the central-western portion of the Italian Peninsula, within Lazio (Latium), along the shores of the Tiber. Vatican City (the smallest country in the world)[6] is an independent country inside the city boundaries of Rome, the only existing example of a country within a city. Rome is often referred to as the City of Seven Hills due to its geographic location, and also as the "Eternal City". Rome is generally considered to be the cradle of Western civilization and Western Christian culture, and the centre of the Catholic Church.[7][8][9] Rome's history spans 28 centuries. While Roman mythology dates the founding of Rome at around 753 BC, the site has been inhabited for much longer, making it a major human settlement for almost three millennia and one of the oldest continuously occupied cities in Europe.[10] The city's early population originated from a mix of Latins, Etruscans, and Sabines. Eventually, the city successively became the capital of the Roman Kingdom, the Roman Republic and the Roman Empire, and is regarded by many as the first-ever Imperial city and metropolis.[11] It was first called The Eternal City (Latin: Urbs Aeterna; Italian: La Città Eterna) by the Roman poet Tibullus in the 1st century BC, and the expression was also taken up by Ovid, Virgil, and Livy.[12][13] Rome is also called "Caput Mundi" (Capital of the World).