From ab63bbcb4baa8bf925cb45d909f634efd1c48fad Mon Sep 17 00:00:00 2001 From: yym68686 Date: Tue, 7 Nov 2023 19:14:44 +0800 Subject: [PATCH] Add support for gpt-4-1106-preview model. --- bot.py | 9 +++++---- chatgpt2api/chatgpt2api.py | 9 +++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index 05999345..3991643f 100644 --- a/bot.py +++ b/bot.py @@ -169,10 +169,11 @@ async def delete_message(update, context, messageid, delay=10): InlineKeyboardButton("gpt-4-32k", callback_data="gpt-4-32k"), # InlineKeyboardButton("gpt-4-0314", callback_data="gpt-4-0314"), ], - # [ - # InlineKeyboardButton("gpt-4-32k", callback_data="gpt-4-32k"), - # InlineKeyboardButton("gpt-4-32k-0314", callback_data="gpt-4-32k-0314"), - # ], + [ + InlineKeyboardButton("gpt-4-1106-preview", callback_data="gpt-4-1106-preview"), + # InlineKeyboardButton("gpt-4-32k", callback_data="gpt-4-32k"), + # InlineKeyboardButton("gpt-4-32k-0314", callback_data="gpt-4-32k-0314"), + ], # [ # InlineKeyboardButton("gpt-4-0613", callback_data="gpt-4-0613"), # InlineKeyboardButton("gpt-4-32k-0613", callback_data="gpt-4-32k-0613"), diff --git a/chatgpt2api/chatgpt2api.py b/chatgpt2api/chatgpt2api.py index 38132f33..21c10739 100644 --- a/chatgpt2api/chatgpt2api.py +++ b/chatgpt2api/chatgpt2api.py @@ -49,6 +49,7 @@ def get_filtered_keys_from_object(obj: object, *keys: str) -> Set[str]: "gpt-4-32k-0314", "gpt-4-0613", "gpt-4-32k-0613", + "gpt-4-1106-preview", "claude-2-web", "claude-2", ] @@ -81,7 +82,9 @@ def __init__( self.api_key: str = api_key self.system_prompt: str = system_prompt self.max_tokens: int = max_tokens or ( - 31000 + 4000 + if "gpt-4-1106-preview" in engine + else 31000 if "gpt-4-32k" in engine else 7000 if "gpt-4" in engine @@ -92,7 +95,9 @@ def __init__( else 4000 ) self.truncate_limit: int = truncate_limit or ( - 30500 + 126500 + if "gpt-4-1106-preview" in engine + else 30500 if "gpt-4-32k" in engine else 6500 if "gpt-4" in engine