Release v1.0.2

This commit is contained in:
SMKRV
2024-11-19 13:10:18 +03:00
parent 103f9d59e9
commit 5e82b9669c
6 changed files with 44 additions and 67 deletions
-2
View File
@@ -32,8 +32,6 @@ jobs:
- name: 🚀 Run hassfest validation - name: 🚀 Run hassfest validation
uses: home-assistant/actions/hassfest@master uses: home-assistant/actions/hassfest@master
with:
strict: true
- name: ️ Print hassfest version - name: ️ Print hassfest version
if: always() if: always()
+18 -1
View File
@@ -27,6 +27,23 @@ from .coordinator import HATextAICoordinator
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONFIG_SCHEMA = vol.Schema(
{
DOMAIN: vol.Schema(
{
vol.Required(CONF_API_KEY): cv.string,
vol.Optional(CONF_MODEL, default="gpt-3.5-turbo"): cv.string,
vol.Optional(CONF_TEMPERATURE, default=0.7): vol.Coerce(float),
vol.Optional(CONF_MAX_TOKENS, default=1000): vol.Coerce(int),
vol.Optional(CONF_REQUEST_INTERVAL, default=1.0): vol.Coerce(float),
vol.Optional(CONF_API_ENDPOINT): cv.string,
}
)
},
extra=vol.ALLOW_EXTRA,
)
async def async_setup(hass: HomeAssistant, config: dict[str, Any]) -> bool: async def async_setup(hass: HomeAssistant, config: dict[str, Any]) -> bool:
"""Set up the HA text AI component.""" """Set up the HA text AI component."""
hass.data.setdefault(DOMAIN, {}) hass.data.setdefault(DOMAIN, {})
@@ -39,7 +56,7 @@ async def async_setup(hass: HomeAssistant, config: dict[str, Any]) -> bool:
coordinator = next(iter(hass.data[DOMAIN].values())) coordinator = next(iter(hass.data[DOMAIN].values()))
question = call.data["question"] question = call.data["question"]
original_params = { original_params = {
"model": coordinator.model, "model": coordinator.model,
"temperature": coordinator.temperature, "temperature": coordinator.temperature,
+7 -24
View File
@@ -10,7 +10,6 @@ ask_question:
selector: selector:
text: text:
multiline: true multiline: true
type: text
model: model:
name: Model name: Model
@@ -23,20 +22,14 @@ ask_question:
options: options:
- label: "GPT-3.5 Turbo" - label: "GPT-3.5 Turbo"
value: "gpt-3.5-turbo" value: "gpt-3.5-turbo"
icon: "mdi:rocket-launch"
- label: "GPT-4" - label: "GPT-4"
value: "gpt-4" value: "gpt-4"
icon: "mdi:brain"
- label: "GPT-4 32K" - label: "GPT-4 32K"
value: "gpt-4-32k" value: "gpt-4-32k"
icon: "mdi:brain-circuit"
temperature: temperature:
name: Temperature name: Temperature
description: >- description: "Controls response creativity (0-2): Lower values for focused responses, higher for creative ones"
Controls response creativity (0-2):
Lower values (0-0.7) for focused, consistent responses
Higher values (0.7-2.0) for more creative, varied responses
required: false required: false
default: 0.7 default: 0.7
selector: selector:
@@ -45,11 +38,10 @@ ask_question:
max: 2.0 max: 2.0
step: 0.1 step: 0.1
mode: slider mode: slider
unit_of_measurement: ""
max_tokens: max_tokens:
name: Max Tokens name: Max Tokens
description: Maximum length of the response (longer responses use more tokens) description: Maximum length of the response
required: false required: false
default: 1000 default: 1000
selector: selector:
@@ -61,12 +53,12 @@ ask_question:
clear_history: clear_history:
name: Clear History name: Clear History
description: Delete all stored questions and responses from the conversation history description: Delete all stored questions and responses
fields: {} fields: {}
get_history: get_history:
name: Get History name: Get History
description: Retrieve recent conversation history between you and the AI description: Retrieve recent conversation history
fields: fields:
limit: limit:
name: Limit name: Limit
@@ -82,22 +74,13 @@ get_history:
set_system_prompt: set_system_prompt:
name: Set System Prompt name: Set System Prompt
description: >- description: Configure the AI's behavior by setting a system prompt
Configure the AI's behavior by setting a system prompt that will be used
for all future conversations until changed
fields: fields:
prompt: prompt:
name: System Prompt name: System Prompt
description: >- description: Instructions that define how the AI should behave and respond
Instructions that define how the AI should behave and respond.
This affects all future conversations.
required: true required: true
example: >- example: "You are a home automation expert assistant. Provide practical advice focused on smart home technology."
You are a home automation expert assistant. Provide practical advice
focused on smart home technology and automation. Use clear, concise
language and include specific product recommendations when relevant.
selector: selector:
text: text:
multiline: true multiline: true
type: text
rows: 4
@@ -5,30 +5,12 @@
"title": "Set up HA text AI", "title": "Set up HA text AI",
"description": "Configure your OpenAI integration for smart home interactions", "description": "Configure your OpenAI integration for smart home interactions",
"data": { "data": {
"api_key": { "api_key": "OpenAI API Key",
"name": "API Key", "model": "AI Model",
"description": "Your OpenAI API key (starts with 'sk-')" "temperature": "Temperature",
}, "max_tokens": "Max Tokens",
"model": { "api_endpoint": "API Endpoint",
"name": "AI Model", "request_interval": "Request Interval"
"description": "Select the AI model to use (e.g., gpt-3.5-turbo)"
},
"temperature": {
"name": "Temperature",
"description": "Response creativity (0-2): lower for focused, higher for creative responses"
},
"max_tokens": {
"name": "Max Tokens",
"description": "Maximum response length (1-4096 tokens)"
},
"api_endpoint": {
"name": "API Endpoint",
"description": "OpenAI API endpoint URL (leave default if unsure)"
},
"request_interval": {
"name": "Request Interval",
"description": "Minimum time between API requests in seconds (0.1 or higher)"
}
} }
} }
}, },
@@ -49,18 +31,9 @@
"title": "HA text AI Options", "title": "HA text AI Options",
"description": "Adjust your OpenAI integration settings", "description": "Adjust your OpenAI integration settings",
"data": { "data": {
"temperature": { "temperature": "Temperature",
"name": "Temperature", "max_tokens": "Max Tokens",
"description": "Controls response creativity (0-2): lower values for focused responses, higher for more creative ones" "request_interval": "Request Interval"
},
"max_tokens": {
"name": "Max Tokens",
"description": "Maximum length of responses (1-4096 tokens)"
},
"request_interval": {
"name": "Request Interval",
"description": "Minimum time between API requests in seconds (0.1 or higher)"
}
} }
} }
} }
@@ -70,9 +43,15 @@
"last_response": { "last_response": {
"name": "Last Response", "name": "Last Response",
"state_attributes": { "state_attributes": {
"question": "Last Question", "last_updated": {
"response": "AI Response", "name": "Last Updated"
"last_updated": "Last Updated" },
"question": {
"name": "Last Question"
},
"response": {
"name": "AI Response"
}
} }
} }
} }
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -4,6 +4,6 @@
"domains": ["sensor"], "domains": ["sensor"],
"homeassistant": "2024.11.0", "homeassistant": "2024.11.0",
"icon": "mdi:brain", "icon": "mdi:brain",
"version": "1.0.1b", "version": "1.0.2",
"documentation": "https://github.com/smkrv/ha-text-ai" "documentation": "https://github.com/smkrv/ha-text-ai"
} }