ReEdgeGPT: Some prompts fails in 0.0.30

if prompt = ‘hello’ or ‘hello + hello’ its ok if prompt = ‘1+1’ or ‘2+2’ it fails with error all is ok with 0.0.28

TypeError
can only concatenate str (not "NoneType") to str
  File "C:\Users\user\V\4 python\2 telegram bot tesseract\tb1\test.py", line 19, in test_ask
    response = await bot.ask(
               ^^^^^^^^^^^^^^
  File "C:\Users\user\V\4 python\2 telegram bot tesseract\tb1\test.py", line 42, in <module>
    loop.run_until_complete(test_ask())
TypeError: can only concatenate str (not "NoneType") to str


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


async def test_ask() -> None:
    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(cookies=cookies)
        response = await bot.ask(
            prompt="1+1",
            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))
        # Raw response
        # print(response)
        assert response

    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())

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Reactions: 2
  • Comments: 28 (16 by maintainers)

Most upvoted comments

fixed re_edge_gpt\chat\re_edge_gpt.py" near line 109 and now its working ok

                        _old_mess = old_message or ''
                        _new_mess = msg.get("text") or ''
                        message.update({
                            "author": "bot",
                            # "text": old_message + msg.get("text")
                            "text": _old_mess + _new_mess
                        })

For reasons unknown to me, I am unable to set a breakpoint at line 109 in the file c:\Users\user\V\4 python\2 telegram bot tesseract\tb1\.venv\Lib\site-packages\re_edge_gpt\chat\re_edge_gpt.py and observe what’s happening at that point.

Traceback (most recent call last):
  File "C:\Program Files\Python311\Lib\runpy.py", line 198, in _run_module_as_main
    return _run_code(code, main_globals, None,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\runpy.py", line 88, in _run_code
    exec(code, run_globals)
  File "c:\Users\user\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 39, in <module>
    cli.main()
  File "c:\Users\user\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main
    run()
  File "c:\Users\user\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "c:\Users\user\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\user\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "c:\Users\user\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "C:\Users\user\V\4 python\2 telegram bot tesseract\tb1\test.py", line 42, in <module>
    loop.run_until_complete(test_ask())
  File "C:\Program Files\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\user\V\4 python\2 telegram bot tesseract\tb1\test.py", line 19, in test_ask
    response = await bot.ask(
               ^^^^^^^^^^^^^^
  File "c:\Users\user\V\4 python\2 telegram bot tesseract\tb1\.venv\Lib\site-packages\re_edge_gpt\chat\re_edge_gpt.py", line 109, in ask
    "text": old_message + msg.get("text")
            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
TypeError: can only concatenate str (not "NoneType") to str