mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
OpenAI Conversation: Add web search support for new models (#143054)
Use a list of openai models for web search support in openai_conversation
This commit is contained in:
parent
f8b56c460e
commit
024ec2b153
@ -63,6 +63,7 @@ from .const import (
|
|||||||
RECOMMENDED_WEB_SEARCH_CONTEXT_SIZE,
|
RECOMMENDED_WEB_SEARCH_CONTEXT_SIZE,
|
||||||
RECOMMENDED_WEB_SEARCH_USER_LOCATION,
|
RECOMMENDED_WEB_SEARCH_USER_LOCATION,
|
||||||
UNSUPPORTED_MODELS,
|
UNSUPPORTED_MODELS,
|
||||||
|
WEB_SEARCH_MODELS,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -160,9 +161,10 @@ class OpenAIOptionsFlow(OptionsFlow):
|
|||||||
errors[CONF_CHAT_MODEL] = "model_not_supported"
|
errors[CONF_CHAT_MODEL] = "model_not_supported"
|
||||||
|
|
||||||
if user_input.get(CONF_WEB_SEARCH):
|
if user_input.get(CONF_WEB_SEARCH):
|
||||||
if not user_input.get(
|
if (
|
||||||
CONF_CHAT_MODEL, RECOMMENDED_CHAT_MODEL
|
user_input.get(CONF_CHAT_MODEL, RECOMMENDED_CHAT_MODEL)
|
||||||
).startswith("gpt-4o"):
|
not in WEB_SEARCH_MODELS
|
||||||
|
):
|
||||||
errors[CONF_WEB_SEARCH] = "web_search_not_supported"
|
errors[CONF_WEB_SEARCH] = "web_search_not_supported"
|
||||||
elif user_input.get(CONF_WEB_SEARCH_USER_LOCATION):
|
elif user_input.get(CONF_WEB_SEARCH_USER_LOCATION):
|
||||||
user_input.update(await self.get_location_data())
|
user_input.update(await self.get_location_data())
|
||||||
|
@ -41,3 +41,12 @@ UNSUPPORTED_MODELS: list[str] = [
|
|||||||
"gpt-4o-mini-realtime-preview",
|
"gpt-4o-mini-realtime-preview",
|
||||||
"gpt-4o-mini-realtime-preview-2024-12-17",
|
"gpt-4o-mini-realtime-preview-2024-12-17",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
WEB_SEARCH_MODELS: list[str] = [
|
||||||
|
"gpt-4.1",
|
||||||
|
"gpt-4.1-mini",
|
||||||
|
"gpt-4o",
|
||||||
|
"gpt-4o-search-preview",
|
||||||
|
"gpt-4o-mini",
|
||||||
|
"gpt-4o-mini-search-preview",
|
||||||
|
]
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"model_not_supported": "This model is not supported, please select a different model",
|
"model_not_supported": "This model is not supported, please select a different model",
|
||||||
"web_search_not_supported": "Web search is only supported for gpt-4o and gpt-4o-mini models"
|
"web_search_not_supported": "Web search is not supported by this model"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"selector": {
|
"selector": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user