Integration-Automation / ReEdgeGPT

Microsoft's Bing Chat AI
MIT License
163 stars 27 forks source link

Is `bot.set_conversation()` method works normally? #139

Closed WindowsSov8forUs closed 6 months ago

WindowsSov8forUs commented 6 months ago

Here is my code (based on ReEdgeGPT Save Conversation chapter in document):

import asyncio
import json
from pathlib import Path

from re_edge_gpt import Chatbot
from re_edge_gpt import ConversationStyle

# If you are using jupyter pls install this package
# from nest_asyncio import apply

conversation_dict = {}

async def test_ask() -> None:
    global conversation_dict
    bot = None
    try:
        cookies: list[dict] = json.loads(open(
            str(Path(str(Path.cwd()) + "/bing_cookies.json")), encoding="utf-8").read())
        bot = await Chatbot.create(proxy='http://127.0.0.1:7890', cookies=cookies, mode='Copilot')
        response = await bot.ask(
            prompt="将我说的下一个单词翻译为中文",
            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=4, ensure_ascii=False))
        conversation_dict.update(await bot.chat_hub.get_conversation())
        print(json.dumps(conversation_dict, indent=4, ensure_ascii=False))
    except Exception as error:
        raise error
    finally:
        if bot is not None:
            await bot.close()

async def test_ask_conversation() -> None:
    global conversation_dict
    bot = None
    try:
        cookies: list[dict] = json.loads(open(
            str(Path(str(Path.cwd()) + "/bing_cookies.json")), encoding="utf-8").read())
        bot = await Chatbot.create(proxy='http://127.0.0.1:7890', cookies=cookies, mode='Copilot')
        print(json.dumps(conversation_dict, indent=4, ensure_ascii=False))
        await bot.chat_hub.set_conversation(conversation_dict=conversation_dict)
        print(await bot.chat_hub.get_conversation())
        response = await bot.ask(
            prompt="піца",
            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))
    except Exception as error:
        raise error
    finally:
        if bot is not None:
            await bot.close()

if __name__ == "__main__":
    # If you are using jupyter pls use nest_asyncio apply()
    # apply()
    try:
        loop = asyncio.get_running_loop()
    except RuntimeError:
        loop = asyncio.get_event_loop()
    loop.run_until_complete(test_ask())
    loop.run_until_complete(test_ask_conversation())

when i try to print the converstaion_dict in three different places (line 29, 44 and 46) , i got these results:

{
    "conversation_id": "51D|BingProd|CAACBEB7E534FC1D8DB802AF3842634B05A5369463079EF5191144DFBED3C6BC",    
    "client_id": "1829582755821829",
    "encrypted_conversation_signature": "hfajN2I0M68jQ1MC2rj/LneLR/RtNpJMp92Og1K1ZYG9U2NrSl1KrmSUuZMpxBsvn83YshDbFkmD68VtKvlxoggqChVVtZ21JSHoXZC0THRltq3cUcinEPUmfH272yog9kEg+/XrWh0zLRvdUXw142Ay9YxvPBSW/fJEN9vuR8cavHqMYAsSc6HiQfCrHJXudhoJ3PZx6kaP6JAD1Q/plgAuJulqGulCrYs2mqSWmSLMwvjDwj0whUICLJTUpibfiX20ZxgKtpKcJ4TGCWW8ZRXYD+g+wasAKOTGF5ouDyBGw6ufy+JPY3b/IAV33nNRoPwWF6UmHUx0yrIHdUcZvtwX09lh6s5KAV8qeW8xx1VCL96XMs+EemLR8AGocp+VWBD2Wlu3KWMUxC0T+j50ZR+VYwTvRHZEc3MZhug7ooLJ9rAEWA1qIwUEyRKMy56UQoE59r/4gZNuoxXQmuU6QUCkC1YLQ/pH+69gUtt53/5klGK011Xx59K9sYFx4JFhpbC+UVaV4q24fAe556tE4/Pxb1EgRQxvvolBzVUX8HdyaeB2b7yXDYzhjoRVbd6mEthmaSTQpeDPaHuzSc0gjophYGL0ZlqOB38vgWiwiYNXSwj9Vd5PP5qfZpfPvWvBVrFKmmg2bILukc05wEr5bifPh4LmCpEeFyDCqmmu+QiWtMVNVECKe16A3sGPA7Q9LQ8Dg8wWViSsZ1x3UCIW/g/iSH+vxbDcSOToptwO8e7C2ABdcO8I4l7kNDucii/Eut173N/xzdlfBxix4iyr8TDxxYIY+S7ag19W4n//MG8WKpVrruCg9WH3iYJI627bLMavw/C9Hj8qwMPyopXw4ixyCe4tkz+H6RAQAKFqsigg1p7SjQDZjz86YNbGOOe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3lkbmV5LmJpbmcuY29tL3N5ZG5leSIsImF1ZCI6Imh0dHBzOi8vc3lkbmV5LmJpbmcuY29tL3N5ZG5leSJ9.Lw6mBMHejoG3cl5VvCe8F9fu7VeV_9qwIS6mi5O7gx4"
}
{
    "conversation_id": "51D|BingProd|CAACBEB7E534FC1D8DB802AF3842634B05A5369463079EF5191144DFBED3C6BC",    
    "client_id": "1829582755821829",
    "encrypted_conversation_signature": "hfajN2I0M68jQ1MC2rj/LneLR/RtNpJMp92Og1K1ZYG9U2NrSl1KrmSUuZMpxBsvn83YshDbFkmD68VtKvlxoggqChVVtZ21JSHoXZC0THRltq3cUcinEPUmfH272yog9kEg+/XrWh0zLRvdUXw142Ay9YxvPBSW/fJEN9vuR8cavHqMYAsSc6HiQfCrHJXudhoJ3PZx6kaP6JAD1Q/plgAuJulqGulCrYs2mqSWmSLMwvjDwj0whUICLJTUpibfiX20ZxgKtpKcJ4TGCWW8ZRXYD+g+wasAKOTGF5ouDyBGw6ufy+JPY3b/IAV33nNRoPwWF6UmHUx0yrIHdUcZvtwX09lh6s5KAV8qeW8xx1VCL96XMs+EemLR8AGocp+VWBD2Wlu3KWMUxC0T+j50ZR+VYwTvRHZEc3MZhug7ooLJ9rAEWA1qIwUEyRKMy56UQoE59r/4gZNuoxXQmuU6QUCkC1YLQ/pH+69gUtt53/5klGK011Xx59K9sYFx4JFhpbC+UVaV4q24fAe556tE4/Pxb1EgRQxvvolBzVUX8HdyaeB2b7yXDYzhjoRVbd6mEthmaSTQpeDPaHuzSc0gjophYGL0ZlqOB38vgWiwiYNXSwj9Vd5PP5qfZpfPvWvBVrFKmmg2bILukc05wEr5bifPh4LmCpEeFyDCqmmu+QiWtMVNVECKe16A3sGPA7Q9LQ8Dg8wWViSsZ1x3UCIW/g/iSH+vxbDcSOToptwO8e7C2ABdcO8I4l7kNDucii/Eut173N/xzdlfBxix4iyr8TDxxYIY+S7ag19W4n//MG8WKpVrruCg9WH3iYJI627bLMavw/C9Hj8qwMPy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CJpYXQiOjE3MTQ4MTgyNzMsImlzcyI6Imh0dHBzOi8vc3lkbmV5LmJpbmcuY29tL3N5ZG5leSIsImF1ZCI6Imh0dHBzOi8vc3lkbmV5LmJpbmcuY29tL3N5ZG5leSJ9.Lw6mBMHejoG3cl5VvCe8F9fu7VeV_9qwIS6mi5O7gx4"
}
{'conversation_id': '51D|BingProd|DA90830A75644D7ADC9DA6C59CFCB944B7F4C74CB249F3E26B5758ED5AA75334', 'client_id': '1829582755821829', 'encrypted_conversation_signature': 'BKBoL1Txw3cqDGBjCtbqf75OOlVtROUpV06/N6ZkRVLH9em2EvtYhLP1jsXN30lMa1XeNdm4g+DVGyQIFNvySKe2sdYlLLIJ7FjGpaSFeJ5SIVwgQxzNbbBkeYIg5xjkJ/eK4eHIcXsx3ToHE8VzUV5Gmr/QK3DBjH/KLe11OXQ1fQBY95hpRxUDLxzR/j5E8wFmWiKtfz/0xD0/LLdbWw5MZ/crwjJk4ri8ofGq8s1kzLZxaZpu0D/2QD1PAhY8sLVxmK5tE3IueW8LVV2MVEwMB40HkNOyvZ4LtDmRg1CsMcV1dEMTLYDcs8eUXW9bNQ/lOgsioWRUetqAe9swrP3lmBVyfXJNiy30hmqeXprTw1WEcYvIlBFOMX3t7ABxvZaRR0sgE7aZ3gPTvmMxokRuEel1/NWlH5ichRMmaDRkzWjjyio339wxLE1n5jhQgoJKQLGSKqof6EsKojR8z5naWOBWWQA6dIeTQx1mDjOYnVnnLburNT75rEh9JAL3zI8nC22xE/4CTM6EPZF7i9znbC/44qb+DMVNPWRdOtnSV0kslRPGL4vbnGePR5ciS949VxVcX8C5vtiEqUNNcb7meiZPJylS3YjH5RqXvMUcfDleXOboiVHq7LdzOh2UYRmrBO+smT13cXbzDsCo4jV1R7LY71EgCVixWz/vQaw/dsU+tiy+bh7CPGvMTqu5YYwY8KFRfvex0LsljcPNO8OC/4ot/LdYL40LRgaOBm5BvxXgVsckjGMG1BE5jdz0bJahbFHWZ5lKRhyx7gLkXjheolR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yI6WyJkZWZhdWx0X3NjZW5hcmlvIl0sIm5iZiI6MTcxNDgxODIyMSwiZXhwIjoxNzE0ODIxODgxLCJpYXQiOjE3MTQ4MTgyODEsImlzcyI6Imh0dHBzOi8vc3lkbmV5LmJpbmcuY29tL3N5ZG5leSIsImF1ZCI6Imh0dHBzOi8vc3lkbmV5LmJpbmcuY29tL3N5ZG5leSJ9.voNJqlMMPUNZ3TjqrnsXS-aEESqz9PDv_Z3SWraofso'}

it seems that bot.set_conversation() method does not work properly, that these chatbots have different conversation_id and encrypted_conversation_signature with the same client_id , and i guess these values should be all the same. as the responses, they has no relevance at all, and it seems that they belong to total different conversations, because the messages_left of them are both 29 , which means it's a new conversation.

is this method really worked?

WindowsSov8forUs commented 6 months ago

Is Save Conversation function able to use now? Why can't I make continuous conversation? Why this issue is invalid?

JE-Chen commented 6 months ago

Invalid tag means this issue doesn't seem right, and will be check later. Not means this issue is invalid.

WindowsSov8forUs commented 6 months ago

Invalid tag means this issue doesn't seem right, and will be check later. Not means this issue is invalid.

Oh sorry i misunderstood it. I found some potential key naming inconsistencies in chathub.py . For example, both encryptedConversationSignature and encrypted_conversation_signature are used as keys in the ChatHub.conversation.struct dictionary. However, when I replaced these with what I believe to be the correct names, the behavior of the copilot remained unchanged. I am still unable to carry out a continuous conversation.

JE-Chen commented 6 months ago

Fix it in the new version.