jekalmin / extended_openai_conversation

Home Assistant custom component of conversation agent. It uses OpenAI to control your devices.
916 stars 129 forks source link

entity_id should not be required for `execute_service` #86

Closed MindFreeze closed 8 months ago

MindFreeze commented 8 months ago

Here an error is thrown if no entity is given. However most services can be called with only area_id. In fact having area_id is pointless if entity_id is required. I tried tweaking the area_id parameter like this and ChatGPT tries to use correctly but gets the exception:

area_id:
  type: string
  description: The id retrieved from areas. 
    You can specify only area_id without entity_id 
    to act on all entities in that area
jekalmin commented 8 months ago

Thanks for reporting an issue.

I agree that area_id(even device_id since it can be used in target) can be used to execute service. I used entity_id because it's easy for user to decide whether entity should be exposed or not since HA supports exposing entities.

However, I want to keep preventing execute_services being called without any parameters. If so, the gpt is able to call services like homeassistant.stop or homeassistant.restart, which we don't want.

I think it would be a good idea to let one of entity_id, area_id, or device_id is required rather than only entity_id is required. In this way, area_id or device_id can be optionally exposed by modifying prompt.

jekalmin commented 8 months ago

I just released 1.0.1-beta1. I have made execute_service function to accept area_id. Please try this out!

https://github.com/jekalmin/extended_openai_conversation/pull/93#issue-2080328465

MindFreeze commented 8 months ago

Tried it. Works great!