mirror of
https://github.com/smkrv/ha-text-ai.git
synced 2026-07-22 07:03:58 +08:00
fix: Read version from manifest.json
This commit is contained in:
@@ -7,6 +7,7 @@ Constants for the HA text AI integration.
|
|||||||
@source: https://github.com/smkrv/ha-text-ai
|
@source: https://github.com/smkrv/ha-text-ai
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
|
import json
|
||||||
from typing import Final
|
from typing import Final
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from homeassistant.const import Platform, CONF_API_KEY, CONF_NAME
|
from homeassistant.const import Platform, CONF_API_KEY, CONF_NAME
|
||||||
@@ -32,8 +33,15 @@ try:
|
|||||||
with open(MANIFEST_PATH) as manifest_file:
|
with open(MANIFEST_PATH) as manifest_file:
|
||||||
manifest = json.load(manifest_file)
|
manifest = json.load(manifest_file)
|
||||||
VERSION = manifest.get("version", "unknown")
|
VERSION = manifest.get("version", "unknown")
|
||||||
except Exception:
|
except FileNotFoundError:
|
||||||
VERSION = "unknown"
|
VERSION = "unknown"
|
||||||
|
_LOGGER.warning("manifest.json not found at %s", MANIFEST_PATH)
|
||||||
|
except json.JSONDecodeError as err:
|
||||||
|
VERSION = "unknown"
|
||||||
|
_LOGGER.error("Error decoding JSON from manifest.json: %s", err)
|
||||||
|
except Exception as err:
|
||||||
|
VERSION = "unknown"
|
||||||
|
_LOGGER.error("Error reading manifest.json: %s", err)
|
||||||
|
|
||||||
# Default endpoints
|
# Default endpoints
|
||||||
DEFAULT_OPENAI_ENDPOINT: Final = "https://api.openai.com/v1"
|
DEFAULT_OPENAI_ENDPOINT: Final = "https://api.openai.com/v1"
|
||||||
|
|||||||
Reference in New Issue
Block a user