Hassassistant / openai_response

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

Working with Home Assistant v2024.6.0 with new OpenAi API #23

Open MissinLinkk05551 opened 5 months ago

MissinLinkk05551 commented 5 months ago

Updated API call Method now working with newest Home Assistant v2024.6.0

D3SOX commented 5 months ago

Tried to add your repo to HACS and install but it says Entity not available: sensor.hassio_openai_response

configuration.yml

sensor:
  - platform: openai_response
    api_key: "sk-proj-XXXXXXXXXXX"

input_text:
  gpt_input:
    name: GPT Input

Home Assistant

Core 2024.6.0 Supervisor 2024.06.0 Frontend 20240605.0

MissinLinkk05551 commented 5 months ago

add the original then copy my manifest.json and sensor.py into the files from the original into your custom_components/openai_response folder on your Home Assistant

D3SOX commented 5 months ago

I tried that already but it resulted in the same problem

D3SOX commented 5 months ago

image It seems like it does not correctly install the new version of the OpenAI dependency

MissinLinkk05551 commented 5 months ago

ssh into Home Assistant and run the following commands

sudo su -s /bin/bash

docker ps

Get the Id of the HomeAssistant Container from the docker ps command

docker exec -it {Your Container ID} /bin/bash

source /config/.venv/bin/activate

Your prompt should look like this: (.venv) homeassistant:/config#

then run pip install openai --upgrade

deactivate

exit

D3SOX commented 5 months ago

.venv did not exist for me inside /config in the container

find / -name activate
/usr/local/lib/python3.12/venv/scripts/common/activate

so I ran pip install openai --upgrade without activating a virtual env which ended up fixing the problem, thanks!

D3SOX commented 5 months ago

But sadly I ran into another problem:

openai.NotFoundError: Error code: 404 - {'error': {'message': 'The model `GPT-4o` does not exist or you do not have access to it.', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}

and the state of hassio_openai_response is always Unknown