Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update for the gpt-4-turbo-preview #432

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bot/openai_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

class ChatGPT:
def __init__(self, model="gpt-3.5-turbo"):
assert model in {"text-davinci-003", "gpt-3.5-turbo-16k", "gpt-3.5-turbo", "gpt-4", "gpt-4-1106-preview"}, f"Unknown model: {model}"
assert model in {"text-davinci-003", "gpt-3.5-turbo-16k", "gpt-3.5-turbo", "gpt-4", "gpt-4-turbo-preview"}, f"Unknown model: {model}"
self.model = model

async def send_message(self, message, dialog_messages=[], chat_mode="assistant"):
Expand All @@ -33,7 +33,7 @@ async def send_message(self, message, dialog_messages=[], chat_mode="assistant")
answer = None
while answer is None:
try:
if self.model in {"gpt-3.5-turbo-16k", "gpt-3.5-turbo", "gpt-4", "gpt-4-1106-preview"}:
if self.model in {"gpt-3.5-turbo-16k", "gpt-3.5-turbo", "gpt-4", "gpt-4-turbo-preview"}:
messages = self._generate_prompt_messages(message, dialog_messages, chat_mode)
r = await openai.ChatCompletion.acreate(
model=self.model,
Expand Down Expand Up @@ -73,7 +73,7 @@ async def send_message_stream(self, message, dialog_messages=[], chat_mode="assi
answer = None
while answer is None:
try:
if self.model in {"gpt-3.5-turbo-16k", "gpt-3.5-turbo", "gpt-4", "gpt-4-1106-preview"}:
if self.model in {"gpt-3.5-turbo-16k", "gpt-3.5-turbo", "gpt-4", "gpt-4-turbo-preview"}:
messages = self._generate_prompt_messages(message, dialog_messages, chat_mode)
r_gen = await openai.ChatCompletion.acreate(
model=self.model,
Expand Down Expand Up @@ -161,7 +161,7 @@ def _count_tokens_from_messages(self, messages, answer, model="gpt-3.5-turbo"):
elif model == "gpt-4":
tokens_per_message = 3
tokens_per_name = 1
elif model == "gpt-4-1106-preview":
elif model == "gpt-4-turbo-preview":
tokens_per_message = 3
tokens_per_name = 1
else:
Expand Down
16 changes: 11 additions & 5 deletions config/models.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
available_text_models: ["gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-4-1106-preview", "gpt-4", "text-davinci-003"]
available_text_models: [
"gpt-3.5-turbo",
# "gpt-3.5-turbo-16k",
"gpt-4-turbo-preview",
# "gpt-4",
]

info:
gpt-3.5-turbo:
type: chat_completion
name: ChatGPT
name: ChatGPT 3.5 Turbo
description: ChatGPT is that well-known model. It's <b>fast</b> and <b>cheap</b>. Ideal for everyday tasks. If there are some tasks it can't handle, try the <b>GPT-4</b>.

price_per_1000_input_tokens: 0.0015
Expand All @@ -27,6 +32,7 @@ info:
Fast: 5
Cheap: 5

# Info here https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo
gpt-4:
type: chat_completion
name: GPT-4
Expand All @@ -40,9 +46,9 @@ info:
Fast: 2
Cheap: 2

gpt-4-1106-preview:
gpt-4-turbo-preview:
type: chat_completion
name: GPT-4 Turbo
name: GPT-4 Turbo Preview
description: GPT-4 Turbo is a <b>faster</b> and <b>cheaper</b> version of GPT-4. It's as smart as GPT-4, so you should use it instead of GPT-4.

price_per_1000_input_tokens: 0.01
Expand Down Expand Up @@ -72,4 +78,4 @@ info:

whisper:
type: audio
price_per_1_min: 0.006
price_per_1_min: 0.006