Skip to content

Commit

Permalink
Fixed LocalAI validation
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinfrlch committed Dec 25, 2024
1 parent fd035d0 commit e72cfa9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
3 changes: 1 addition & 2 deletions custom_components/llmvision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ async def _remember(hass, call, start, response) -> None:
# Find semantic index config
config_entry = None
for entry in hass.config_entries.async_entries(DOMAIN):
_LOGGER.info(f"Entry: {entry.data}")
# Check if the config entry is empty
if entry.data["provider"] == "Event Calendar":
config_entry = entry
Expand Down Expand Up @@ -372,7 +371,7 @@ async def data_analyzer(data_call):
)
response = await request.call(call)
_LOGGER.info(f"Response: {response}")
# udpate sensor in data_call.data.get("sensor_entity")
# update sensor in data_call.data.get("sensor_entity")
await _update_sensor(hass, sensor_entity, response["response_text"], type)
return response

Expand Down
4 changes: 2 additions & 2 deletions custom_components/llmvision/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ async def _post(self, url, headers, data) -> dict:
_LOGGER.info(f"Request data: {Request.sanitize_data(data)}")

try:
_LOGGER.info(f"Posting to {url} with headers {headers}")
_LOGGER.info(f"Posting to {url}")
response = await self.session.post(url, headers=headers, json=data)
except Exception as e:
raise ServiceValidationError(f"Request failed: {e}")
Expand Down Expand Up @@ -628,7 +628,7 @@ async def _make_request(self, data) -> str:
port=self.endpoint.get("port")
)

headers = self._generate_headers()
headers = {}
response = await self._post(url=endpoint, headers=headers, data=data)
response_text = response.get(
"choices")[0].get("message").get("content")
Expand Down
10 changes: 10 additions & 0 deletions custom_components/llmvision/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
"openai_api_key": "Your API key"
}
},
"azure": {
"title": "Configure Azure",
"description": "Provide a valid Azure API key, base URL, deployment and API version.\nThe Base URL must be in the format `https://domain.openai.azure.com/` including the trailing slash.",
"data": {
"azure_api_key": "Your API key",
"azure_base_url": "Base URL",
"azure_deployment": "Deployment",
"azure_version": "API Version"
}
},
"anthropic": {
"title": "Configure Anthropic Claude",
"description": "Provide a valid Anthropic API key.",
Expand Down
10 changes: 10 additions & 0 deletions custom_components/llmvision/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
"api_key": "Dein API-key"
}
},
"azure": {
"title": "Azure konfigurieren",
"description": "Gib einen gültigen Azure API-key, die Base URL, den Namen des Deployments und die API-Version an.\nDie Base URL muss dieses Format haben: `https://domain.openai.azure.com/` (einschliesslich des abschliessenden '/')",
"data": {
"azure_api_key": "Dein API key",
"azure_base_url": "Base URL",
"azure_deployment": "Deployment",
"azure_version": "API Version"
}
},
"anthropic": {
"title": "Anthropic Claude konfigurieren",
"description": "Gib einen gültigen Anthropic API-key ein.",
Expand Down
10 changes: 10 additions & 0 deletions custom_components/llmvision/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
"openai_api_key": "Your API key"
}
},
"azure": {
"title": "Configure Azure",
"description": "Provide a valid Azure API key, base URL, deployment and API version.\nThe Base URL must be in the format `https://domain.openai.azure.com/` including the trailing slash.",
"data": {
"azure_api_key": "Your API key",
"azure_base_url": "Base URL",
"azure_deployment": "Deployment",
"azure_version": "API Version"
}
},
"anthropic": {
"title": "Configure Anthropic Claude",
"description": "Provide a valid Anthropic API key.",
Expand Down

0 comments on commit e72cfa9

Please sign in to comment.