Bavarder / baichat-py

Python wrapper for BAI Chat
https://bavarder.codeberg.page/code/baichat
14 stars 5 forks source link

UnicodeDecodeError #4

Open solstice-gao opened 1 year ago

solstice-gao commented 1 year ago

image

prompt = "用中文回答:请帮我写一个判断字符串是否为空的方法"

Full Response

/Users/ga666666/PycharmProjects/baichat/venv/bin/python /Users/ga666666/PycharmProjects/baichat/baichat.py 
当
字符串
为空
时
,
通
常
指
字符串
的
长度
为
零
或
者
字符串
只
包
含
空
格
字符
。
以下
是
一个
于
判断
字符串
为空
的
方法
的
示
例
代码
:

Exception ignored from cffi callback <function write_callback at 0x10d522ac0>:
Traceback (most recent call last):
  File "/Users/ga666666/PycharmProjects/baichat/venv/lib/python3.11/site-packages/curl_cffi/curl.py", line 53, in write_callback
    callback(ffi.buffer(ptr, nmemb)[:])
  File "/Users/ga666666/PycharmProjects/baichat/venv/lib/python3.11/site-packages/baichat_py/__init__.py", line 80, in handle_stream_response
    Completion.message_queue.put(response.decode("utf-8"))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe7 in position 1359: unexpected end of data
Exception in thread Thread-1 (request):
Traceback (most recent call last):
  File "/Users/ga666666/PycharmProjects/baichat/venv/lib/python3.11/site-packages/curl_cffi/requests/session.py", line 428, in request
    c.perform()
  File "/Users/ga666666/PycharmProjects/baichat/venv/lib/python3.11/site-packages/curl_cffi/curl.py", line 191, in perform
    self._check_error(ret, action="perform")
  File "/Users/ga666666/PycharmProjects/baichat/venv/lib/python3.11/site-packages/curl_cffi/curl.py", line 84, in _check_error
    raise error
curl_cffi.curl.CurlError: Failed to perform, ErrCode: 23, Reason: 'Failure writing output to destination'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/ga666666/PycharmProjects/baichat/venv/lib/python3.11/site-packages/baichat_py/__init__.py", line 55, in request
    response = requests.post("https://chatbot.theb.ai/api/chat-process", headers=headers, data=payload, impersonate="chrome101", content_callback=Completion.handle_stream_response, proxies=proxies)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ga666666/PycharmProjects/baichat/venv/lib/python3.11/site-packages/curl_cffi/requests/__init__.py", line 46, in request
    return s.request(
           ^^^^^^^^^^
  File "/Users/ga666666/PycharmProjects/baichat/venv/lib/python3.11/site-packages/curl_cffi/requests/session.py", line 430, in request
    raise RequestsError(e)
curl_cffi.requests.errors.RequestsError: Failed to perform, ErrCode: 23, Reason: 'Failure writing output to destination'
0xMRTT commented 1 year ago

Will release a new version with a fix for that in a few days