Skip to content

Commit e7ac56c

Browse files
Shulyakajoostlek
andauthored
Revisit list of OpenAI models for tool support (home-assistant#154399)
Co-authored-by: Joost Lekkerkerker <[email protected]>
1 parent 3cc4091 commit e7ac56c

File tree

4 files changed

+76
-12
lines changed

4 files changed

+76
-12
lines changed

homeassistant/components/openai_conversation/config_flow.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,9 @@ async def async_step_model(
428428

429429
if user_input is not None:
430430
if user_input.get(CONF_WEB_SEARCH):
431-
if user_input.get(CONF_WEB_SEARCH_USER_LOCATION):
431+
if user_input.get(CONF_REASONING_EFFORT) == "minimal":
432+
errors[CONF_WEB_SEARCH] = "web_search_minimal_reasoning"
433+
if user_input.get(CONF_WEB_SEARCH_USER_LOCATION) and not errors:
432434
user_input.update(await self._get_location_data())
433435
else:
434436
options.pop(CONF_WEB_SEARCH_CITY, None)
@@ -437,16 +439,17 @@ async def async_step_model(
437439
options.pop(CONF_WEB_SEARCH_TIMEZONE, None)
438440

439441
options.update(user_input)
440-
if self._is_new:
441-
return self.async_create_entry(
442-
title=options.pop(CONF_NAME),
442+
if not errors:
443+
if self._is_new:
444+
return self.async_create_entry(
445+
title=options.pop(CONF_NAME),
446+
data=options,
447+
)
448+
return self.async_update_and_abort(
449+
self._get_entry(),
450+
self._get_reconfigure_subentry(),
443451
data=options,
444452
)
445-
return self.async_update_and_abort(
446-
self._get_entry(),
447-
self._get_reconfigure_subentry(),
448-
data=options,
449-
)
450453

451454
return self.async_show_form(
452455
step_id="model",

homeassistant/components/openai_conversation/const.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
]
5656

5757
UNSUPPORTED_WEB_SEARCH_MODELS: list[str] = [
58+
"gpt-5-nano",
5859
"gpt-3.5",
5960
"gpt-4-turbo",
6061
"gpt-4.1-nano",
@@ -63,7 +64,7 @@
6364
]
6465

6566
UNSUPPORTED_IMAGE_MODELS: list[str] = [
66-
"gpt-5",
67+
"gpt-5-mini",
6768
"o3-mini",
6869
"o4",
6970
"o1",

homeassistant/components/openai_conversation/strings.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
"entry_not_loaded": "Cannot add things while the configuration is disabled."
7171
},
7272
"error": {
73-
"model_not_supported": "This model is not supported, please select a different model"
73+
"model_not_supported": "This model is not supported, please select a different model",
74+
"web_search_minimal_reasoning": "Web search is currently not supported with minimal reasoning effort"
7475
}
7576
},
7677
"ai_task_data": {
@@ -98,13 +99,15 @@
9899
"model": {
99100
"title": "[%key:component::openai_conversation::config_subentries::conversation::step::model::title%]",
100101
"data": {
102+
"code_interpreter": "[%key:component::openai_conversation::config_subentries::conversation::step::model::data::code_interpreter%]",
101103
"reasoning_effort": "[%key:component::openai_conversation::config_subentries::conversation::step::model::data::reasoning_effort%]",
102104
"image_model": "[%key:component::openai_conversation::config_subentries::conversation::step::model::data::image_model%]",
103105
"web_search": "[%key:component::openai_conversation::config_subentries::conversation::step::model::data::web_search%]",
104106
"search_context_size": "[%key:component::openai_conversation::config_subentries::conversation::step::model::data::search_context_size%]",
105107
"user_location": "[%key:component::openai_conversation::config_subentries::conversation::step::model::data::user_location%]"
106108
},
107109
"data_description": {
110+
"code_interpreter": "[%key:component::openai_conversation::config_subentries::conversation::step::model::data_description::code_interpreter%]",
108111
"reasoning_effort": "[%key:component::openai_conversation::config_subentries::conversation::step::model::data_description::reasoning_effort%]",
109112
"image_model": "[%key:component::openai_conversation::config_subentries::conversation::step::model::data_description::image_model%]",
110113
"web_search": "[%key:component::openai_conversation::config_subentries::conversation::step::model::data_description::web_search%]",
@@ -118,7 +121,8 @@
118121
"entry_not_loaded": "[%key:component::openai_conversation::config_subentries::conversation::abort::entry_not_loaded%]"
119122
},
120123
"error": {
121-
"model_not_supported": "[%key:component::openai_conversation::config_subentries::conversation::error::model_not_supported%]"
124+
"model_not_supported": "[%key:component::openai_conversation::config_subentries::conversation::error::model_not_supported%]",
125+
"web_search_minimal_reasoning": "[%key:component::openai_conversation::config_subentries::conversation::error::web_search_minimal_reasoning%]"
122126
}
123127
}
124128
},

tests/components/openai_conversation/test_config_flow.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,62 @@ async def test_subentry_unsupported_model(
234234
assert subentry_flow["errors"] == {"chat_model": "model_not_supported"}
235235

236236

237+
async def test_subentry_websearch_unsupported_reasoning_effort(
238+
hass: HomeAssistant, mock_config_entry, mock_init_component
239+
) -> None:
240+
"""Test the subentry form giving error about unsupported minimal reasoning effort."""
241+
subentry = next(iter(mock_config_entry.subentries.values()))
242+
subentry_flow = await mock_config_entry.start_subentry_reconfigure_flow(
243+
hass, subentry.subentry_id
244+
)
245+
assert subentry_flow["type"] is FlowResultType.FORM
246+
assert subentry_flow["step_id"] == "init"
247+
248+
# Configure initial step
249+
subentry_flow = await hass.config_entries.subentries.async_configure(
250+
subentry_flow["flow_id"],
251+
{
252+
CONF_RECOMMENDED: False,
253+
CONF_PROMPT: "Speak like a pirate",
254+
CONF_LLM_HASS_API: ["assist"],
255+
},
256+
)
257+
assert subentry_flow["type"] is FlowResultType.FORM
258+
assert subentry_flow["step_id"] == "advanced"
259+
260+
# Configure advanced step
261+
subentry_flow = await hass.config_entries.subentries.async_configure(
262+
subentry_flow["flow_id"],
263+
{
264+
CONF_CHAT_MODEL: "gpt-5",
265+
},
266+
)
267+
assert subentry_flow["type"] is FlowResultType.FORM
268+
assert subentry_flow["step_id"] == "model"
269+
270+
# Configure model step
271+
subentry_flow = await hass.config_entries.subentries.async_configure(
272+
subentry_flow["flow_id"],
273+
{
274+
CONF_REASONING_EFFORT: "minimal",
275+
CONF_WEB_SEARCH: True,
276+
},
277+
)
278+
assert subentry_flow["type"] is FlowResultType.FORM
279+
assert subentry_flow["errors"] == {"web_search": "web_search_minimal_reasoning"}
280+
281+
# Reconfigure model step
282+
subentry_flow = await hass.config_entries.subentries.async_configure(
283+
subentry_flow["flow_id"],
284+
{
285+
CONF_REASONING_EFFORT: "low",
286+
CONF_WEB_SEARCH: True,
287+
},
288+
)
289+
assert subentry_flow["type"] is FlowResultType.ABORT
290+
assert subentry_flow["reason"] == "reconfigure_successful"
291+
292+
237293
@pytest.mark.parametrize(
238294
("side_effect", "error"),
239295
[

0 commit comments

Comments
 (0)