Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #123

Merged
merged 8 commits into from
Feb 18, 2024
Merged

Dev #123

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/re_edge_gpt_dev_python3_10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/re_edge_gpt_dev_python3_11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/re_edge_gpt_dev_python3_9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
]
Expand Down
10 changes: 5 additions & 5 deletions re_edge_gpt/chat/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -66,15 +66,15 @@ 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:
self.struct["conversationSignature"] = response.headers["X-Sydney-Conversationsignature"]
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":
Expand Down Expand Up @@ -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:
Expand All @@ -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":
Expand Down
5 changes: 3 additions & 2 deletions re_edge_gpt/chat/re_edge_gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions re_edge_gpt/image/image_genearation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion re_edge_gpt/utils/exception/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class NoResultsFound(Exception):
pass


class NoAuthCookieFound(Exception):
class AuthCookieError(Exception):
pass


Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions test/self_test_requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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).
Expand Down
Loading