diff --git a/re_edge_gpt/chat/chathub.py b/re_edge_gpt/chat/chathub.py index 9dd9787..e91d556 100644 --- a/re_edge_gpt/chat/chathub.py +++ b/re_edge_gpt/chat/chathub.py @@ -22,7 +22,6 @@ from re_edge_gpt.utils.utilities import guess_locale from .conversation import Conversation from .request import ChatHubRequest -from ..plugins.suno import generate_suno_music from ..utils.exception.exceptions import NoResultsFound, ResponseError ssl_context = ssl.create_default_context() @@ -226,27 +225,27 @@ async def close(self) -> None: async def get_conversation(self) -> dict: return { - "conversation_id": self.conversation_id, - "client_id": self.request.client_id, - "encrypted_conversation_signature": self.encrypted_conversation_signature, - "conversation_signature": self.request.conversation_signature, + "conversationId": self.conversation.struct["conversationId"], + "clientId": self.conversation.struct["clientId"], + "encryptedConversationSignature": self.conversation.struct["encryptedConversationSignature"], + "conversationSignature": self.conversation.struct["conversationSignature"], } async def set_conversation(self, conversation_dict: dict) -> None: - self.conversation.struct["conversationId"] = conversation_dict.get("conversation_id") - self.conversation.struct["client_id"] = conversation_dict.get("client_id") + self.conversation.struct["conversationId"] = conversation_dict.get("conversationId") + self.conversation.struct["clientId"] = conversation_dict.get("clientId") self.conversation.struct[ - "encrypted_conversation_signature"] = conversation_dict.get("encrypted_conversation_signature") - self.conversation.struct["conversation_signature"] = conversation_dict.get("conversation_signature") + "encryptedConversationSignature"] = conversation_dict.get("encryptedConversationSignature") + self.conversation.struct["conversationSignature"] = conversation_dict.get("conversationSignature") async def delete_conversation(self, conversation_id: str = None, client_id: str = None, encrypted_conversation_signature: str = None, conversation_signature: str = None ) -> None: self.conversation.struct["conversationId"] = conversation_id - self.conversation.struct["client_id"] = client_id + self.conversation.struct["clientId"] = client_id self.conversation.struct[ - "encrypted_conversation_signature"] = encrypted_conversation_signature - self.conversation.struct["conversation_signature"] = conversation_signature + "encryptedConversationSignature"] = encrypted_conversation_signature + self.conversation.struct["conversationSignature"] = conversation_signature delete_conversation_url = "https://sydney.bing.com/sydney/DeleteSingleConversation" await self.session.post( delete_conversation_url, diff --git a/requirements.txt b/requirements.txt index 2253ec8..2d8062d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ aiohttp certifi httpx -prompt_toolkit requests rich regex diff --git a/test/unit_test/back-end/manual_test/test_conversation.py b/test/unit_test/back-end/manual_test/test_conversation.py index 3d19401..0354185 100644 --- a/test/unit_test/back-end/manual_test/test_conversation.py +++ b/test/unit_test/back-end/manual_test/test_conversation.py @@ -18,12 +18,13 @@ async def test_ask() -> None: str(Path(str(Path.cwd()) + "/bing_cookies.json")), encoding="utf-8").read()) bot = await Chatbot.create(cookies=cookies) response = await bot.ask( - prompt="Translate next word what I say to english", + prompt="Hello there", conversation_style=ConversationStyle.balanced, simplify_response=True ) # If you are using non ascii char you need set ensure_ascii=False print(json.dumps(response, indent=2, ensure_ascii=False)) + print(bot.chat_hub.conversation.struct) print(await bot.chat_hub.get_conversation()) conversation_dict.update(await bot.chat_hub.get_conversation()) except Exception as error: @@ -41,12 +42,14 @@ async def test_ask_conversation() -> None: bot = await Chatbot.create(cookies=cookies) await bot.chat_hub.set_conversation(conversation_dict=conversation_dict) response = await bot.ask( - prompt="піца", + prompt="What did I say before?", conversation_style=ConversationStyle.balanced, simplify_response=True ) # If you are using non ascii char you need set ensure_ascii=False print(json.dumps(response, indent=2, ensure_ascii=False)) + print(bot.chat_hub.conversation.struct) + print(await bot.chat_hub.get_conversation()) except Exception as error: raise error finally: