lss233 / chatgpt-mirai-qq-bot

🚀 一键部署!真正的 AI 聊天机器人!支持ChatGPT、文心一言、讯飞星火、Bing、Bard、ChatGLM、POE,多账号,人设调教,虚拟女仆、图片渲染、语音发送 | 支持 QQ、Telegram、Discord、微信 等平台
GNU Affero General Public License v3.0
13.34k stars 1.56k forks source link

'ascii' codec can't encode characters in position 2389-2397: ordinal not in range(128) #430

Closed magisk317 closed 1 year ago

magisk317 commented 1 year ago

提交 issue 前,请先确认:

表现
描述 BUG 的表现情况

运行环境:

复现步骤
描述你是如何触发这个 BUG 的

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

预期行为
描述你认为正常情况下应该看见的情况

截图

2023-03-26 20:13:58.361 | ERROR    | graia.ariadne.util:loguru_exc_callback:76 - Exception:
Traceback (most recent call last):

  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\bot.py", line 23, in <module>
    main()
    └ <function main at 0x00000000076D2CA0>

  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\platforms\ariadne_bot.py", line 299, in main
    app.launch_blocking()
    │   └ <classmethod(<function Ariadne.launch_blocking at 0x0000000005C2E0C0>)>
    └ <graia.ariadne.app.Ariadne object at 0x000000000570D050>

  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\python3.11\Lib\site-packages\graia\ariadne\app.py", line 312, in launch_blocking
    cls.launch_manager.launch_blocking(loop=cls.service.loop, stop_signal=stop_signals)
    │   │              │                    │   │       │                 └ (<Signals.SIGINT: 2>,)
    │   │              │                    │   │       └ <property object at 0x0000000005C1B7E0>
    │   │              │                    │   └ <graia.ariadne.service.ElizabethService object at 0x0000000005702A10>
    │   │              │                    └ <class 'graia.ariadne.app.Ariadne'>
    │   │              └ <function Launart.launch_blocking at 0x0000000005736840>
    │   └ <launart.manager.Launart object at 0x00000000076C2C10>
    └ <class 'graia.ariadne.app.Ariadne'>
  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\python3.11\Lib\site-packages\launart\manager.py", line 494, in launch_blocking
    loop.run_until_complete(launch_task)
    │    │                  └ <Task pending name='amnesia-launch' coro=<Launart.launch() running at D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\...
    │    └ <function BaseEventLoop.run_until_complete at 0x0000000003343560>
    └ <ProactorEventLoop running=True closed=False debug=False>

  File "asyncio\base_events.py", line 640, in run_until_complete
    sock.setblocking(False)

  File "asyncio\windows_events.py", line 321, in run_forever

  File "asyncio\base_events.py", line 607, in run_forever
    sock.close()

  File "asyncio\base_events.py", line 1922, in _run_once

  File "asyncio\events.py", line 80, in _run
    self._loop = loop
    │    └ <member '_loop' of 'Handle' objects>
    └ <Handle <TaskStepMethWrapper object at 0x00000000075E6A10>()>

> File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\python3.11\Lib\site-packages\graia\broadcast\__init__.py", line 191, in Executor
    result = await run_always_await(target_callable, **parameter_compile_result)
                   │                │                  └ {'app': <graia.ariadne.app.Ariadne object at 0x000000000570D050>, 'target': Friend(id=****, nickname='', remark='****...
                   │                └ <function friend_message_listener at 0x00000000076D25C0>
                   └ <function run_always_await at 0x0000000005764CC0>
  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\python3.11\Lib\site-packages\graia\broadcast\utilles.py", line 34, in run_always_await
    obj = await obj
                └ <coroutine object friend_message_listener at 0x00000000076E9AD0>

  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\platforms\ariadne_bot.py", line 144, in friend_message_listener
    await handle_message(
          └ <function handle_message at 0x00000000056B1580>

  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\universal.py", line 50, in handle_message
    conversation_handler.current_conversation = await conversation_handler.create(
    │                    │                            │                    └ <function ConversationHandler.create at 0x0000000007597BA0>
    │                    │                            └ <conversation.ConversationHandler object at 0x0000000007709210>
    │                    └ None
    └ <conversation.ConversationHandler object at 0x0000000007709210>

  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\conversation.py", line 227, in create
    conversation = ConversationContext(_type, self.session_id)
                   │                   │      │    └ 'friend-****'
                   │                   │      └ <conversation.ConversationHandler object at 0x0000000007709210>
                   │                   └ 'bing'
                   └ <class 'conversation.ConversationContext'>

  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\conversation.py", line 67, in __init__
    self.adapter = BingAdapter(self.session_id)
    │              │           │    └ 'friend-****'
    │              │           └ <conversation.ConversationContext object at 0x00000000076EFD50>
    │              └ <class 'adapter.ms.bing.BingAdapter'>
    └ <conversation.ConversationContext object at 0x00000000076EFD50>

  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\adapter\ms\bing.py", line 33, in __init__
    self.bot = EdgeChatbot(cookies=self.cookieData, proxy=account.proxy)
    │          │                   │    │                 │       └ 'http://127.0.0.1:1125'
    │          │                   │    │                 └ BingCookiePath(cookie_content='MUID=00BDB6B5F21C66950DA1A766F346670F; MUIDB=00BDB6B5F21C66950DA1A766F346670F; SRCHD=AF=NOFORM...
    │          │                   │    └ [{'name': 'MUID', 'value': '00BDB6B5F21C66950DA1A766F346670F'}, {'name': 'MUIDB', 'value': '00BDB6B5F21C66950DA1A766F346670F'...
    │          │                   └ <adapter.ms.bing.BingAdapter object at 0x00000000079EA510>
    │          └ <class 'EdgeGPT.Chatbot'>
    └ <adapter.ms.bing.BingAdapter object at 0x00000000079EA510>

  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\python3.11\Lib\site-packages\EdgeGPT.py", line 325, in __init__
    Conversation(self.cookiePath, self.cookies, self.proxy)
    │            │    │           │    │        │    └ 'http://127.0.0.1:1125'
    │            │    │           │    │        └ <EdgeGPT.Chatbot object at 0x00000000079EA990>
    │            │    │           │    └ [{'name': 'MUID', 'value': '00BDB6B5F21C66950DA1A766F346670F'}, {'name': 'MUIDB', 'value': '00BDB6B5F21C66950DA1A766F346670F'...
    │            │    │           └ <EdgeGPT.Chatbot object at 0x00000000079EA990>
    │            │    └ ''
    │            └ <EdgeGPT.Chatbot object at 0x00000000079EA990>
    └ <class 'EdgeGPT.Conversation'>
  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\python3.11\Lib\site-packages\EdgeGPT.py", line 217, in __init__
    response = self.session.get(
               │    │       └ <function Client.get at 0x0000000004A56B60>
               │    └ <httpx.Client object at 0x00000000079EA9D0>
               └ <EdgeGPT.Conversation object at 0x00000000079EA4D0>
  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\python3.11\Lib\site-packages\httpx\_client.py", line 1045, in get
    return self.request(
           │    └ <function Client.request at 0x0000000004A56700>
           └ <httpx.Client object at 0x00000000079EA9D0>
  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\python3.11\Lib\site-packages\httpx\_client.py", line 808, in request
    request = self.build_request(
              │    └ <function BaseClient.build_request at 0x0000000004A55D00>
              └ <httpx.Client object at 0x00000000079EA9D0>
  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\python3.11\Lib\site-packages\httpx\_client.py", line 360, in build_request
    return Request(
           └ <class 'httpx.Request'>
  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\python3.11\Lib\site-packages\httpx\_models.py", line 335, in __init__
    Cookies(cookies).set_cookie_header(self)
    │       │                          └ <Request('GET', 'https://edgeservices.bing.com/edgesvc/turing/conversation/create')>
    │       └ <Cookies[<Cookie MUID=00BDB6B5F21C66950DA1A766F346670F for  />, <Cookie MUIDB=00BDB6B5F21C66950DA1A766F346670F for  />, <Cook...
    └ <class 'httpx.Cookies'>
  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\python3.11\Lib\site-packages\httpx\_models.py", line 1045, in set_cookie_header
    self.jar.add_cookie_header(urllib_request)
    │    │   │                 └ <httpx._models.Cookies._CookieCompatRequest object at 0x00000000076EE310>
    │    │   └ <function CookieJar.add_cookie_header at 0x0000000003E5EDE0>
    │    └ <CookieJar[Cookie(version=0, name='MUID', value='00BDB6B5F21C66950DA1A766F346670F', port=None, port_specified=False, domain='...
    └ <Cookies[<Cookie MUID=00BDB6B5F21C66950DA1A766F346670F for  />, <Cookie MUIDB=00BDB6B5F21C66950DA1A766F346670F for  />, <Cook...

  File "http\cookiejar.py", line 1373, in add_cookie_header

  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\python3.11\Lib\site-packages\httpx\_models.py", line 1191, in add_unredirected_header
    self.request.headers[key] = value
    │    │       │       │      └ 'MUID=00BDB6B5F21C66950DA1A766F346670F; MUIDB=00BDB6B5F21C66950DA1A766F346670F; SRCHD=AF=NOFORM; SRCHUID=V=2&GUID=B2421DF91D4...
    │    │       │       └ 'Cookie'
    │    │       └ Headers({'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'authority': 'edgeservices.bing.com', 'accept': 'tex...
    │    └ <Request('GET', 'https://edgeservices.bing.com/edgesvc/turing/conversation/create')>
    └ <httpx._models.Cookies._CookieCompatRequest object at 0x00000000076EE310>
  File "D:\ROM\Windows-quickstart-refs.tags.v2.2.5-rc2\chatgpt\python3.11\Lib\site-packages\httpx\_models.py", line 235, in __setitem__
    set_value = value.encode(self._encoding or "utf-8")
                │     │      │    └ 'ascii'
                │     │      └ Headers({'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'authority': 'edgeservices.bing.com', 'accept': 'tex...
                │     └ <method 'encode' of 'str' objects>
                └ 'MUID=00BDB6B5F21C66950DA1A766F346670F; MUIDB=00BDB6B5F21C66950DA1A766F346670F; SRCHD=AF=NOFORM; SRCHUID=V=2&GUID=B2421DF91D4...

UnicodeEncodeError: 'ascii' codec can't encode characters in position 2389-2397: ordinal not in range(128)

其他内容
此处填写其他内容,没有可跳过

magisk317 commented 1 year ago

这是cookie的问题吗?还是编码的问题

lss233 commented 1 year ago

编码的问题, cookie 里面把有汉字的字段删了试试。

magisk317 commented 1 year ago

编码的问题, cookie 里面把有汉字的字段删了试试。

确实,删了就好了,多谢