mirror of
https://github.com/hwchase17/langchain
synced 2024-11-04 06:00:26 +00:00
update get_num_tokens_from_messages model (#8431)
(#8430) Co-authored-by: Kano Kunihiko <kkano@heroz.co.jp>
This commit is contained in:
parent
e0de62f6da
commit
abe4c361f9
@ -550,12 +550,12 @@ class ChatOpenAI(BaseChatModel):
|
||||
if sys.version_info[1] <= 7:
|
||||
return super().get_num_tokens_from_messages(messages)
|
||||
model, encoding = self._get_encoding_model()
|
||||
if model.startswith("gpt-3.5-turbo"):
|
||||
if model.startswith("gpt-3.5-turbo-0301"):
|
||||
# every message follows <im_start>{role/name}\n{content}<im_end>\n
|
||||
tokens_per_message = 4
|
||||
# if there's a name, the role is omitted
|
||||
tokens_per_name = -1
|
||||
elif model.startswith("gpt-4"):
|
||||
elif model.startswith("gpt-3.5-turbo") or model.startswith("gpt-4"):
|
||||
tokens_per_message = 3
|
||||
tokens_per_name = 1
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user