Skip to content

Commit

Permalink
move hard-coded deployments to environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
= Enea_Gore committed Aug 3, 2024
1 parent f16ddaf commit 5a6cb31
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions module_text_llm/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ OPENAI_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
AZURE_OPENAI_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
AZURE_OPENAI_API_KEY="https://ase-eu01.openai.azure.com/" # change base if needed
OPENAI_API_VERSION="2023-07-01-preview" # change base if needed
AZURE_DEPLOYMENTS= '["gpt-35-turbo","gpt-4-turbo","gpt-4-vision","gpt-4o"]'

# Replicate [leave blank if not used]
# See https://replicate.com and adjust model config options in `module_text_llm/helpers/models/replicate.py`
Expand Down
15 changes: 4 additions & 11 deletions module_text_llm/module_text_llm/helpers/models/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,13 @@
from langchain_openai import AzureChatOpenAI, AzureOpenAI, ChatOpenAI
from athena.logger import logger
from .model_config import ModelConfig

import json

OPENAI_PREFIX = "openai_"
AZURE_OPENAI_PREFIX = "azure_openai_"
openai_available = bool(os.environ.get("OPENAI_API_KEY"))
azure_openai_available = bool(os.environ.get("AZURE_OPENAI_API_KEY"))

# For sure correct chat completion models
actually_deployed_azure= [
"gpt-35-turbo",
"gpt-4-turbo",
"gpt-4-vision",
"gpt-4o"
]

available_models: Dict[str, BaseLanguageModel] = {}

if openai_available:
Expand All @@ -33,8 +25,9 @@
)

if azure_openai_available:
for deployment in actually_deployed_azure:
available_models[AZURE_OPENAI_PREFIX+deployment] = AzureChatOpenAI(deployment_name=deployment, temperature=0, client="")
# Will be replaced in the future
for deployment in json.loads(os.environ['AZURE_DEPLOYMENTS']):
available_models[AZURE_OPENAI_PREFIX + deployment] = AzureChatOpenAI(deployment_name=deployment, temperature=0, client="")

if available_models:
logger.info("Available openai models: %s", ", ".join(available_models.keys()))
Expand Down

0 comments on commit 5a6cb31

Please sign in to comment.