Skip to content

Commit

Permalink
✨ (openai_constants.py): add a new file to define constant MODEL_NAME…
Browse files Browse the repository at this point in the history
…S for OpenAI models (langflow-ai#1858)

* ✨ (openai_constants.py): add a new file to define constant MODEL_NAMES for OpenAI models
♻️ (ChatOpenAISpecs.py, OpenAIModel.py): refactor to use MODEL_NAMES constant from openai_constants.py for consistency and easier maintenance

* ✨ (IDGenerator.py): update key name from 'real_time_refresh' to 'refresh_button' for better clarity and consistency
  • Loading branch information
ogabrielluiz authored May 8, 2024
1 parent 82877d8 commit 28c2585
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/backend/base/langflow/base/models/openai_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MODEL_NAMES = ["gpt-4-turbo", "gpt-4-turbo-preview", "gpt-3.5-turbo", "gpt-3.5-turbo-0125"]
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def build_config(self):
return {
"unique_id": {
"display_name": "Value",
"real_time_refresh": True,
"refresh_button": True,
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Optional

from langflow.field_typing import BaseLanguageModel
from langchain_community.chat_models.openai import ChatOpenAI

from langflow.field_typing import NestedDict
from langflow.base.models.openai_constants import MODEL_NAMES
from langflow.field_typing import BaseLanguageModel, NestedDict
from langflow.interface.custom.custom_component import CustomComponent


Expand All @@ -24,19 +24,7 @@ def build_config(self):
"advanced": True,
"required": False,
},
"model_name": {
"display_name": "Model Name",
"advanced": False,
"required": False,
"options": [
"gpt-4-turbo-preview",
"gpt-4-0125-preview",
"gpt-4-1106-preview",
"gpt-4-vision-preview",
"gpt-3.5-turbo-0125",
"gpt-3.5-turbo-1106",
],
},
"model_name": {"display_name": "Model Name", "advanced": False, "options": MODEL_NAMES},
"openai_api_base": {
"display_name": "OpenAI API Base",
"advanced": False,
Expand Down
12 changes: 2 additions & 10 deletions src/backend/base/langflow/components/models/OpenAIModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from langflow.base.constants import STREAM_INFO_TEXT
from langflow.base.models.model import LCModelComponent
from langflow.base.models.openai_constants import MODEL_NAMES
from langflow.field_typing import NestedDict, Text


Expand Down Expand Up @@ -39,16 +40,7 @@ def build_config(self):
"model_name": {
"display_name": "Model Name",
"advanced": False,
"options": [
"gpt-4-turbo-2024-04-09",
"gpt-4-turbo-preview",
"gpt-3.5-turbo",
"gpt-4-0125-preview",
"gpt-4-1106-preview",
"gpt-4-vision-preview",
"gpt-3.5-turbo-0125",
"gpt-3.5-turbo-1106",
],
"options": MODEL_NAMES,
"value": "gpt-4-turbo-preview",
},
"openai_api_base": {
Expand Down

0 comments on commit 28c2585

Please sign in to comment.