yym68686/ChatGPT-Telegram-Bot

使用 o1-preview 时遇到错误

Closed this issue · 1 comments

如题,已经更新到最新版本,报错日志如下,不知道是我这里的问题还是bug……

first message len: 461
message_token {'total': 535} truncate_limit 100000
model_max_tokens 4096
api_url https://***/v1/chat/completions
api_key sk-**
{
    "model": "o1-preview",
    "messages": [
        {
            "role": "user",
            "content": "**。"
        }
    ]
}
发生了未预料的错误:Attempted to access streaming response content, without having called `read()`.
Traceback (most recent call last):
  File "/home/ChatGPT-Telegram-Bot/ModelMerge/src/ModelMerge/models/chatgpt.py", line 701, in ask_stream_async
    raise Exception(f"{response.status_code} {response.reason_phrase} {response.text[:400]}")
  File "/usr/local/lib/python3.10/site-packages/httpx/_models.py", line 578, in text
    content = self.content
  File "/usr/local/lib/python3.10/site-packages/httpx/_models.py", line 572, in content
    raise ResponseNotRead()
httpx.ResponseNotRead: Attempted to access streaming response content, without having called `read()`.

Traceback (most recent call last):
  File "/home/ChatGPT-Telegram-Bot/ModelMerge/src/ModelMerge/models/chatgpt.py", line 701, in ask_stream_async
    raise Exception(f"{response.status_code} {response.reason_phrase} {response.text[:400]}")
  File "/usr/local/lib/python3.10/site-packages/httpx/_models.py", line 578, in text
    content = self.content
  File "/usr/local/lib/python3.10/site-packages/httpx/_models.py", line 572, in content
    raise ResponseNotRead()
httpx.ResponseNotRead: Attempted to access streaming response content, without having called `read()`.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ChatGPT-Telegram-Bot/bot.py", line 243, in getChatGPT
    async for data in robot.ask_stream_async(text, convo_id=convo_id, pass_history=pass_history, model=model_name, language=language, api_url=api_url, api_key=api_key, system_prompt=system_prompt, plugins=plugins):
  File "/home/ChatGPT-Telegram-Bot/ModelMerge/src/ModelMerge/models/chatgpt.py", line 768, in ask_stream_async
    raise Exception(f"{e}")
Exception: Attempted to access streaming response content, without having called `read()`.




`Attempted to access streaming response content, without having called `read()`.`

你好,我已经修复了这个 bug,原因是在改进回复速度后,对于响应不是 200 的情况下,读取响应错误信息的时候,没有调用 await response.aread() 导致的。