Aedial / novelai-api

Python API for the NovelAI REST API
https://aedial.github.io/novelai-api/
MIT License
129 stars 17 forks source link

Got the UnicodeDecodeError: 'utf-8' with /ai/generate-image #16

Closed Tand0 closed 1 year ago

Tand0 commented 1 year ago
D:\gitwork\test>python test.py
Traceback (most recent call last):
  File "D:\gitwork\test\test.py", line 89, in <module>
    run(main())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
  File "D:\gitwork\test\test.py", line 83, in main
    async for _, img in api.high_level.generate_image("1girl", ImageModel.Anime_Full, preset):
  File "C:\Users\PC_User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\novelai_api\_high_level.py", line 355, in generate_image
    async for e in self._parent.low_level.generate_image(prompt, model, settings):
  File "C:\Users\PC_User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\novelai_api\_low_level.py", line 621, in generate_image
    async for rsp, content in self.request_stream("post", "/ai/generate-image", args):
  File "C:\Users\PC_User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\novelai_api\_low_level.py", line 161, in request_stream
    raise e
  File "C:\Users\PC_User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\novelai_api\_low_level.py", line 158, in request_stream
    async for i in self._request(method, url, session, data, stream):
  File "C:\Users\PC_User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\novelai_api\_low_level.py", line 136, in _request
    yield rsp, await self._treat_response_stream(rsp, content)
  File "C:\Users\PC_User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\novelai_api\_low_level.py", line 88, in _treat_response_stream
    data = data.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaa in position 11: invalid start byte

D:\gitwork\test>
Aedial commented 1 year ago

Looking at the callstack, you're using an older version of the project. The NAI API underwent some breaking changes as of last update, update your package.