diff --git a/.github/workflows/hassfest.yaml b/.github/workflows/hassfest.yaml index 694d189..5cdf1c6 100644 --- a/.github/workflows/hassfest.yaml +++ b/.github/workflows/hassfest.yaml @@ -32,8 +32,6 @@ jobs: - name: 🚀 Run hassfest validation uses: home-assistant/actions/hassfest@master - with: - strict: true - name: â„šī¸ Print hassfest version if: always() diff --git a/custom_components/ha_text_ai/__init__.py b/custom_components/ha_text_ai/__init__.py index d281dc8..5028bce 100644 --- a/custom_components/ha_text_ai/__init__.py +++ b/custom_components/ha_text_ai/__init__.py @@ -27,6 +27,23 @@ from .coordinator import HATextAICoordinator _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: """Set up the HA text AI component.""" 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())) question = call.data["question"] - + original_params = { "model": coordinator.model, "temperature": coordinator.temperature, diff --git a/custom_components/ha_text_ai/services.yaml b/custom_components/ha_text_ai/services.yaml index 2fa11b9..7a35454 100644 --- a/custom_components/ha_text_ai/services.yaml +++ b/custom_components/ha_text_ai/services.yaml @@ -10,7 +10,6 @@ ask_question: selector: text: multiline: true - type: text model: name: Model @@ -23,20 +22,14 @@ ask_question: options: - label: "GPT-3.5 Turbo" value: "gpt-3.5-turbo" - icon: "mdi:rocket-launch" - label: "GPT-4" value: "gpt-4" - icon: "mdi:brain" - label: "GPT-4 32K" value: "gpt-4-32k" - icon: "mdi:brain-circuit" temperature: name: Temperature - description: >- - 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 + description: "Controls response creativity (0-2): Lower values for focused responses, higher for creative ones" required: false default: 0.7 selector: @@ -45,11 +38,10 @@ ask_question: max: 2.0 step: 0.1 mode: slider - unit_of_measurement: "" max_tokens: name: Max Tokens - description: Maximum length of the response (longer responses use more tokens) + description: Maximum length of the response required: false default: 1000 selector: @@ -61,12 +53,12 @@ ask_question: clear_history: name: Clear History - description: Delete all stored questions and responses from the conversation history + description: Delete all stored questions and responses fields: {} get_history: name: Get History - description: Retrieve recent conversation history between you and the AI + description: Retrieve recent conversation history fields: limit: name: Limit @@ -82,22 +74,13 @@ get_history: set_system_prompt: name: Set System Prompt - description: >- - Configure the AI's behavior by setting a system prompt that will be used - for all future conversations until changed + description: Configure the AI's behavior by setting a system prompt fields: prompt: name: System Prompt - description: >- - Instructions that define how the AI should behave and respond. - This affects all future conversations. + description: Instructions that define how the AI should behave and respond required: true - example: >- - 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. + example: "You are a home automation expert assistant. Provide practical advice focused on smart home technology." selector: text: multiline: true - type: text - rows: 4 diff --git a/custom_components/ha_text_ai/translations/en.json b/custom_components/ha_text_ai/translations/en.json index 5087166..7245314 100644 --- a/custom_components/ha_text_ai/translations/en.json +++ b/custom_components/ha_text_ai/translations/en.json @@ -5,30 +5,12 @@ "title": "Set up HA text AI", "description": "Configure your OpenAI integration for smart home interactions", "data": { - "api_key": { - "name": "API Key", - "description": "Your OpenAI API key (starts with 'sk-')" - }, - "model": { - "name": "AI Model", - "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)" - } + "api_key": "OpenAI API Key", + "model": "AI Model", + "temperature": "Temperature", + "max_tokens": "Max Tokens", + "api_endpoint": "API Endpoint", + "request_interval": "Request Interval" } } }, @@ -49,18 +31,9 @@ "title": "HA text AI Options", "description": "Adjust your OpenAI integration settings", "data": { - "temperature": { - "name": "Temperature", - "description": "Controls response creativity (0-2): lower values for focused responses, higher for more creative ones" - }, - "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)" - } + "temperature": "Temperature", + "max_tokens": "Max Tokens", + "request_interval": "Request Interval" } } } @@ -70,9 +43,15 @@ "last_response": { "name": "Last Response", "state_attributes": { - "question": "Last Question", - "response": "AI Response", - "last_updated": "Last Updated" + "last_updated": { + "name": "Last Updated" + }, + "question": { + "name": "Last Question" + }, + "response": { + "name": "AI Response" + } } } } diff --git a/ha-text-ai.zip b/ha-text-ai.zip index 8fc88d6..5bed532 100644 Binary files a/ha-text-ai.zip and b/ha-text-ai.zip differ diff --git a/hacs.json b/hacs.json index 34819b7..2255ad6 100644 --- a/hacs.json +++ b/hacs.json @@ -4,6 +4,6 @@ "domains": ["sensor"], "homeassistant": "2024.11.0", "icon": "mdi:brain", - "version": "1.0.1b", + "version": "1.0.2", "documentation": "https://github.com/smkrv/ha-text-ai" }