From e72cfa90841a853368feb6c3bd32794059731b89 Mon Sep 17 00:00:00 2001 From: valentinfrlch Date: Wed, 25 Dec 2024 16:55:20 +0100 Subject: [PATCH] Fixed LocalAI validation --- custom_components/llmvision/__init__.py | 3 +-- custom_components/llmvision/providers.py | 4 ++-- custom_components/llmvision/strings.json | 10 ++++++++++ custom_components/llmvision/translations/de.json | 10 ++++++++++ custom_components/llmvision/translations/en.json | 10 ++++++++++ 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/custom_components/llmvision/__init__.py b/custom_components/llmvision/__init__.py index cf9345b..7ada025 100644 --- a/custom_components/llmvision/__init__.py +++ b/custom_components/llmvision/__init__.py @@ -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 @@ -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 diff --git a/custom_components/llmvision/providers.py b/custom_components/llmvision/providers.py index 5fefc09..3e939eb 100644 --- a/custom_components/llmvision/providers.py +++ b/custom_components/llmvision/providers.py @@ -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}") @@ -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") diff --git a/custom_components/llmvision/strings.json b/custom_components/llmvision/strings.json index 2e038d6..e3b6304 100644 --- a/custom_components/llmvision/strings.json +++ b/custom_components/llmvision/strings.json @@ -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.", diff --git a/custom_components/llmvision/translations/de.json b/custom_components/llmvision/translations/de.json index 49956eb..fa8156a 100644 --- a/custom_components/llmvision/translations/de.json +++ b/custom_components/llmvision/translations/de.json @@ -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.", diff --git a/custom_components/llmvision/translations/en.json b/custom_components/llmvision/translations/en.json index 2e038d6..e3b6304 100644 --- a/custom_components/llmvision/translations/en.json +++ b/custom_components/llmvision/translations/en.json @@ -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.",