Skip to content

Commit 815f2c5

Browse files
authored
feat: Add list of supported models for AzureOpenAI generator components (#10881)
* feat: Add list of supported models for AzureOpenAI generator components * Remove changes to legacy generator
1 parent ad347dd commit 815f2c5

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

haystack/components/generators/chat/azure.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
import os
6-
from typing import Any
6+
from typing import Any, ClassVar
77

88
from openai.lib._pydantic import to_strict_json_schema
99
from openai.lib.azure import AsyncAzureADTokenProvider, AsyncAzureOpenAI, AzureADTokenProvider, AzureOpenAI
@@ -70,6 +70,44 @@ class AzureOpenAIChatGenerator(OpenAIChatGenerator):
7070
```
7171
"""
7272

73+
SUPPORTED_MODELS: ClassVar[list[str]] = [
74+
"gpt-5.4",
75+
"gpt-5.4-pro",
76+
"gpt-5.3-codex",
77+
"gpt-5.2",
78+
"gpt-5.2-codex",
79+
"gpt-5.2-chat",
80+
"gpt-5.1",
81+
"gpt-5.1-chat",
82+
"gpt-5.1-codex",
83+
"gpt-5.1-codex-mini",
84+
"gpt-5",
85+
"gpt-5-mini",
86+
"gpt-5-nano",
87+
"gpt-5-chat",
88+
"gpt-4.1",
89+
"gpt-4.1-mini",
90+
"gpt-4.1-nano",
91+
"gpt-4o",
92+
"gpt-4o-mini",
93+
"gpt-4o-audio-preview",
94+
"gpt-realtime-1.5",
95+
"gpt-audio-1.5",
96+
"o1",
97+
"o1-mini",
98+
"o3",
99+
"o3-mini",
100+
"o4-mini",
101+
"codex-mini",
102+
"gpt-4",
103+
"gpt-35-turbo",
104+
"gpt-oss-120b",
105+
"computer-use-preview",
106+
]
107+
"""A non-exhaustive list of chat models supported by this component.
108+
See https://learn.microsoft.com/en-us/azure/foundry/foundry-models/concepts/models-sold-directly-by-azure
109+
for the full list."""
110+
73111
# ruff: noqa: PLR0913
74112
def __init__(
75113
self,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
features:
3+
- |
4+
``AzureOpenAIChatGenerator`` now exposes a ``SUPPORTED_MODELS`` class variable listing supported model IDs, for example ``gpt-5-mini`` and ``gpt-4o``. To view all supported models go to the [API reference](https://docs.haystack.deepset.ai/reference/generators-api#azureopenaichatgenerator) or run:
5+
6+
.. code:: python
7+
8+
from haystack.components.generators.chat import AzureOpenAIChatGenerator
9+
print(AzureOpenAIChatGenerator.SUPPORTED_MODELS)
10+
11+
We will add this for other model providers in their respective ChatGenerator components step by step.

test/components/generators/chat/test_azure.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ def tools():
7575

7676

7777
class TestAzureOpenAIChatGenerator:
78+
def test_supported_models(self) -> None:
79+
"""SUPPORTED_MODELS is a non-empty list of strings."""
80+
models = AzureOpenAIChatGenerator.SUPPORTED_MODELS
81+
assert isinstance(models, list)
82+
assert len(models) > 0
83+
assert all(isinstance(m, str) for m in models)
84+
7885
def test_init_default(self, monkeypatch):
7986
monkeypatch.setenv("AZURE_OPENAI_API_KEY", "test-api-key")
8087
component = AzureOpenAIChatGenerator(azure_endpoint="some-non-existing-endpoint")

0 commit comments

Comments
 (0)