- Fixed version reading from manifest.json implementation

This commit is contained in:
SMKRV
2024-12-11 22:01:01 +03:00
parent f9bfb9ab7f
commit e988d445a4
+10
View File
@@ -6,6 +6,7 @@ Constants for the HA text AI integration.
@github: https://github.com/smkrv/ha-text-ai @github: https://github.com/smkrv/ha-text-ai
@source: https://github.com/smkrv/ha-text-ai @source: https://github.com/smkrv/ha-text-ai
""" """
import os
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
@@ -25,6 +26,15 @@ API_PROVIDERS: Final = [
API_PROVIDER_ANTHROPIC API_PROVIDER_ANTHROPIC
] ]
# Read version from manifest.json
MANIFEST_PATH = os.path.join(os.path.dirname(__file__), "manifest.json")
try:
with open(MANIFEST_PATH) as manifest_file:
manifest = json.load(manifest_file)
VERSION = manifest.get("version", "unknown")
except Exception:
VERSION = "unknown"
# Default endpoints # Default endpoints
DEFAULT_OPENAI_ENDPOINT: Final = "https://api.openai.com/v1" DEFAULT_OPENAI_ENDPOINT: Final = "https://api.openai.com/v1"
DEFAULT_ANTHROPIC_ENDPOINT: Final = "https://api.anthropic.com" DEFAULT_ANTHROPIC_ENDPOINT: Final = "https://api.anthropic.com"