fix: fallback to messages.create when proxy returns 404 on models endpoint; add version to manifest
This commit is contained in:
1 parent
187fcb895f
commit
b2d046694a
2 files changed
+27
-5
No files matched your search
@@ -102,7 +102,21 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> None:
|
||||
base_url=data.get(CONF_BASE_URL) or None,
|
||||
http_client=get_async_client(hass)
|
||||
)
|
||||
await client.models.list(timeout=10.0)
|
||||
# Use a minimal messages call instead of models.list so that
|
||||
# proxies which don't implement GET /v1/models still validate correctly.
|
||||
try:
|
||||
await client.models.list(timeout=10.0)
|
||||
except anthropic.APIStatusError as exc:
|
||||
if exc.status_code == 404:
|
||||
# Proxy does not support models endpoint — validate via a tiny messages call
|
||||
await client.messages.create(
|
||||
model="claude-haiku-4-5",
|
||||
max_tokens=1,
|
||||
messages=[{"role": "user", "content": "hi"}],
|
||||
timeout=10.0,
|
||||
)
|
||||
else:
|
||||
raise
|
||||
|
||||
|
||||
async def get_model_list(client: anthropic.AsyncAnthropic) -> list[SelectOptionDict]:
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
{
|
||||
"domain": "anthropic_custom",
|
||||
"name": "Anthropic (Custom Base URL)",
|
||||
"after_dependencies": ["assist_pipeline", "intent"],
|
||||
"after_dependencies": [
|
||||
"assist_pipeline",
|
||||
"intent"
|
||||
],
|
||||
"codeowners": [],
|
||||
"config_flow": true,
|
||||
"dependencies": ["conversation"],
|
||||
"dependencies": [
|
||||
"conversation"
|
||||
],
|
||||
"documentation": "https://github.com/robot/ha-anthropic-custom",
|
||||
"integration_type": "service",
|
||||
"iot_class": "cloud_polling",
|
||||
"quality_scale": "bronze",
|
||||
"requirements": ["anthropic==0.83.0"]
|
||||
}
|
||||
"requirements": [
|
||||
"anthropic==0.83.0"
|
||||
],
|
||||
"version": "1.0.0"
|
||||
}
|
||||
Reference in new issue
Block a user