n3d1117 / chatgpt-telegram-bot

🤖 A Telegram bot that integrates with OpenAI's official ChatGPT APIs to provide answers, written in Python
GNU General Public License v2.0
3k stars 1.38k forks source link

NotImplementedError: num_tokens_from_messages() is not implemented for model #344

Closed Jake-double-one closed 1 year ago

Jake-double-one commented 1 year ago

Hey, I tried different models due to today's OpenAI's announcements,

I get the below shown error messages in the container with these models: gpt-3.5-turbo-16k gpt-3.5-turbo-0613 gpt-3.5-turbo-16k-0613 ...

gpt-3.5-turbo still works fine for me! I cannot test gpt-4 yet.

2023-06-14 13:38:44,116 - root - ERROR - ⚠️ _Ein Fehler ist aufgetreten._ ⚠️
num_tokens_from_messages() is not implemented for model gpt-3.5-turbo-16k-0613.
Traceback (most recent call last):
  File "/app/bot/openai_helper.py", line 154, in __common_get_chat_response
    token_count = self.__count_tokens(self.conversations[chat_id])
  File "/app/bot/openai_helper.py", line 305, in __count_tokens
    raise NotImplementedError(f"""num_tokens_from_messages() is not implemented for model {model}.""")
NotImplementedError: num_tokens_from_messages() is not implemented for model gpt-3.5-turbo-16k-0613.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/bot/telegram_bot.py", line 427, in prompt
    async for content, tokens in stream_response:
  File "/app/bot/openai_helper.py", line 118, in get_chat_response_stream
    response = await self.__common_get_chat_response(chat_id, query, stream=True)
  File "/app/bot/openai_helper.py", line 188, in __common_get_chat_response
    raise Exception(f"⚠️ _{localized_text('error', bot_language)}._ ⚠️\n{str(e)}") from e
Exception: ⚠️ _Ein Fehler ist aufgetreten._ ⚠️
num_tokens_from_messages() is not implemented for model gpt-3.5-turbo-16k-0613.
n3d1117 commented 1 year ago

Hey, pull from the main branch please, the fix was added a few hours ago!

Jake-double-one commented 1 year ago

As a normal Synology user, I am only able to download releases. The Synology is too limited when it comes to 'fiddling around', and I'm not aware of the mounting directories. I will wait for the next release then.

Thank you for resolving the problem, though. :-)

n3d1117 commented 1 year ago

All good! I'll release a new version with the new models soon, and work on integrating plugins for the next one!

n3d1117 commented 1 year ago

@Jake-double-one v0.2.6 is available now! You should be able to use the new models if you update the image and its dependencies

Jake-double-one commented 1 year ago

Awesome man! Works now "as intended". <3