jekalmin / extended_openai_conversation

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

breaking change on beta HA 2024.1.0b0 #62

Closed Anto79-ops closed 9 months ago

Anto79-ops commented 9 months ago

Hi,

I'm running running 0.0.10-beta2 for your integration, all working well. I have 2 entries. One is using OpenAI, and the other is using LocalAI with LLM and no functions (using [] in the functions box). Upon updating to beta HA core 2024.1.0b0, the openAI entry is broken:

image

with this error message:

Logger: homeassistant.config_entries
Source: config_entries.py:406
First occurred: 3:27:22 PM (2 occurrences)
Last logged: 3:58:32 PM

Error setting up entry OpenAI Entities for extended_openai_conversation
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 406, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/extended_openai_conversation/__init__.py", line 99, in async_setup_entry
    await validate_authentication(
  File "/config/custom_components/extended_openai_conversation/helpers.py", line 154, in validate_authentication
    await hass.async_add_executor_job(
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openai/lib/_old_api.py", line 39, in __call__
openai.lib._old_api.APIRemovedInV1: 

You tried to access openai.Model, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface. 

Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742

thanks!

Anto79-ops commented 9 months ago

Actually, not even the local one works, gives a similar error message:

Logger: homeassistant.components.assist_pipeline.pipeline
Source: components/assist_pipeline/pipeline.py:988
Integration: Assist pipeline (documentation, issues)
First occurred: 5:55:05 PM (2 occurrences)
Last logged: 5:55:26 PM

Unexpected error during intent recognition
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/assist_pipeline/pipeline.py", line 988, in recognize_intent
    conversation_result = await conversation.async_converse(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/conversation/__init__.py", line 467, in async_converse
    result = await agent.async_process(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/extended_openai_conversation/__init__.py", line 179, in async_process
    response = await self.query(user_input, messages, exposed_entities, 0)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/extended_openai_conversation/__init__.py", line 298, in query
    response = await openai.ChatCompletion.acreate(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openai/lib/_old_api.py", line 39, in __call__
openai.lib._old_api.APIRemovedInV1: 

You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface. 

Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742
Anto79-ops commented 9 months ago

looks like the issue here is the OpenAI library you're using is a bit too old at 0.27.2 and the latest is 1.40. Perhaps an update to the library is required moving forward. thanks

Some info for v0 vs v1: https://localai.io/howtos/easy-request/

jekalmin commented 9 months ago

Thanks for reporting an issue! I will work on it pretty soon!

Anto79-ops commented 9 months ago

It seems you already updated from this pr you made before here

So maybe it's just your manifest.json just needs to be updated.

From a dev in beta chat about another custom component:

ideally they change that to be >= in themanifest.json(in core we pin to ==, but for CCs I usually use >= so core wins) so it doesn't conflict with whats in core as both of the deps there are used in core

jekalmin commented 9 months ago

Yes. I have tried it before and waited for HA to update to newer version. >= seems a great idea! I might have to try it.

Anto79-ops commented 9 months ago

sorry, I just tried changing that in the manifest.json and it did not work :(

jekalmin commented 9 months ago

Can you try 1.0.0-beta1?

saya6k commented 9 months ago

@jekalmin I've tested 1.0.0-beta1 at core 2024.1.0b7 and it seems working fine.

Anto79-ops commented 9 months ago

thanks! yes its working go me too now on 2024.1.0b7, both OpenAI requests AND LocalAI requests with no funcrtions (i.e. [])

thanks for fixing so quickly!