mirror of
https://github.com/smkrv/ha-text-ai.git
synced 2026-07-21 22:54:00 +08:00
fix: Add support for response_variable in ask_question service
- Added response schema definition in services.yaml for ask_question service - Set supports_response=True flag when registering the service - Fixed JSON syntax error in English translation file - Added comprehensive documentation with examples for response_variable usage - Users can now capture AI responses directly in variables without sensor delays Resolves issue where scripts failed with 'Script does not support response_variable' error
This commit is contained in:
@@ -188,7 +188,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
DOMAIN,
|
||||
SERVICE_ASK_QUESTION,
|
||||
async_ask_question,
|
||||
schema=SERVICE_SCHEMA_ASK_QUESTION
|
||||
schema=SERVICE_SCHEMA_ASK_QUESTION,
|
||||
supports_response=True
|
||||
)
|
||||
|
||||
hass.services.async_register(
|
||||
|
||||
@@ -73,6 +73,39 @@ ask_question:
|
||||
max: 100000
|
||||
step: 1
|
||||
mode: box
|
||||
response:
|
||||
type: object
|
||||
properties:
|
||||
response_text:
|
||||
type: string
|
||||
description: The AI response text
|
||||
tokens_used:
|
||||
type: integer
|
||||
description: Total number of tokens used
|
||||
prompt_tokens:
|
||||
type: integer
|
||||
description: Number of tokens in the prompt
|
||||
completion_tokens:
|
||||
type: integer
|
||||
description: Number of tokens in the completion
|
||||
model_used:
|
||||
type: string
|
||||
description: The AI model that was used for the response
|
||||
instance:
|
||||
type: string
|
||||
description: The instance name that was used
|
||||
question:
|
||||
type: string
|
||||
description: The original question that was asked
|
||||
timestamp:
|
||||
type: string
|
||||
description: ISO timestamp when the response was generated
|
||||
success:
|
||||
type: boolean
|
||||
description: Whether the request was successful
|
||||
error:
|
||||
type: string
|
||||
description: Error message if the request failed
|
||||
|
||||
clear_history:
|
||||
name: Clear History
|
||||
|
||||
@@ -92,9 +92,9 @@
|
||||
"anthropic": "Anthropic (compatible)",
|
||||
"deepseek": "DeepSeek",
|
||||
"gemini": "Google Gemini"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
"services": {
|
||||
"ask_question": {
|
||||
"name": "Ask Question (HA Text AI)",
|
||||
|
||||
Reference in New Issue
Block a user