From d07ac7bf0ec918b0da413b0bec545ba7cf1e6a73 Mon Sep 17 00:00:00 2001 From: zchk0 Date: Wed, 5 Jun 2024 20:55:40 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=B8=20?= =?UTF-8?q?=D0=B8=D0=B3=D0=BD=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- translations.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translations.json b/translations.json index e13198ba..414cd23b 100644 --- a/translations.json +++ b/translations.json @@ -644,9 +644,9 @@ "stats_description":"Получить статистику использования", "resend_description":"Повторная отправка последнего сообщения", "chat_description":"Общайся с ботом!", - "disallowed":"Извини, тебе запрещено использовать этого бота. Исходный код можно найти здесь https://github.com/n3d1117/chatgpt-telegram-bot", + "disallowed":"хе-хе-хе тебе никто не разрешал использовать меня :)", "budget_limit":"Извини, ты достиг предела использования", - "help_text":["Я бот ChatGPT, поговори со мной!", "Пришли мне голосовое сообщение или файл, и я сделаю тебе расшифровку", "Открытый исходный код на https://github.com/n3d1117/chatgpt-telegram-bot"], + "help_text":["Я бот ChatGPT, поговори со мной!", "Пришли мне голосовое сообщение или файл, и я сделаю тебе расшифровку", "*тык*"], "stats_conversation":["Текущий разговор", "сообщения в истории", "токены чата в истории"], "usage_today":"Использование сегодня", "usage_month":"Использование в этом месяце", From e065a75b7e1aa945db0bd3138f9815c2f72447b0 Mon Sep 17 00:00:00 2001 From: zchk0 Date: Wed, 5 Jun 2024 20:57:29 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=B8=20?= =?UTF-8?q?=D0=B8=D0=B3=D0=BD=D0=BE=D1=80=D0=B0=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a156be6a..dcbd7cc1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ __pycache__ /usage_logs venv /.cache +translations.json From 867547f24ea8e367449eca85951ffe137f8c1516 Mon Sep 17 00:00:00 2001 From: zchk0 Date: Thu, 31 Oct 2024 09:44:13 +0000 Subject: [PATCH 3/4] bump version --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 520d28da..f73cf55f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ python-dotenv~=1.0.0 pydub~=0.25.1 -tiktoken==0.7.0 -openai==1.29.0 +tiktoken==0.8.0 +openai==1.45.0 python-telegram-bot==21.1.1 requests~=2.31.0 tenacity==8.3.0 From 0edbc51293b6919de9309fc2b77145012d0485dd Mon Sep 17 00:00:00 2001 From: zchk0 Date: Sun, 10 Nov 2024 20:38:40 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20tiktoken=20?= =?UTF-8?q?=D0=B8=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8=20=D1=80=D0=B0?= =?UTF-8?q?=D1=81=D0=BF=D0=BE=D0=B7=D0=BD=D0=B0=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot/main.py | 2 +- bot/openai_helper.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bot/main.py b/bot/main.py index 8e0118d2..7c118ca8 100644 --- a/bot/main.py +++ b/bot/main.py @@ -53,7 +53,7 @@ def main(): 'bot_language': os.environ.get('BOT_LANGUAGE', 'en'), 'show_plugins_used': os.environ.get('SHOW_PLUGINS_USED', 'false').lower() == 'true', 'whisper_prompt': os.environ.get('WHISPER_PROMPT', ''), - 'vision_model': os.environ.get('VISION_MODEL', 'gpt-4-vision-preview'), + 'vision_model': os.environ.get('VISION_MODEL', 'gpt-4o'), 'enable_vision_follow_up_questions': os.environ.get('ENABLE_VISION_FOLLOW_UP_QUESTIONS', 'true').lower() == 'true', 'vision_prompt': os.environ.get('VISION_PROMPT', 'What is in this image'), 'vision_detail': os.environ.get('VISION_DETAIL', 'auto'), diff --git a/bot/openai_helper.py b/bot/openai_helper.py index 5a1896cf..bce896f3 100644 --- a/bot/openai_helper.py +++ b/bot/openai_helper.py @@ -26,9 +26,9 @@ GPT_3_16K_MODELS = ("gpt-3.5-turbo-16k", "gpt-3.5-turbo-16k-0613", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-0125") GPT_4_MODELS = ("gpt-4", "gpt-4-0314", "gpt-4-0613", "gpt-4-turbo-preview") GPT_4_32K_MODELS = ("gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-0613") -GPT_4_VISION_MODELS = ("gpt-4-vision-preview",) +GPT_4_VISION_MODELS = ("gpt-4-vision-preview", "gpt-4o") GPT_4_128K_MODELS = ("gpt-4-1106-preview","gpt-4-0125-preview","gpt-4-turbo-preview", "gpt-4-turbo", "gpt-4-turbo-2024-04-09") -GPT_4O_MODELS = ("gpt-4o",) +GPT_4O_MODELS = ("gpt-4o","gpt-4o-mini") GPT_ALL_MODELS = GPT_3_MODELS + GPT_3_16K_MODELS + GPT_4_MODELS + GPT_4_32K_MODELS + GPT_4_VISION_MODELS + GPT_4_128K_MODELS + GPT_4O_MODELS def default_max_tokens(model: str) -> int: @@ -652,8 +652,8 @@ def __count_tokens(self, messages) -> int: model = self.config['model'] try: encoding = tiktoken.encoding_for_model(model) - except KeyError: - encoding = tiktoken.get_encoding("gpt-3.5-turbo") + except KeyError: # было gpt-3.5-turbo фикс на cl100k_base или p50k_base https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb + encoding = tiktoken.get_encoding("cl100k_base") if model in GPT_3_MODELS + GPT_3_16K_MODELS: tokens_per_message = 4 # every message follows <|start|>{role/name}\n{content}<|end|>\n