Skip to content

Commit 044bbea

Browse files
authored
Merge pull request #273 from marginal23326/feat/azure-api-version-env
Make Azure OpenAI `api_version` configurable via env var
2 parents 3a459a9 + 3403de4 commit 044bbea

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ GOOGLE_API_KEY=
88

99
AZURE_OPENAI_ENDPOINT=
1010
AZURE_OPENAI_API_KEY=
11+
AZURE_OPENAI_API_VERSION=2025-01-01-preview
1112

1213
DEEPSEEK_ENDPOINT=https://api.deepseek.com
1314
DEEPSEEK_API_KEY=

src/utils/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,11 @@ def get_llm_model(provider: str, **kwargs):
128128
base_url = os.getenv("AZURE_OPENAI_ENDPOINT", "")
129129
else:
130130
base_url = kwargs.get("base_url")
131+
api_version = kwargs.get("api_version", "") or os.getenv("AZURE_OPENAI_API_VERSION", "2025-01-01-preview")
131132
return AzureChatOpenAI(
132133
model=kwargs.get("model_name", "gpt-4o"),
133134
temperature=kwargs.get("temperature", 0.0),
134-
api_version="2024-05-01-preview",
135+
api_version=api_version,
135136
azure_endpoint=base_url,
136137
api_key=api_key,
137138
)

0 commit comments

Comments
 (0)