Skip to content

Commit 3291cf5

Browse files
committed
Switch to gpt-4-turbo by default
1 parent 646bfe0 commit 3291cf5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/gptcmd/message.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ def __init__(
155155
self.stream: bool = False
156156
if model is None:
157157
models = self._openai.models.list().data
158-
if self._is_valid_model("gpt-4", models=models):
158+
if self._is_valid_model("gpt-4-turbo", models=models):
159+
self.model = "gpt-4-turbo"
160+
elif self._is_valid_model("gpt-4", models=models):
159161
self.model = "gpt-4"
160162
elif self._is_valid_model("gpt-3.5-turbo", models=models):
161163
self.model = "gpt-3.5-turbo"
@@ -230,7 +232,11 @@ def cost_cents(self) -> int:
230232
raise CostEstimateUnavailableError(
231233
"Unable to calculate token usage"
232234
)
233-
if self.model.startswith("gpt-4"):
235+
if self.model.startswith("gpt-4-turbo"):
236+
return (1 * (self.prompt_tokens // 1000)) + (
237+
3 * (self.sampled_tokens // 1000)
238+
)
239+
elif self.model.startswith("gpt-4"):
234240
return (3 * (self.prompt_tokens // 1000)) + (
235241
6 * (self.sampled_tokens // 1000)
236242
)
@@ -368,6 +374,7 @@ def _post_send(self, resp, stream_cls: Type[S]) -> Union[Message, S]:
368374
if resp.model not in (
369375
"gpt-4-0314",
370376
"gpt-4-0613",
377+
"gpt-4-turbo-2024-04-09",
371378
) and resp.model.startswith("gpt-4"):
372379
self.prompt_tokens = None
373380
self.sampled_tokens = None

0 commit comments

Comments
 (0)