fix: make the home location lookup work against Claude
- Send the location question as a user message. A request with only a
system message has no user content, which endpoints in front of Anthropic
models reject ("text content blocks must be non-empty").
- Leave unknown fields out of the web search user_location. After a failed
lookup there is no city or region, and the empty strings made every
request fail ("user_location.city: String should have at least 1
character").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
235c536cab
commit
84f4bcda55
4 files changed
+63
-7
No files matched your search
@@ -560,12 +560,20 @@ class OpenAIBaseLLMEntity(Entity):
|
||||
),
|
||||
)
|
||||
if options.get(CONF_WEB_SEARCH_USER_LOCATION):
|
||||
# Leave out unknown fields: some endpoints reject empty strings,
|
||||
# and the location lookup may have found no city or region.
|
||||
location = {
|
||||
key: value
|
||||
for key, option in (
|
||||
("city", CONF_WEB_SEARCH_CITY),
|
||||
("region", CONF_WEB_SEARCH_REGION),
|
||||
("country", CONF_WEB_SEARCH_COUNTRY),
|
||||
("timezone", CONF_WEB_SEARCH_TIMEZONE),
|
||||
)
|
||||
if (value := options.get(option))
|
||||
}
|
||||
web_search["user_location"] = UserLocation(
|
||||
type="approximate",
|
||||
city=options.get(CONF_WEB_SEARCH_CITY, ""),
|
||||
region=options.get(CONF_WEB_SEARCH_REGION, ""),
|
||||
country=options.get(CONF_WEB_SEARCH_COUNTRY, ""),
|
||||
timezone=options.get(CONF_WEB_SEARCH_TIMEZONE, ""),
|
||||
type="approximate", **location
|
||||
)
|
||||
if not options.get(
|
||||
CONF_WEB_SEARCH_INLINE_CITATIONS,
|
||||
|
||||
Reference in new issue
Block a user