poe-platform / server-bot-quick-start

Tutorial for Poe server bots
1.31k stars 192 forks source link

Message called on bot that has 0 or undefined call count in settings. #60

Closed marsnebulasoup closed 9 months ago

marsnebulasoup commented 9 months ago

Attempting to set up this repo with Poe, but I keep getting this error when I try to run any models. I haven't changed any code in the example, so I'm a bit confused as to why this is happening.

I get this error in Modal when I deploy and try to send any message.

Error in Poe bot: Bot request to GPT-3.5-Turbo failed on try 1 
 BotError('{"allow_retry": true, "text": "Message m-000000xy92lvkqap8y0ljx2d0d4ko5mb called on bot that has 0 or undefined call count in settings."}')
Error responding to query
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/fastapi_poe/base.py", line 181, in handle_query
    async for event in self.get_response(request):
  File "/root/turbo_allcapsbot.py", line 24, in get_response
    async for msg in stream_request(request, "GPT-3.5-Turbo", request.access_key):
  File "/usr/local/lib/python3.10/site-packages/fastapi_poe/client.py", line 307, in stream_request
    async for message in ctx.perform_query_request(request):
  File "/usr/local/lib/python3.10/site-packages/fastapi_poe/client.py", line 209, in perform_query_request
    raise BotError(event.data)
fastapi_poe.client.BotError: {"allow_retry": true, "text": "Message m-000000xy92lvkqap8y0ljx2d0d4ko5mb called on bot that has 0 or undefined call count in settings."}

I don't understand why it's saying the bot has a 0 or undefined call count, when it's clearly defined in the settings. I'm running the GPT35TurboAllCapsBot:

"""

Sample bot that wraps GPT-3.5-Turbo but makes responses use all-caps.

"""
from __future__ import annotations

from typing import AsyncIterable

from fastapi_poe import PoeBot
from fastapi_poe.client import stream_request
from fastapi_poe.types import (
    PartialResponse,
    QueryRequest,
    SettingsRequest,
    SettingsResponse,
)

class GPT35TurboAllCapsBot(PoeBot):
    async def get_response(
        self, request: QueryRequest
    ) -> AsyncIterable[PartialResponse]:
        async for msg in stream_request(request, "GPT-3.5-Turbo", request.access_key):
            yield msg.model_copy(update={"text": msg.text.upper()})

    async def get_settings(self, setting: SettingsRequest) -> SettingsResponse:
        return SettingsResponse(server_bot_dependencies={"GPT-3.5-Turbo": 1})

If anyone could assist with this, that would be great.

Thanks

marsnebulasoup commented 9 months ago

It appears that this is because Poe fetches the bot's settings one time only, when your bot is created. So, any new deploys don't work (if you change the models listed in server_bot_dependencies). This can be refreshed by setting the bot as public, saving, then making it private again, since it appears this triggers a settings refetch.

image

I guess this would have to be done every time you change the server_bot_dependencies, but otherwise, deploys should work fine.

Additionally, it seems to help to change the call count for certain models and redeploy in some cases. This seems to trigger some refresh. For example, changing it from 10 to 1 then attempting to send a message and if it works change it back to 10 again.

    async def get_settings(self, setting: SettingsRequest) -> SettingsResponse:
        return SettingsResponse(server_bot_dependencies={"Claude-2-100k": 10}) 👈 this
anmolsingh95 commented 9 months ago

The way to manually update your bot's settings is documented here: https://developer.poe.com/server-bots/updating-bot-settings