poe-platform / fastapi_poe

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

"Internal Server Error" using `fp.get_bot_response` #48

Closed gregl83 closed 1 month ago

gregl83 commented 6 months ago

Following the get_bot_response example from the developer documentation returns "Internal Server Error" for all attempts.

Newly minted API Key was used.

Environment Details:

Stacktrace:

Error in Poe bot: Bot request to GPT-3.5-Turbo failed on try 0
 BotError('{"allow_retry": true, "text": "Internal server error"}')
Error in Poe bot: Bot request to GPT-3.5-Turbo failed on try 1
 BotError('{"allow_retry": true, "text": "Internal server error"}')
Traceback (most recent call last):
  File "C:\path\to\example.py", line 29, in <module>
    res = asyncio.run(
          ^^^^^^^^^^^^
  File "C:\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\asyncio\base_events.py", line 650, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\path\to\example.py", line 18, in get_responses
    async for partial in fp.get_bot_response(
  File "C:\Python311\Lib\site-packages\fastapi_poe\client.py", line 326, in stream_request
    async for message in stream_request_base(
  File "C:\Python311\Lib\site-packages\fastapi_poe\client.py", line 455, in stream_request_base
    async for message in ctx.perform_query_request(
  File "C:\Python311\Lib\contextlib.py", line 222, in __aexit__
    await self.gen.athrow(typ, value, traceback)
  File "C:\Python311\Lib\contextlib.py", line 222, in __aexit__
    await self.gen.athrow(typ, value, traceback)
  File "C:\Python311\Lib\site-packages\httpx\_client.py", line 1609, in stream
    yield response
  File "C:\Python311\Lib\site-packages\httpx_sse\_api.py", line 70, in aconnect_sse
    yield EventSource(response)
  File "C:\Python311\Lib\site-packages\fastapi_poe\client.py", line 224, in perform_query_request
    raise BotError(event.data)
fastapi_poe.client.BotError: {"allow_retry": true, "text": "Internal server error"}
YuiZ commented 5 months ago

A similar "Internal server error" encountered when calling image generation Bot such as "StableDiffusionXL". It worked well a week ago but crashed recently.

I could receive the first two partial respones ("Generating image (1s elapsed)..."), but it would certainly crash on the third partial response. However, "GPT-3.5-Turbo" and "GPT-4" works well in my case.

I've also tried to use a newly generated API key, which makes no difference.

Env:

Part of the staketrace:

text='Generating image (1s elapsed)' data=None raw_response={'type': 'replace_response', 'text': '{"text": "Generating image (1s elapsed)"}'} full_prompt="QueryRequest(version='1.0', type='query', query=[ProtocolMessage(role='user', content='In a black-white sketch style. Introduction to Lake Kivu and its hidden dangers beneath a peaceful surface.', content_type='text/markdown', timestamp=0, message_id='', feedback=[], attachments=[])], user_id='', conversation_id='', message_id='', metadata='', api_key='<missing>', access_key='<missing>', temperature=0.7, skip_system_prompt=False, logit_bias={}, stop_sequences=[])" request_id=None is_suggested_reply=False is_replace_response=True
text='Generating image (2s elapsed)' data=None raw_response={'type': 'replace_response', 'text': '{"text": "Generating image (2s elapsed)"}'} full_prompt="QueryRequest(version='1.0', type='query', query=[ProtocolMessage(role='user', content='In a black-white sketch style. Introduction to Lake Kivu and its hidden dangers beneath a peaceful surface.', content_type='text/markdown', timestamp=0, message_id='', feedback=[], attachments=[])], user_id='', conversation_id='', message_id='', metadata='', api_key='<missing>', access_key='<missing>', temperature=0.7, skip_system_prompt=False, logit_bias={}, stop_sequences=[])" request_id=None is_suggested_reply=False is_replace_response=True
Error in Poe bot: Bot request to StableDiffusionXL failed on try 0 
 BotError('{"allow_retry": true, "text": "Internal server error"}')

...

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fastapi_poe/client.py", line 326, in stream_request
    async for message in stream_request_base(
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fastapi_poe/client.py", line 455, in stream_request_base
    async for message in ctx.perform_query_request(
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fastapi_poe/client.py", line 224, in perform_query_request
    raise BotError(event.data)
fastapi_poe.client.BotError: {"allow_retry": true, "text": "Internal server error"}

Looking forward to a solution, thanks :)

iamshaynez commented 4 months ago

Have exactly same issue, upgraded to 0.0.34.

PeterChen1997 commented 4 months ago

the same problem. is the api been blocked?

PeterChen1997 commented 4 months ago

Oh, I got it. the token is wrong...

iamshaynez commented 4 months ago

The original issue sounds like resolved. #70 replied here.