Hassassistant / openai_response

Custom component to integrate OpenAI's ChatGPT into Home Assistant
71 stars 15 forks source link

Using it as Assist? #17

Open Sturmkater opened 8 months ago

Sturmkater commented 8 months ago

Hi, thank you for your work! Is it somehow possible to use your adon as an assist? That way I could use ChatGPT as an assistant on my phone via Home Assistant.

andrejsoucek commented 7 months ago

@Sturmkater configuration.yaml:

intent_script:
  ChatGPT:
    action:
      - service: input_text.set_value
        data:
          value: "{{ prompt }}? Answer in one sentence."
        target:
          entity_id: input_text.gpt_input
      - delay: "00:00:02" # it takes some time to get the response
    speech:
      text: >
          {{ state_attr('sensor.hassio_openai_response', 'response_text') }}

custom_sentences/xx/chatgpt.yaml:

language: "xx"
intents:
  ChatGPT:
    data:
      - sentences:
          - "ask the prophecy {prompt}"
lists:
  prompt:
    wildcard: true

@Hassassistant might be worth adding this to readme

However there needs to be the delay in the script to wait for the response. I think this addon could be re-done to work as a callable service or script. Then we would just call the script and wait for the response.

Deniz66 commented 7 months ago

What is wrong here? My response is empty

alias: GPT
description: ""
trigger: []
condition: []
action:
  - service: input_text.set_value
    target:
      entity_id: input_text.gpt_input
    data:
      value: "Test Message "
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - device_id: 5b61253e56eae41f958bfa6378bbe3d5
    domain: mobile_app
    type: notify
    message: "{{ state_attr('sensor.hassio_openai_response', 'response_text') }}"
    title: Postkasten
mode: single