Skip to content

Commit adcd4ae

Browse files
authored
chore: Update Azure default model to gpt-4.1-mini (#10167)
* Update Azure default model to gpt-4.1-mini * Add version * Version updates * Experiment * Update experiment with 2024-12-01-preview * Fix test * Add reno note * Fix typo
1 parent 0907d89 commit adcd4ae

File tree

5 files changed

+46
-42
lines changed

5 files changed

+46
-42
lines changed

haystack/components/generators/azure.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class AzureOpenAIGenerator(OpenAIGenerator):
4040
client = AzureOpenAIGenerator(
4141
azure_endpoint="<Your Azure endpoint e.g. `https://your-company.azure.openai.com/>",
4242
api_key=Secret.from_token("<your-api-key>"),
43-
azure_deployment="<this a model name, e.g. gpt-4o-mini>")
43+
azure_deployment="<this a model name, e.g. gpt-4.1-mini>")
4444
response = client.run("What's Natural Language Processing? Be brief.")
4545
print(response)
4646
```
@@ -49,7 +49,7 @@ class AzureOpenAIGenerator(OpenAIGenerator):
4949
>> {'replies': ['Natural Language Processing (NLP) is a branch of artificial intelligence that focuses on
5050
>> the interaction between computers and human language. It involves enabling computers to understand, interpret,
5151
>> and respond to natural human language in a way that is both meaningful and useful.'], 'meta': [{'model':
52-
>> 'gpt-4o-mini', 'index': 0, 'finish_reason': 'stop', 'usage': {'prompt_tokens': 16,
52+
>> 'gpt-4.1-mini', 'index': 0, 'finish_reason': 'stop', 'usage': {'prompt_tokens': 16,
5353
>> 'completion_tokens': 49, 'total_tokens': 65}}]}
5454
```
5555
"""
@@ -58,8 +58,8 @@ class AzureOpenAIGenerator(OpenAIGenerator):
5858
def __init__( # pylint: disable=too-many-positional-arguments # noqa: PLR0913
5959
self,
6060
azure_endpoint: Optional[str] = None,
61-
api_version: Optional[str] = "2023-05-15",
62-
azure_deployment: Optional[str] = "gpt-4o-mini",
61+
api_version: Optional[str] = "2024-12-01-preview",
62+
azure_deployment: Optional[str] = "gpt-4.1-mini",
6363
api_key: Optional[Secret] = Secret.from_env_var("AZURE_OPENAI_API_KEY", strict=False),
6464
azure_ad_token: Optional[Secret] = Secret.from_env_var("AZURE_OPENAI_AD_TOKEN", strict=False),
6565
organization: Optional[str] = None,
@@ -77,7 +77,7 @@ def __init__( # pylint: disable=too-many-positional-arguments # noqa: PLR0913
7777
Initialize the Azure OpenAI Generator.
7878
7979
:param azure_endpoint: The endpoint of the deployed model, for example `https://example-resource.azure.openai.com/`.
80-
:param api_version: The version of the API to use. Defaults to 2023-05-15.
80+
:param api_version: The version of the API to use. Defaults to 2024-12-01-preview.
8181
:param azure_deployment: The deployment of the model, usually the model name.
8282
:param api_key: The API key to use for authentication.
8383
:param azure_ad_token: [Azure Active Directory token](https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id).
@@ -144,7 +144,7 @@ def __init__( # pylint: disable=too-many-positional-arguments # noqa: PLR0913
144144
self.azure_endpoint = azure_endpoint
145145
self.azure_deployment = azure_deployment
146146
self.organization = organization
147-
self.model: str = azure_deployment or "gpt-4o-mini"
147+
self.model: str = azure_deployment or "gpt-4.1-mini"
148148
self.timeout = timeout if timeout is not None else float(os.environ.get("OPENAI_TIMEOUT", "30.0"))
149149
self.max_retries = max_retries if max_retries is not None else int(os.environ.get("OPENAI_MAX_RETRIES", "5"))
150150
self.http_client_kwargs = http_client_kwargs

haystack/components/generators/chat/azure.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class AzureOpenAIChatGenerator(OpenAIChatGenerator):
5353
client = AzureOpenAIChatGenerator(
5454
azure_endpoint="<Your Azure endpoint e.g. `https://your-company.azure.openai.com/>",
5555
api_key=Secret.from_token("<your-api-key>"),
56-
azure_deployment="<this a model name, e.g. gpt-4o-mini>")
56+
azure_deployment="<this a model name, e.g. gpt-4.1-mini>")
5757
response = client.run(messages)
5858
print(response)
5959
```
@@ -64,7 +64,7 @@ class AzureOpenAIChatGenerator(OpenAIChatGenerator):
6464
"Natural Language Processing (NLP) is a branch of artificial intelligence that focuses on
6565
enabling computers to understand, interpret, and generate human language in a way that is useful.")],
6666
_name=None,
67-
_meta={'model': 'gpt-4o-mini', 'index': 0, 'finish_reason': 'stop',
67+
_meta={'model': 'gpt-4.1-mini', 'index': 0, 'finish_reason': 'stop',
6868
'usage': {'prompt_tokens': 15, 'completion_tokens': 36, 'total_tokens': 51}})]
6969
}
7070
```
@@ -75,8 +75,8 @@ class AzureOpenAIChatGenerator(OpenAIChatGenerator):
7575
def __init__( # pylint: disable=too-many-positional-arguments
7676
self,
7777
azure_endpoint: Optional[str] = None,
78-
api_version: Optional[str] = "2023-05-15",
79-
azure_deployment: Optional[str] = "gpt-4o-mini",
78+
api_version: Optional[str] = "2024-12-01-preview",
79+
azure_deployment: Optional[str] = "gpt-4.1-mini",
8080
api_key: Optional[Secret] = Secret.from_env_var("AZURE_OPENAI_API_KEY", strict=False),
8181
azure_ad_token: Optional[Secret] = Secret.from_env_var("AZURE_OPENAI_AD_TOKEN", strict=False),
8282
organization: Optional[str] = None,
@@ -95,7 +95,7 @@ def __init__( # pylint: disable=too-many-positional-arguments
9595
Initialize the Azure OpenAI Chat Generator component.
9696
9797
:param azure_endpoint: The endpoint of the deployed model, for example `"https://example-resource.azure.openai.com/"`.
98-
:param api_version: The version of the API to use. Defaults to 2023-05-15.
98+
:param api_version: The version of the API to use. Defaults to 2024-12-01-preview.
9999
:param azure_deployment: The deployment of the model, usually the model name.
100100
:param api_key: The API key to use for authentication.
101101
:param azure_ad_token: [Azure Active Directory token](https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id).
@@ -173,7 +173,7 @@ def __init__( # pylint: disable=too-many-positional-arguments
173173
self.azure_endpoint = azure_endpoint
174174
self.azure_deployment = azure_deployment
175175
self.organization = organization
176-
self.model = azure_deployment or "gpt-4o-mini"
176+
self.model = azure_deployment or "gpt-4.1-mini"
177177
self.timeout = timeout if timeout is not None else float(os.environ.get("OPENAI_TIMEOUT", "30.0"))
178178
self.max_retries = max_retries if max_retries is not None else int(os.environ.get("OPENAI_MAX_RETRIES", "5"))
179179
self.default_headers = default_headers or {}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
upgrade:
3+
- |
4+
Updated the default Azure OpenAI model from ``gpt-4o-mini`` to ``gpt-4.1-mini`` and the default API version from ``2023-05-15`` to ``2024-12-01-preview`` for both ``AzureOpenAIGenerator`` and ``AzureOpenAIChatGenerator``.

test/components/generators/chat/test_azure.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_init_default(self, monkeypatch):
7979
monkeypatch.setenv("AZURE_OPENAI_API_KEY", "test-api-key")
8080
component = AzureOpenAIChatGenerator(azure_endpoint="some-non-existing-endpoint")
8181
assert component.client.api_key == "test-api-key"
82-
assert component.azure_deployment == "gpt-4o-mini"
82+
assert component.azure_deployment == "gpt-4.1-mini"
8383
assert component.streaming_callback is None
8484
assert not component.generation_kwargs
8585

@@ -100,7 +100,7 @@ def test_init_with_parameters(self, tools):
100100
azure_ad_token_provider=default_azure_ad_token_provider,
101101
)
102102
assert component.client.api_key == "test-api-key"
103-
assert component.azure_deployment == "gpt-4o-mini"
103+
assert component.azure_deployment == "gpt-4.1-mini"
104104
assert component.streaming_callback is print_streaming_chunk
105105
assert component.generation_kwargs == {"max_completion_tokens": 10, "some_test_param": "test-params"}
106106
assert component.tools == tools
@@ -121,7 +121,7 @@ def test_init_with_0_max_retries(self, tools):
121121
max_retries=0,
122122
)
123123
assert component.client.api_key == "test-api-key"
124-
assert component.azure_deployment == "gpt-4o-mini"
124+
assert component.azure_deployment == "gpt-4.1-mini"
125125
assert component.streaming_callback is print_streaming_chunk
126126
assert component.generation_kwargs == {"max_completion_tokens": 10, "some_test_param": "test-params"}
127127
assert component.tools == tools
@@ -138,9 +138,9 @@ def test_to_dict_default(self, monkeypatch):
138138
"init_parameters": {
139139
"api_key": {"env_vars": ["AZURE_OPENAI_API_KEY"], "strict": False, "type": "env_var"},
140140
"azure_ad_token": {"env_vars": ["AZURE_OPENAI_AD_TOKEN"], "strict": False, "type": "env_var"},
141-
"api_version": "2023-05-15",
141+
"api_version": "2024-12-01-preview",
142142
"azure_endpoint": "some-non-existing-endpoint",
143-
"azure_deployment": "gpt-4o-mini",
143+
"azure_deployment": "gpt-4.1-mini",
144144
"organization": None,
145145
"streaming_callback": None,
146146
"generation_kwargs": {},
@@ -177,9 +177,9 @@ def test_to_dict_with_parameters(self, monkeypatch, calendar_event_model):
177177
"init_parameters": {
178178
"api_key": {"env_vars": ["ENV_VAR"], "strict": False, "type": "env_var"},
179179
"azure_ad_token": {"env_vars": ["ENV_VAR1"], "strict": False, "type": "env_var"},
180-
"api_version": "2023-05-15",
180+
"api_version": "2024-12-01-preview",
181181
"azure_endpoint": "some-non-existing-endpoint",
182-
"azure_deployment": "gpt-4o-mini",
182+
"azure_deployment": "gpt-4.1-mini",
183183
"organization": None,
184184
"streaming_callback": "haystack.components.generators.utils.print_streaming_chunk",
185185
"timeout": 2.5,
@@ -222,9 +222,9 @@ def test_from_dict(self, monkeypatch):
222222
"init_parameters": {
223223
"api_key": {"env_vars": ["AZURE_OPENAI_API_KEY"], "strict": False, "type": "env_var"},
224224
"azure_ad_token": {"env_vars": ["AZURE_OPENAI_AD_TOKEN"], "strict": False, "type": "env_var"},
225-
"api_version": "2023-05-15",
225+
"api_version": "2024-12-01-preview",
226226
"azure_endpoint": "some-non-existing-endpoint",
227-
"azure_deployment": "gpt-4o-mini",
227+
"azure_deployment": "gpt-4.1-mini",
228228
"organization": None,
229229
"streaming_callback": None,
230230
"generation_kwargs": {},
@@ -252,9 +252,9 @@ def test_from_dict(self, monkeypatch):
252252

253253
assert generator.api_key == Secret.from_env_var("AZURE_OPENAI_API_KEY", strict=False)
254254
assert generator.azure_ad_token == Secret.from_env_var("AZURE_OPENAI_AD_TOKEN", strict=False)
255-
assert generator.api_version == "2023-05-15"
255+
assert generator.api_version == "2024-12-01-preview"
256256
assert generator.azure_endpoint == "some-non-existing-endpoint"
257-
assert generator.azure_deployment == "gpt-4o-mini"
257+
assert generator.azure_deployment == "gpt-4.1-mini"
258258
assert generator.organization is None
259259
assert generator.streaming_callback is None
260260
assert generator.generation_kwargs == {}
@@ -282,9 +282,9 @@ def test_pipeline_serialization_deserialization(self, tmp_path, monkeypatch):
282282
"type": "haystack.components.generators.chat.azure.AzureOpenAIChatGenerator",
283283
"init_parameters": {
284284
"azure_endpoint": "some-non-existing-endpoint",
285-
"azure_deployment": "gpt-4o-mini",
285+
"azure_deployment": "gpt-4.1-mini",
286286
"organization": None,
287-
"api_version": "2023-05-15",
287+
"api_version": "2024-12-01-preview",
288288
"streaming_callback": None,
289289
"generation_kwargs": {},
290290
"timeout": 30.0,
@@ -341,7 +341,7 @@ def test_live_run(self):
341341
assert len(results["replies"]) == 1
342342
message: ChatMessage = results["replies"][0]
343343
assert "Paris" in message.text
344-
assert "gpt-4o-mini" in message.meta["model"]
344+
assert "gpt-4.1-mini" in message.meta["model"]
345345
assert message.meta["finish_reason"] == "stop"
346346

347347
@pytest.mark.integration
@@ -544,7 +544,7 @@ def test_init_should_also_create_async_client_with_same_args(self, tools):
544544
tools_strict=True,
545545
)
546546
assert component.async_client.api_key == "test-api-key"
547-
assert component.azure_deployment == "gpt-4o-mini"
547+
assert component.azure_deployment == "gpt-4.1-mini"
548548
assert component.streaming_callback is print_streaming_chunk
549549
assert component.generation_kwargs == {"max_completion_tokens": 10, "some_test_param": "test-params"}
550550
assert component.tools == tools
@@ -567,7 +567,7 @@ async def test_live_run_async(self):
567567
assert len(results["replies"]) == 1
568568
message: ChatMessage = results["replies"][0]
569569
assert "Paris" in message.text
570-
assert "gpt-4o" in message.meta["model"]
570+
assert "gpt-4.1-mini" in message.meta["model"]
571571
assert message.meta["finish_reason"] == "stop"
572572

573573
@pytest.mark.integration

test/components/generators/test_azure.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_init_default(self, monkeypatch):
1919
monkeypatch.setenv("AZURE_OPENAI_API_KEY", "test-api-key")
2020
component = AzureOpenAIGenerator(azure_endpoint="some-non-existing-endpoint")
2121
assert component.client.api_key == "test-api-key"
22-
assert component.azure_deployment == "gpt-4o-mini"
22+
assert component.azure_deployment == "gpt-4.1-mini"
2323
assert component.streaming_callback is None
2424
assert not component.generation_kwargs
2525

@@ -33,13 +33,13 @@ def test_init_with_parameters(self):
3333
component = AzureOpenAIGenerator(
3434
api_key=Secret.from_token("fake-api-key"),
3535
azure_endpoint="some-non-existing-endpoint",
36-
azure_deployment="gpt-4o-mini",
36+
azure_deployment="gpt-4.1-mini",
3737
streaming_callback=print_streaming_chunk,
3838
generation_kwargs={"max_completion_tokens": 10, "some_test_param": "test-params"},
3939
azure_ad_token_provider=default_azure_ad_token_provider,
4040
)
4141
assert component.client.api_key == "fake-api-key"
42-
assert component.azure_deployment == "gpt-4o-mini"
42+
assert component.azure_deployment == "gpt-4.1-mini"
4343
assert component.streaming_callback is print_streaming_chunk
4444
assert component.timeout == 30.0
4545
assert component.generation_kwargs == {"max_completion_tokens": 10, "some_test_param": "test-params"}
@@ -51,14 +51,14 @@ def test_init_with_0_max_retries(self):
5151
component = AzureOpenAIGenerator(
5252
api_key=Secret.from_token("fake-api-key"),
5353
azure_endpoint="some-non-existing-endpoint",
54-
azure_deployment="gpt-4o-mini",
54+
azure_deployment="gpt-4.1-mini",
5555
streaming_callback=print_streaming_chunk,
5656
generation_kwargs={"max_completion_tokens": 10, "some_test_param": "test-params"},
5757
azure_ad_token_provider=default_azure_ad_token_provider,
5858
max_retries=0,
5959
)
6060
assert component.client.api_key == "fake-api-key"
61-
assert component.azure_deployment == "gpt-4o-mini"
61+
assert component.azure_deployment == "gpt-4.1-mini"
6262
assert component.streaming_callback is print_streaming_chunk
6363
assert component.timeout == 30.0
6464
assert component.generation_kwargs == {"max_completion_tokens": 10, "some_test_param": "test-params"}
@@ -74,8 +74,8 @@ def test_to_dict_default(self, monkeypatch):
7474
"init_parameters": {
7575
"api_key": {"env_vars": ["AZURE_OPENAI_API_KEY"], "strict": False, "type": "env_var"},
7676
"azure_ad_token": {"env_vars": ["AZURE_OPENAI_AD_TOKEN"], "strict": False, "type": "env_var"},
77-
"azure_deployment": "gpt-4o-mini",
78-
"api_version": "2023-05-15",
77+
"azure_deployment": "gpt-4.1-mini",
78+
"api_version": "2024-12-01-preview",
7979
"streaming_callback": None,
8080
"azure_endpoint": "some-non-existing-endpoint",
8181
"organization": None,
@@ -109,8 +109,8 @@ def test_to_dict_with_parameters(self, monkeypatch):
109109
"init_parameters": {
110110
"api_key": {"env_vars": ["ENV_VAR"], "strict": False, "type": "env_var"},
111111
"azure_ad_token": {"env_vars": ["ENV_VAR1"], "strict": False, "type": "env_var"},
112-
"azure_deployment": "gpt-4o-mini",
113-
"api_version": "2023-05-15",
112+
"azure_deployment": "gpt-4.1-mini",
113+
"api_version": "2024-12-01-preview",
114114
"streaming_callback": "haystack.components.generators.utils.print_streaming_chunk",
115115
"azure_endpoint": "some-non-existing-endpoint",
116116
"organization": None,
@@ -131,8 +131,8 @@ def test_from_dict_defaults(self, monkeypatch):
131131
"init_parameters": {
132132
"api_key": {"env_vars": ["AZURE_OPENAI_API_KEY"], "strict": False, "type": "env_var"},
133133
"azure_ad_token": {"env_vars": ["AZURE_OPENAI_AD_TOKEN"], "strict": False, "type": "env_var"},
134-
"azure_deployment": "gpt-4o-mini",
135-
"api_version": "2023-05-15",
134+
"azure_deployment": "gpt-4.1-mini",
135+
"api_version": "2024-12-01-preview",
136136
"streaming_callback": None,
137137
"azure_endpoint": "some-non-existing-endpoint",
138138
"organization": None,
@@ -148,8 +148,8 @@ def test_from_dict_defaults(self, monkeypatch):
148148
component = AzureOpenAIGenerator.from_dict(data)
149149
assert component.api_key == Secret.from_env_var("AZURE_OPENAI_API_KEY", strict=False)
150150
assert component.azure_ad_token == Secret.from_env_var("AZURE_OPENAI_AD_TOKEN", strict=False)
151-
assert component.azure_deployment == "gpt-4o-mini"
152-
assert component.api_version == "2023-05-15"
151+
assert component.azure_deployment == "gpt-4.1-mini"
152+
assert component.api_version == "2024-12-01-preview"
153153
assert component.streaming_callback is None
154154
assert component.azure_endpoint == "some-non-existing-endpoint"
155155
assert component.organization is None
@@ -187,7 +187,7 @@ def test_live_run(self):
187187
assert "Paris" in response
188188

189189
metadata = results["meta"][0]
190-
assert "gpt-4o-mini" in metadata["model"]
190+
assert "gpt-4.1-mini" in metadata["model"]
191191
assert metadata["finish_reason"] == "stop"
192192

193193
assert "usage" in metadata

0 commit comments

Comments
 (0)