chrislemke / ChatFred

Alfred workflow using ChatGPT, DALL·E 2 and other models for chatting, image generation and more.
https://alfred.app/workflows/chrislemke/chatfred/
MIT License
377 stars 34 forks source link

Nothing happens when trying to use `cfi` to generate an image according to a query. #27

Closed EugeneTarasenko closed 1 year ago

EugeneTarasenko commented 1 year ago

I had a look at the troubleshooting section

Describe the bug When I'm trying to get an image using cfi + query command nothing happens in response. Alfred's troubleshooting mode window just throws an error:

[20:42:54.552] Logging Started...
[20:43:13.353] ChatFred[Keyword] Processing complete
[20:43:13.361] ChatFred[Keyword] Passing output 'a red car' to Run Script
[20:43:23.444] ERROR: ChatFred[Run Script] Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1454, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 512, in wrap_socket
    return self.sslsocket_class._create(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1070, in _create
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1341, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/eugen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.AEE17DC6-6D41-4E92-9EA8-1DE651F111CF/src/image_generation.py", line 68, in make_request
    urllib.request.urlretrieve(response["data"][0]["url"], file_path)  # nosec
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 241, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/eugen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.AEE17DC6-6D41-4E92-9EA8-1DE651F111CF/src/image_generation.py", line 85, in <module>
    __response = make_request(get_query(), __size)
  File "/Users/eugen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.AEE17DC6-6D41-4E92-9EA8-1DE651F111CF/src/image_generation.py", line 75, in make_request
    error_message=exception._message,  # type: ignore  # pylint: disable=protected-access
AttributeError: 'URLError' object has no attribute '_message'
[20:43:23.461] ChatFred[Run Script] Processing complete
[20:43:23.462] ChatFred[Run Script] Passing output '' to Conditional
[20:43:23.463] ChatFred[Conditional] Processing complete
[20:43:23.464] ChatFred[Conditional] Passing output '' to Large Type

To Reproduce Steps to reproduce the behavior:

  1. Type cfi.
  2. Press the spacebar.
  3. Type a query (a red car, e.g.)
  4. Press Enter key.
  5. Nothing happens in response.

Relevant information from the ChatFred_Error.log file No information related to the problem in ChatFred_Error.log file has been found.

Versions:

chrislemke commented 1 year ago

Hey @EugeneTarasenko! Thanks for the detailed information. I will investigate the issue and come back to you. Just a short question. Which Workflow version you are using?

EugeneTarasenko commented 1 year ago

Hey @EugeneTarasenko! Thanks for the detailed information. I will investigate the issue and come back to you. Just a short question. Which Workflow version you are using?

@chrislemke , 1.2.2. The latest beta version 1.3 doesn't work as well.

chrislemke commented 1 year ago

I found this. Maybe

pip install --upgrade certifi

fixes it?

EugeneTarasenko commented 1 year ago

@chrislemke Unfortunately, no.


[21:23:51.841] ChatFred[Keyword] Passing output 'a fast red car' to Run Script
[21:23:59.814] ERROR: ChatFred[Run Script] Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1454, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 512, in wrap_socket
    return self.sslsocket_class._create(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1070, in _create
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1341, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/eugen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.AEE17DC6-6D41-4E92-9EA8-1DE651F111CF/src/image_generation.py", line 68, in make_request
    urllib.request.urlretrieve(response["data"][0]["url"], file_path)  # nosec
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 241, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/eugen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.AEE17DC6-6D41-4E92-9EA8-1DE651F111CF/src/image_generation.py", line 85, in <module>
    __response = make_request(get_query(), __size)
  File "/Users/eugen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.AEE17DC6-6D41-4E92-9EA8-1DE651F111CF/src/image_generation.py", line 75, in make_request
    error_message=exception._message,  # type: ignore  # pylint: disable=protected-access
AttributeError: 'URLError' object has no attribute '_message'
[21:23:59.826] ChatFred[Run Script] Processing complete
[21:23:59.827] ChatFred[Run Script] Passing output '' to Conditional
[21:23:59.828] ChatFred[Conditional] Processing complete
[21:23:59.829] ChatFred[Conditional] Passing output '' to Large Type
chrislemke commented 1 year ago

Maybe it is connected to your Python installation. You could try installing it using homebrew.

First, install homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then install Python 3.10

brew install python@3.10

Not sure if that helps. But maybe it is worth a try.

EugeneTarasenko commented 1 year ago

@chrislemke no luck. Homebrew version: 4.0.6

[22:13:30.409] ChatFred[Keyword] Passing output 'a picture of a red and blue bird' to Run Script
[22:13:36.679] ERROR: ChatFred[Run Script] Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1454, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 512, in wrap_socket
    return self.sslsocket_class._create(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1070, in _create
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1341, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/eugen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.AEE17DC6-6D41-4E92-9EA8-1DE651F111CF/src/image_generation.py", line 68, in make_request
    urllib.request.urlretrieve(response["data"][0]["url"], file_path)  # nosec
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 241, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/eugen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.AEE17DC6-6D41-4E92-9EA8-1DE651F111CF/src/image_generation.py", line 85, in <module>
    __response = make_request(get_query(), __size)
  File "/Users/eugen/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.AEE17DC6-6D41-4E92-9EA8-1DE651F111CF/src/image_generation.py", line 75, in make_request
    error_message=exception._message,  # type: ignore  # pylint: disable=protected-access
AttributeError: 'URLError' object has no attribute '_message'
[22:13:36.683] ChatFred[Run Script] Processing complete
[22:13:36.697] ChatFred[Run Script] Passing output '' to Conditional
[22:13:36.698] ChatFred[Conditional] Processing complete
[22:13:36.699] ChatFred[Conditional] Passing output '' to Large Type
chrislemke commented 1 year ago

Looks like you are still using the old Python installation. For this to work, you need to tell MacOS which Python version it should use. Please check out the following link: https://stackoverflow.com/questions/5157678/how-do-i-use-brew-installed-python-as-the-default-python

EugeneTarasenko commented 1 year ago

@chrislemke No luck. I might not be skillful enough to figure out how to manage python versions installed on my mac. For some reason, I can't even generate an image directly on the dall-e website. I get an error instead there:

Screen Shot 2023-03-18 at 22 52 21

Anyway, most likely the problem is on my part. I'd rather not bother you anymore. So, please, close the issue. Thanks for your help and the time you've spent on me.

chrislemke commented 1 year ago

Hey! That is indeed a very strange message. Maybe OpenAI has an internal error. I will leave this issue open for a while. Maybe we find a solution to this.

chrislemke commented 1 year ago

Hey @EugeneTarasenko! Any news on this? Does it work for you? I just released version 1.3.0. In a perfect world, this fixes your issue.

EugeneTarasenko commented 1 year ago

Thanks. I still can't make dall-e work on their own website. I'm still getting this error: Screen Shot 2023-03-20 at 11 10 39 I've just tested your new version of ChatFred and the response in the Alfred's debugging window is different now when typing cfi a man sitting in a chair e.g.:

[11:30:55.652] ChatFred[Keyword] Passing output 'a man sitting in a chair' to Run Script

[11:31:02.069] ChatFred[Debug] VARIABLES:{
  always_copy_to_clipboard = "1"
  always_speak = "1"
  api_key = "sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  cf_aliases = "joke=tell me a joke;"
  chat_gpt_model = "gpt-3.5-turbo"
  frequency_penalty = "0.0"
  history_length = "5"
  history_type = "search"
  image_size = "512"
  instruct_gpt_model = "text-davinci-003"
  jailbreak_prompt = ""
  max_tokens = ""
  presence_penalty = "0.0"
  save_to_file = "0"
  save_to_file_dir = "/Users/eugen"
  show_loading_indicator = "1"
  show_notifications = "1"
  temperature = "0"
  top_p = "1"
  transformation_prompt = "Write the text so that each letter is replaced by its successor in the alphabet."
}
RESPONSE:''

But I still can't get an image. Probably it's dall-e's fault.

chrislemke commented 1 year ago

Looks like you really need to contact the guys from OpenAI. They can probably help you. You can also try creating a new account and check if that one works.