poe-platform / fastapi_poe

A helper library for writing Poe API bots using FastAPI
Apache License 2.0
112 stars 21 forks source link

BotError('{"allow_retry": true, "text": "Internal server error"}') with Image Generation Bots #70

Closed iamshaynez closed 3 months ago

iamshaynez commented 4 months ago

I created this issue because original #48 is not same. Althought the comments in #48 mentioned.

It might not be the issue of fastapi_poe but maybe the poe backend bot service. However there is no other place for reporting the issue, so...please help.

Tried using stream_request, directly using fp.get_final_response. Works with LLM bots, however always return internal server error with Image Generation bots(SDXL, Playground-v2, or customed bots with these models).

If using stream_request and yield the msg in real time. You can see first 1 or 2 'Generating image (1s elapsed)...' rendered and then goes to error.

Example: Python 3.11, fastapi_poe 0.0.34

final_message = await fp.get_final_response(request, bot_name=IMAGE_MODEL, api_key=request.access_key)

Error as:

Error in Poe bot: Bot request to ComicBookStyle-PGV2 failed on try 0 
 BotError('{"allow_retry": true, "text": "Internal server error"}')
Error responding to query
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/fastapi_poe/base.py", line 381, in handle_query
    async for event in self.get_response_with_context(request, context):
  File "/usr/local/lib/python3.11/site-packages/fastapi_poe/base.py", line 111, in get_response_with_context
    async for event in self.get_response(request):
  File "/root/memes_creator.py", line 39, in get_response
    final_message = await fp.get_final_response(request, bot_name=IMAGE_MODEL, api_key=request.access_key)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/fastapi_poe/client.py", line 544, in get_final_response
    async for message in stream_request(
  File "/usr/local/lib/python3.11/site-packages/fastapi_poe/client.py", line 327, in stream_request
    async for message in stream_request_base(
  File "/usr/local/lib/python3.11/site-packages/fastapi_poe/client.py", line 456, in stream_request_base
    async for message in ctx.perform_query_request(
  File "/usr/local/lib/python3.11/contextlib.py", line 222, in __aexit__
    await self.gen.athrow(typ, value, traceback)
  File "/usr/local/lib/python3.11/contextlib.py", line 222, in __aexit__
    await self.gen.athrow(typ, value, traceback)
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1624, in stream
    yield response
  File "/usr/local/lib/python3.11/site-packages/httpx_sse/_api.py", line 70, in aconnect_sse
    yield EventSource(response)
  File "/usr/local/lib/python3.11/site-packages/fastapi_poe/client.py", line 225, in perform_query_request
    raise BotError(event.data)
fastapi_poe.client.BotError: {"allow_retry": true, "text": "Internal server error"}
krisyang1125 commented 4 months ago

This seems to work now, can you help confirm if the issue is addressed on your end as well?

iamshaynez commented 4 months ago

Thanks, I confirm now image generation bots can be called from fastapi_poe!

JohntheLi commented 3 months ago

closing, seems like the issue is resolved from conversation