Skip to content

Commit

Permalink
Add gpt-4-1106-preview (gpt-4-turbo) to model list
Browse files Browse the repository at this point in the history
  • Loading branch information
jepler committed Nov 9, 2023
1 parent 4454071 commit 1e856e4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/chap/backends/openai_chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import functools
import json
import warnings
from dataclasses import dataclass
from typing import AsyncGenerator, cast

Expand Down Expand Up @@ -36,16 +37,20 @@ def num_tokens_for_messages(self, messages: Session) -> int:
@functools.cache
def from_model(cls, model: str) -> "EncodingMeta":
if model == "gpt-3.5-turbo":
# print("Warning: gpt-3.5-turbo may update over time. Returning num tokens assuming gpt-3.5-turbo-0613.")
warnings.warn(
"Warning: gpt-3.5-turbo may update over time. Returning num tokens assuming gpt-3.5-turbo-0613."
)
model = "gpt-3.5-turbo-0613"
if model == "gpt-4":
# print("Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613.")
warnings.warn(
"Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613."
)
model = "gpt-4-0613"

try:
encoding = tiktoken.encoding_for_model(model)
except KeyError:
print("Warning: model not found. Using cl100k_base encoding.")
warnings.warn("Warning: model not found. Using cl100k_base encoding.")
encoding = tiktoken.get_encoding("cl100k_base")

if model in {
Expand All @@ -55,6 +60,7 @@ def from_model(cls, model: str) -> "EncodingMeta":
"gpt-4-32k-0314",
"gpt-4-0613",
"gpt-4-32k-0613",
"gpt-4-1106-preview",
}:
tokens_per_message = 3
tokens_per_name = 1
Expand Down

0 comments on commit 1e856e4

Please sign in to comment.