Hassassistant / openai_response

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

After update, gpt-4 not working #7

Closed CajuCLC closed 1 year ago

CajuCLC commented 1 year ago

I updated after PR #6 was merged and now I can't use any of the gpt-4 models. Yes, I pay for the beta and yes it was working prior to the update.

Logger: homeassistant
Source: custom_components/openai_response/sensor.py:76
Integration: openai_response ([documentation](https://github.com/Hassassistant/openai_response))
First occurred: 10:11:02 AM (1 occurrences)
Last logged: 10:11:02 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/openai_response/sensor.py", line 132, in async_generate_openai_response
    response = await self._hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/openai_response/sensor.py", line 76, in generate_openai_response_sync
    return openai.ChatCompletion.create(
  File "/usr/local/lib/python3.10/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
  File "/usr/local/lib/python3.10/site-packages/openai/api_requestor.py", line 226, in request
    resp, got_stream = self._interpret_response(result, stream)
  File "/usr/local/lib/python3.10/site-packages/openai/api_requestor.py", line 619, in _interpret_response
    self._interpret_response_line(
  File "/usr/local/lib/python3.10/site-packages/openai/api_requestor.py", line 679, in _interpret_response_line
    raise self.handle_error_response(
openai.error.InvalidRequestError: The model: `gpt-4` does not exist
Hassassistant commented 1 year ago

thanks, can you try update again please and let me know

CajuCLC commented 1 year ago

thanks, can you try update again please and let me know

gpt-4 model worked with this code: https://github.com/Hassassistant/openai_response/issues/4#issuecomment-1511495044 So he PR #6 was almost there.

Olen commented 1 year ago

That is very strange. I basicallly copied your code for that part.

I don't have gpt-4 so I can't really test it. Would you be able to run something like

import openai
openai.api_key = "sk-....."

# list models
models = openai.Model.list()

for m in models.data:
    print(m.id)
CajuCLC commented 1 year ago

That is very strange. I basicallly copied your code for that part.

I don't have gpt-4 so I can't really test it. Would you be able to run something like

import openai
openai.api_key = "sk-....."

# list models
models = openai.Model.list()

for m in models.data:
    print(m.id)

Sorry I haven't replied. Now it doesn't show. I guess it was there for a day and then gone. Might have been the trial.