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

Add support for GPT-4o #131

Open
wants to merge 3 commits 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
1 change: 1 addition & 0 deletions mindflow/cli/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def configure_query_model():
model_ids = [
ModelID.GPT_3_5_TURBO.value,
ModelID.GPT_4.value,
ModelID.GPT_4_O.value
]
model_options: List[Model] = [Model.load(model_id) for model_id in model_ids]
model_descriptions: List[str] = [
Expand Down
20 changes: 18 additions & 2 deletions mindflow/core/types/definitions/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class ModelID(Enum):
GPT_4_32K = "gpt-4-32k"
GPT_4_32K_0314 = "gpt-4-32k-0314"

GPT_4_O = "gpt-4o"

CLAUDE_V1 = "claude-v1"
CLAUDE_V1_2 = "claude-v1.2"
CLAUDE_INSTANT_V1 = "claude-instant-v1"
Expand All @@ -52,7 +54,7 @@ class ModelID(Enum):
ModelParameterKey.MAX_TOKENS_PER_MINUTE.value: 40_000,
ModelParameterKey.TOKEN_COST.value: 0.002,
ModelParameterKey.TOKEN_COST_UNIT.value: 1_000,
ModelParameterKey.CONFIG_DESCRIPTION.value: f"GPT 3.5 Turbo: OpenAI's Fast, cheap, and still powerful model. Token Limit: {4_000}.",
ModelParameterKey.CONFIG_DESCRIPTION.value: f"GPT 3.5 Turbo: OpenAI's Fast, cheap, and still powerful model. Token Limit: {4_000}.",
},
ModelID.GPT_3_5_TURBO_0301.value: {
ModelParameterKey.ID.value: ModelID.GPT_3_5_TURBO_0301.value,
Expand All @@ -79,7 +81,7 @@ class ModelID(Enum):
ModelParameterKey.MAX_TOKENS_PER_MINUTE.value: 40_000,
ModelParameterKey.TOKEN_COST.value: 0.002,
ModelParameterKey.TOKEN_COST_UNIT.value: 1_000,
ModelParameterKey.CONFIG_DESCRIPTION.value: f"GPT 4: OpenAI's most powerful model (slower + expensive). Token Limit: {str(8192)}. Get access -> https://openai.com/waitlist/gpt-4-api.",
ModelParameterKey.CONFIG_DESCRIPTION.value: f"GPT 4: OpenAI's previous high intelligence model (slower + expensive). Token Limit: {str(8192)}.",
},
ModelID.GPT_4_0314.value: {
ModelParameterKey.ID.value: ModelID.GPT_4_0314.value,
Expand Down Expand Up @@ -120,6 +122,20 @@ class ModelID(Enum):
ModelParameterKey.TOKEN_COST.value: 0.002,
ModelParameterKey.TOKEN_COST_UNIT.value: 1_000,
},
ModelID.GPT_4_O.value: {
ModelParameterKey.ID.value: ModelID.GPT_4_O.value,
ModelParameterKey.NAME.value: "GPT 4o",
ModelParameterKey.SERVICE.value: "openai",
ModelParameterKey.MODEL_TYPE.value: ModelType.TEXT_COMPLETION.value,
ModelParameterKey.URL.value: "https://api.openai.com/v1/chat/completions",
ModelParameterKey.DEFAULT_SOFT_TOKEN_LIMIT.value: 5000,
ModelParameterKey.HARD_TOKEN_LIMIT.value: 128_000,
ModelParameterKey.MAX_REQUESTS_PER_MINUTE.value: 3_500,
ModelParameterKey.MAX_TOKENS_PER_MINUTE.value: 90_000,
ModelParameterKey.TOKEN_COST.value: 0.002,
ModelParameterKey.TOKEN_COST_UNIT.value: 1_000,
ModelParameterKey.CONFIG_DESCRIPTION.value: f"GPT 4o: OpenAI's fasted and most affordable flagship model. Token Limit: {str(128_000)}.",
},
ModelID.TEXT_EMBEDDING_ADA_002.value: {
ModelParameterKey.ID.value: ModelID.TEXT_EMBEDDING_ADA_002.value,
ModelParameterKey.NAME.value: "Text Embedding Ada 002",
Expand Down
4 changes: 2 additions & 2 deletions mindflow/core/types/mindflow_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def index(self) -> ConfiguredTextCompletionModel:
MindFlowModelID.INDEX.value, mindflow_model.defaults
)

if model_id in [ModelID.GPT_3_5_TURBO.value, ModelID.GPT_4.value]:
if model_id in [ModelID.GPT_3_5_TURBO.value, ModelID.GPT_4.value, ModelID.GPT_4_O.value]:
return ConfiguredOpenAIChatCompletionModel(model_id)
raise Exception("Unsupported model: " + model_id)

Expand All @@ -69,7 +69,7 @@ def query(self) -> ConfiguredTextCompletionModel:
MindFlowModelID.QUERY.value, mindflow_model.defaults
)

if model_id in [ModelID.GPT_3_5_TURBO.value, ModelID.GPT_4.value]:
if model_id in [ModelID.GPT_3_5_TURBO.value, ModelID.GPT_4.value, ModelID.GPT_4_O.value]:
return ConfiguredOpenAIChatCompletionModel(model_id)
raise Exception("Unsupported model: " + model_id)

Expand Down
3 changes: 2 additions & 1 deletion mindflow/core/types/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def __init__(self, model_id: str):

try:
if self.model.service == ServiceID.OPENAI.value:
if self.model.id == ModelID.GPT_4.value:
if self.model.id in [ModelID.GPT_4.value, ModelID.GPT_4_O.value]:
self.tokenizer = tiktoken.encoding_for_model(
ModelID.GPT_3_5_TURBO.value
)
Expand Down Expand Up @@ -425,6 +425,7 @@ async def call_api_stream( # type: ignore
yield model_error
return
except Exception as e:
print(f'/n/nERROR OCCURRED')
logging.warning(f"Request {payload} failed with exception {e}")
await self.status_tracker.increment_error_count_other()
yield Err(UncaughtModelException(str(e)))
Expand Down
Loading