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

Some prompts fails in 0.0.30 #117

Closed
theurs opened this issue Feb 7, 2024 · 28 comments
Closed

Some prompts fails in 0.0.30 #117

theurs opened this issue Feb 7, 2024 · 28 comments
Labels
invalid This doesn't seem right wontfix This will not be worked on

Comments

@theurs
Copy link

theurs commented Feb 7, 2024

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())
@JE-Chen JE-Chen added invalid This doesn't seem right bug Something isn't working labels Feb 7, 2024
@JE-Chen
Copy link
Member

JE-Chen commented Feb 7, 2024

I can get the result of prompt 1+1 or 2+2 etc.
image
image

@theurs
Copy link
Author

theurs commented Feb 7, 2024

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

@theurs
Copy link
Author

theurs commented Feb 7, 2024

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

@theurs
Copy link
Author

theurs commented Feb 8, 2024

upload image also throw error

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 66, in <module>
    loop.run_until_complete(test_ask2())
  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 42, in test_ask2
    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 128, in ask
    source_texts.append(source.get("providerDisplayName"))
                        ^^^^^^^^^^
AttributeError: 'str' object has no attribute 'get'
import asyncio
import base64
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_ask2() -> 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="What does this image show?",
            conversation_style=ConversationStyle.balanced,
            simplify_response=True,
            #attachment={"image_url": r"https://images.yourstory.com/cs/2/96eabe90392211eb93f18319e8c07a74/Image54nh-1683225460858.jpg"})
            attachment={"base64_image": base64.b64encode(open('1.jpg', 'rb').read()).decode('utf-8')})
        # 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_ask2())

@JE-Chen
Copy link
Member

JE-Chen commented Feb 8, 2024

Can version 0.0.31 fix this issue ?

@theurs
Copy link
Author

theurs commented Feb 8, 2024

0.0.31 - ok on my windows developer pc. and error on linux server

Traceback (most recent call last):
  File "/home/ubuntu/tb/./bingai.py", line 116, in chat_async
    r = await DIALOGS[dialog].ask(prompt=query, conversation_style=st, simplify_response=True, search_result=False)
  File "/home/ubuntu/.tb1/lib/python3.10/site-packages/re_edge_gpt/chat/re_edge_gpt.py", line 79, in ask
    async for final, response in self.chat_hub.ask_stream(
  File "/home/ubuntu/.tb1/lib/python3.10/site-packages/re_edge_gpt/chat/chathub.py", line 191, in ask_stream
    raise ResponseError(
re_edge_gpt.utils.exception.exceptions.ResponseError: Throttled: Request is throttled.

@JE-Chen
Copy link
Member

JE-Chen commented Feb 9, 2024

re_edge_gpt.utils.exception.exceptions.ResponseError: Throttled: Request is throttled.
Maybe this exception is reach chat limit per day. try use new cookie and run on next day.

@theurs
Copy link
Author

theurs commented Feb 9, 2024

I use the same address (proxy) and cookie file. the package versions are also the same pip freeze >123; pip install -r 123

@JE-Chen
Copy link
Member

JE-Chen commented Feb 10, 2024

Still have same exception?

@theurs
Copy link
Author

theurs commented Feb 10, 2024

Yes. Tried one more server, same result.

@JE-Chen
Copy link
Member

JE-Chen commented Feb 11, 2024

Run normal on my ubuntu, can u try use another bing account that have acces of Bing chat, use it's cookie file.
image

@theurs
Copy link
Author

theurs commented Feb 11, 2024

new VPS server ubuntu 22, new account and cookie, new venv. it works ok in my windows pc with vpn connected to this VPS

pip freeze
aiohttp==3.9.3
aiosignal==1.3.1
anyio==4.2.0
async-timeout==4.0.3
attrs==23.2.0
Brotli==1.1.0
certifi==2024.2.2
charset-normalizer==3.3.2
exceptiongroup==1.2.0
frozenlist==1.4.1
h11==0.14.0
httpcore==1.0.2
httpx==0.26.0
idna==3.6
markdown-it-py==3.0.0
mdurl==0.1.2
multidict==6.0.5
prompt-toolkit==3.0.43
Pygments==2.17.2
re_edge_gpt==0.0.31
regex==2023.12.25
requests==2.31.0
rich==13.7.0
sniffio==1.3.0
typing_extensions==4.9.0
urllib3==2.2.0
wcwidth==0.2.13
yarl==1.9.4
#!/usr/bin/env python3

import asyncio
import base64
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())

(.test) ubuntu@kunsun:~/test$ ./1.py
Traceback (most recent call last):
  File "/home/ubuntu/test/./1.py", line 68, in <module>
    loop.run_until_complete(test_ask())
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/ubuntu/test/./1.py", line 22, in test_ask
    response = await bot.ask(
  File "/home/ubuntu/.test/lib/python3.10/site-packages/re_edge_gpt/chat/re_edge_gpt.py", line 79, in ask
    async for final, response in self.chat_hub.ask_stream(
  File "/home/ubuntu/.test/lib/python3.10/site-packages/re_edge_gpt/chat/chathub.py", line 191, in ask_stream
    raise ResponseError(
re_edge_gpt.utils.exception.exceptions.ResponseError: Throttled: Request is throttled.
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7fc4e91787f0>

@JE-Chen
Copy link
Member

JE-Chen commented Feb 11, 2024

I will change forwardIP on next version.

@JE-Chen
Copy link
Member

JE-Chen commented Feb 12, 2024

Can version 0.0.32 run success ?

@theurs
Copy link
Author

theurs commented Feb 12, 2024

Successfully installed re_edge_gpt-0.0.32
(.test) ubuntu@kunsun:~/test$ ./1.py
Traceback (most recent call last):
  File "/home/ubuntu/test/./1.py", line 68, in <module>
    loop.run_until_complete(test_ask())
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/ubuntu/test/./1.py", line 22, in test_ask
    response = await bot.ask(
  File "/home/ubuntu/.test/lib/python3.10/site-packages/re_edge_gpt/chat/re_edge_gpt.py", line 79, in ask
    async for final, response in self.chat_hub.ask_stream(
  File "/home/ubuntu/.test/lib/python3.10/site-packages/re_edge_gpt/chat/chathub.py", line 191, in ask_stream
    raise ResponseError(
re_edge_gpt.utils.exception.exceptions.ResponseError: Throttled: Request is throttled.
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f1cd5d251b0>

@JE-Chen
Copy link
Member

JE-Chen commented Feb 23, 2024

I am still unable to determine what happened. However, both my Ubuntu Desktop 22.04 and Ubuntu Server 22.04 have successfully executed the code you provided.

So, I believe it’s a connection issue with Bing. (Bing block your server connect)

image

image

@JE-Chen JE-Chen added wontfix This will not be worked on and removed bug Something isn't working labels Feb 23, 2024
@golenchenko
Copy link

golenchenko commented Feb 24, 2024

I have same problem. Some requests failed with this error. I can`t determine what cause this problem.

   response = await bot.ask(
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\re_edge_gpt\re_edge_gpt.py", line 70, in ask
    async for final, response in self.chat_hub.ask_stream(
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\re_edge_gpt\chathub.py", line 179, in ask_stream
    raise Exception(
Exception: Throttled: Request is throttled.
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x0000023645DB0100>
transport: <_ProactorSocketTransport fd=724 read=<_OverlappedFuture cancelled>>
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\sslproto.py", line 690, in _process_write_backlog
    self._transport.write(chunk)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 361, in write
    self._loop_writing(data=bytes(data))
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 397, in _loop_writing
    self._write_fut = self._loop._proactor.send(self._sock, data)
AttributeError: 'NoneType' object has no attribute 'send'
Exception ignored in: <function ClientResponse.__del__ at 0x0000023645BDF1C0>

Exception: Throttled: Request is throttled.
Fatal error on SSL transport

@JE-Chen
Copy link
Member

JE-Chen commented Feb 25, 2024

I have same problem. Some requests failed with this error. I can`t determine what cause this problem.

   response = await bot.ask(
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\re_edge_gpt\re_edge_gpt.py", line 70, in ask
    async for final, response in self.chat_hub.ask_stream(
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\re_edge_gpt\chathub.py", line 179, in ask_stream
    raise Exception(
Exception: Throttled: Request is throttled.
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x0000023645DB0100>
transport: <_ProactorSocketTransport fd=724 read=<_OverlappedFuture cancelled>>
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\sslproto.py", line 690, in _process_write_backlog
    self._transport.write(chunk)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 361, in write
    self._loop_writing(data=bytes(data))
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 397, in _loop_writing
    self._write_fut = self._loop._proactor.send(self._sock, data)
AttributeError: 'NoneType' object has no attribute 'send'
Exception ignored in: <function ClientResponse.__del__ at 0x0000023645BDF1C0>

Exception: Throttled: Request is throttled. Fatal error on SSL transport

Not this package exception. You can see who threw this exception—it’s the Python 3.10 asyncio sslproto module.

C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\sslproto.py

@pixkk
Copy link
Contributor

pixkk commented Feb 25, 2024

I have same problem. Some requests failed with this error. I can`t determine what cause this problem.

   response = await bot.ask(
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\re_edge_gpt\re_edge_gpt.py", line 70, in ask
    async for final, response in self.chat_hub.ask_stream(
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\re_edge_gpt\chathub.py", line 179, in ask_stream
    raise Exception(
Exception: Throttled: Request is throttled.
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x0000023645DB0100>
transport: <_ProactorSocketTransport fd=724 read=<_OverlappedFuture cancelled>>
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\sslproto.py", line 690, in _process_write_backlog
    self._transport.write(chunk)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 361, in write
    self._loop_writing(data=bytes(data))
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 397, in _loop_writing
    self._write_fut = self._loop._proactor.send(self._sock, data)
AttributeError: 'NoneType' object has no attribute 'send'
Exception ignored in: <function ClientResponse.__del__ at 0x0000023645BDF1C0>

Exception: Throttled: Request is throttled. Fatal error on SSL transport

Not this package exception. You can see who threw this exception—it’s the Python 3.10 asyncio sslproto module.

C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\sslproto.py

So the error is thrown by “self.chathub.ask_stream”, which incorrectly gives something to the library “asyncio”.

@JE-Chen
Copy link
Member

JE-Chen commented Feb 25, 2024

I don’t know why, but even in our daily CI/CD processes, this exception has never been thrown before.

@IKDH
Copy link

IKDH commented Feb 27, 2024

Exception: Throttled: Request is throttled. --> You have reached the limitation of 300 messages per day I think.

@golenchenko
Copy link

Exception: Throttled: Request is throttled. --> You have reached the limitation of 300 messages per day I think.

I would be glad if that was the case. But I don’t even get 100 messages a day 🌚.I can also assume that the problem occurs if the prompt uses unicode characters. For example, quotes (not those that are ", but left and right quotes).

@JE-Chen
Copy link
Member

JE-Chen commented Feb 27, 2024

If your cookie too old, you can only 100 msg per day.
And what version of re-edge-gpt you are using?

@JE-Chen
Copy link
Member

JE-Chen commented Feb 29, 2024

I can also assume that the problem occurs if the prompt uses unicode characters. For example, quotes (not those that are ", but left and right quotes).
That is a Python json.dumps problem.
You need to add the parameter ensure_ascii=False.

json.dumps(response, indent=2, ensure_ascii=False)

See Q&A

@JE-Chen
Copy link
Member

JE-Chen commented Feb 29, 2024

Finally, I encountered an exception: “Throttled: Request is throttled.
image
When I use a cookie that hasn’t been refreshed for over a week.
Bing sets a cookie with a chat limit of only 10 messages per day if it has been active for over a week.

@JE-Chen
Copy link
Member

JE-Chen commented Feb 29, 2024

The only thing you need to do is refresh the cookie.

@golenchenko
Copy link

The only thing you need to do is refresh the cookie.

Are there plans to add functionality to automatically update cookies?

@JE-Chen
Copy link
Member

JE-Chen commented Mar 1, 2024

The only thing you need to do is refresh the cookie.

Are there plans to add functionality to automatically update cookies?

Open a new issue to request an enhancement.

@JE-Chen JE-Chen closed this as completed Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

5 participants