feat: Implement response variables support and comprehensive production audit (v2.1.8)

🚀 Major Features:
- Add response variables support to ask_question service
- Eliminate 255-character limitation for AI responses
- Enable direct data access in automations without sensors
- Prevent race conditions in parallel automations

🔧 Production Code Audit & Fixes:
- Enhanced resource management with context managers in api_client.py
- Fixed critical race conditions with asyncio.Semaphore implementation
- Improved file operations with atomic writes and corruption handling
- Enhanced error handling and logging security (removed sensitive data)
- Fixed _check_memory_available method placement in coordinator.py

🌐 Translation Updates (8 languages):
- Updated all translation files with response variables information
- Enhanced service descriptions in: en, ru, de, es, it, hi, sr, zh
- Added information about direct response capability
- Maintained consistency across all language files

📚 Documentation Enhancements:
- Added comprehensive Response Variables section to README
- Created advanced automation examples with response_variable usage
- Added migration guide from sensors to response variables
- Enhanced service documentation with response data structure
- Added practical examples for multi-step AI workflows

🔄 Service Improvements:
- Enhanced ask_question service to return structured response data
- Added comprehensive response schema in services.yaml
- Improved error handling with success/failure indicators
- Added metadata support (tokens, model, timestamp)

�� Version & Manifest:
- Bumped version to 2.1.8
- Maintained compatibility with existing integrations
- Updated service documentation

This release addresses GitHub issue #2 and significantly improves the integration's
production readiness while adding powerful new response variable functionality.
This commit is contained in:
SMKRV
2025-09-01 17:14:23 +03:00
parent 76c5629fa0
commit e427254584
14 changed files with 347 additions and 75 deletions
@@ -3,6 +3,7 @@ ask_question:
description: >-
Send a question to the AI model and receive a detailed response.
The response will be stored in the conversation history and can be retrieved later.
This service now returns response data directly, eliminating the need to read from sensors.
fields:
instance:
name: Instance
@@ -72,6 +73,37 @@ ask_question:
max: 100000
step: 1
mode: box
response:
response_text:
description: "Full AI response text (unlimited length)"
example: "The answer to your question is..."
tokens_used:
description: "Total number of tokens consumed for this request"
example: 150
prompt_tokens:
description: "Number of tokens used for the input prompt"
example: 50
completion_tokens:
description: "Number of tokens used for the AI response"
example: 100
model_used:
description: "AI model that generated the response"
example: "gpt-4o-mini"
instance:
description: "Instance name that processed the request"
example: "my_assistant"
question:
description: "The original question that was asked"
example: "What is the weather like?"
timestamp:
description: "ISO timestamp when the response was generated"
example: "2025-01-09T16:57:00.000Z"
success:
description: "Whether the request was successful"
example: true
error:
description: "Error message if the request failed (only present when success is false)"
example: "API rate limit exceeded"
clear_history:
name: Clear History