mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-19 21:55:06 +01:00
gpt-4 model support
This commit is contained in:
@@ -172,7 +172,7 @@ class OpenAIHelper:
|
||||
return response.choices[0]['message']['content']
|
||||
|
||||
def __max_model_tokens(self):
|
||||
if self.config['model'] == "gpt-3.5-turbo" or self.config['model'] == "gpt-3.5-turbo-0301":
|
||||
if self.config['model'] in ("gpt-3.5-turbo","gpt-3.5-turbo-0301","gpt-4"):
|
||||
return 4096
|
||||
raise NotImplementedError(
|
||||
f"Max tokens for model {self.config['model']} is not implemented yet."
|
||||
@@ -190,7 +190,7 @@ class OpenAIHelper:
|
||||
encoding = tiktoken.encoding_for_model(model)
|
||||
except KeyError:
|
||||
encoding = tiktoken.get_encoding("gpt-3.5-turbo")
|
||||
if model == "gpt-3.5-turbo" or model == "gpt-3.5-turbo-0301":
|
||||
if model in ("gpt-3.5-turbo", "gpt-3.5-turbo-0301", "gpt-4"):
|
||||
num_tokens = 0
|
||||
for message in messages:
|
||||
num_tokens += 4 # every message follows <im_start>{role/name}\n{content}<im_end>\n
|
||||
|
||||
Reference in New Issue
Block a user