Compare commits

..
13 Commits
Author SHA1 Message Date
SMKRV 82e1f0c4f9 Release v2.1.0 2024-12-13 00:06:08 +03:00
SMKRV 5c16eee6e4 fix: Read version from manifest.json 2024-12-12 16:03:15 +03:00
SMKRV e988d445a4 - Fixed version reading from manifest.json implementation 2024-12-11 22:01:01 +03:00
SMKRV f9bfb9ab7f fix: correct sw_version syntax in device_info
- Fixed version reading from manifest.json implementation
2024-12-11 21:57:27 +03:00
SMKRV 92dd1bc110 ~ 2024-12-11 00:00:12 +03:00
SMKRV 17d547325a refactor(docs): updated README services examples with more detailed configuration 2024-12-10 23:33:32 +03:00
SMKRV b8cb70217c refactor(docs): updated README shields 2024-12-10 23:27:49 +03:00
SMKRV 530d04f25d refactor(docs): updated README shields 2024-12-10 23:27:18 +03:00
SMKRV b71083b9bf bump to version 2.0.9 2024-12-10 17:25:47 +03:00
SMKRV f9f7d10f7f refactor(docs): updated README images 2024-12-10 17:21:41 +03:00
SMKRV 9f7cb20621 refactor(docs): updated README images 2024-12-10 17:19:52 +03:00
SMKRV 6fc3b23365 refactor(docs): updated README images 2024-12-10 17:18:55 +03:00
SMKRV 15c717fcb0 fix: Display only last Q&A in sensor state to prevent data truncation
- Show only the latest question and answer in sensor state
- Keep full conversation history in attributes
- Fix truncation issues in Home Assistant UI
- Maintain backwards compatibility
- No configuration changes required
2024-12-10 17:02:48 +03:00
5 changed files with 31 additions and 6 deletions
+1
View File
@@ -38,3 +38,4 @@ Thumbs.db
*.psd
*.zip
*.txt
*.pdf
+8 -3
View File
@@ -2,9 +2,11 @@
<div align="center">
![GitHub release](https://img.shields.io/github/release/smkrv/ha-text-ai.svg?style=flat-square) ![GitHub last commit](https://img.shields.io/github/last-commit/smkrv/ha-text-ai.svg?style=flat-square) [![License: CC BY-NC-SA 4.0](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg?style=flat-square)](https://creativecommons.org/licenses/by-nc-sa/4.0/) [![hacs_badge](https://img.shields.io/badge/HACS-Custom-41BDF5.svg?style=flat-square)](https://github.com/hacs/integration) ![/README.md](https://img.shields.io/badge/language-English-green?style=flat-square) ![/README_RU.md](https://img.shields.io/badge/language-Russian-green?style=flat-square) ![](https://img.shields.io/badge/language-Deutch-green?style=flat-square)
![GitHub release](https://img.shields.io/github/release/smkrv/ha-text-ai.svg?style=flat-square) ![GitHub last commit](https://img.shields.io/github/last-commit/smkrv/ha-text-ai.svg?style=flat-square) [![License: CC BY-NC-SA 4.0](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg?style=flat-square)](https://creativecommons.org/licenses/by-nc-sa/4.0/) [![hacs_badge](https://img.shields.io/badge/HACS-Custom-41BDF5.svg?style=flat-square)](https://github.com/hacs/integration)
![Deutsch](https://img.shields.io/badge/de-Deutsch-blue?style=flat-square) ![English](https://img.shields.io/badge/en-English-blue?style=flat-square) ![Español](https://img.shields.io/badge/es-Español-blue?style=flat-square) ![हिन्दी](https://img.shields.io/badge/hi-हिन्दी-blue?style=flat-square) ![Italiano](https://img.shields.io/badge/it-Italiano-blue?style=flat-square) ![Русский](https://img.shields.io/badge/ru-Русский-blue?style=flat-square) ![Српски](https://img.shields.io/badge/sr-Српски-blue?style=flat-square) ![中文](https://img.shields.io/badge/zh-中文-blue?style=flat-square)
<img src="https://github.com/smkrv/ha-text-ai/blob/2aaf3405759eb2d97624834594e24ace896131df/assets/images/icons/logo.png" alt="HA Text AI" style="width: 80%; max-width: 640px; max-height: 150px; aspect-ratio: 2/1; object-fit: contain;"/>
<img src="https://github.com/smkrv/ha-text-ai/blob/15c717fcb0204bf4a0d4b4b4c6f0bb93e9f6c9a9/custom_components/ha_text_ai/icons/logo%402x.png" alt="HA Text AI" style="width: 50%; max-width: 256px; max-height: 128px; aspect-ratio: 2/1; object-fit: contain;"/>
### Advanced AI Integration for [Home Assistant](https://www.home-assistant.io/) with LLM multi-provider support
</div>
@@ -272,6 +274,8 @@ data:
### clear_history
```yaml
service: ha_text_ai.clear_history
data:
instance: sensor.ha_text_ai_gpt
```
### get_history
@@ -280,6 +284,7 @@ service: ha_text_ai.get_history
data:
limit: 5 # optional
filter_model: "gpt-4o" # optional
instance: sensor.ha_text_ai_gpt
```
### 🏷️ HA Text AI Sensor Naming Convention
@@ -402,7 +407,7 @@ automation:
# Number of entries in current history file
{{ state_attr('sensor.ha_text_ai_gpt', 'History size') }} # 0
# Last few conversation entries (limited to 3 for performance)
# Last few conversation entries (limited to 1 for performance)
{{ state_attr('sensor.ha_text_ai_gpt', 'conversation_history') }} # [...]
```
+19 -1
View File
@@ -6,6 +6,8 @@ Constants for the HA text AI integration.
@github: https://github.com/smkrv/ha-text-ai
@source: https://github.com/smkrv/ha-text-ai
"""
import os
import json
from typing import Final
import voluptuous as vol
from homeassistant.const import Platform, CONF_API_KEY, CONF_NAME
@@ -25,6 +27,22 @@ API_PROVIDERS: Final = [
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 FileNotFoundError:
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_OPENAI_ENDPOINT: Final = "https://api.openai.com/v1"
DEFAULT_ANTHROPIC_ENDPOINT: Final = "https://api.anthropic.com"
@@ -56,7 +74,7 @@ DEFAULT_NAME: Final = "HA Text AI"
DEFAULT_NAME_PREFIX = "ha_text_ai"
DEFAULT_CONTEXT_MESSAGES: Final = 5
TRUNCATION_INDICATOR = " "
TRUNCATION_INDICATOR = " ... "
# Parameter constraints
MIN_TEMPERATURE: Final = 0.0
+1 -1
View File
@@ -23,6 +23,6 @@
"single_config_entry": false,
"ssdp": [],
"usb": [],
"version": "2.0.8",
"version": "2.1.0",
"zeroconf": []
}
+2 -1
View File
@@ -68,6 +68,7 @@ from .const import (
DEFAULT_NAME_PREFIX,
CONF_MAX_HISTORY_SIZE,
MAX_ATTRIBUTE_SIZE,
VERSION,
)
from .coordinator import HATextAICoordinator
@@ -154,7 +155,7 @@ class HATextAISensor(CoordinatorEntity, SensorEntity):
name=self._attr_name,
manufacturer="Community",
model=f"{model} ({api_provider} provider)",
sw_version="1.0.0",
sw_version=VERSION,
)
_LOGGER.debug(