yohasebe / openai-chat-api-workflow

🎩 An Alfred 5 Workflow for using OpenAI Chat API to interact with GPT-4o πŸ€–πŸ’¬ It also allows image generation πŸ–ΌοΈ, image understanding πŸ‘€, speech-to-text conversion 🎀, and text-to-speech synthesis πŸ”ˆ
https://github.com/yohasebe/openai-text-completion-workflow
MIT License
300 stars 8 forks source link

Hangs on 'please wait' #3

Open pmcgovern opened 1 year ago

pmcgovern commented 1 year ago

Hi, I've been looking for an Alfred workflow that can copy text in an app (like email), modify it, and paste it back.

This workflow appears to do what I want. I'm having an issue, however. When I use any method, it sends the data to OpenAi, and displays an Alfred message: 'Please Wait '. I can see the answer in the browser with a local URL that says file:///Users/(snip)/Library/Caches/com.runningwithcrayons.Alfred/Workflow%20Data/com.yohasebe.openai/tmpfile.html. And that is where it hangs. The 'Please Wait' never disappears, but I can see the tmpfile.html file in the background. If I hit escape, I can remove 'Please Wait'...and see the tmpfile content in the browser. Of course, I really want the tmpfile contents to go into my clipboard so that it is pasted back as a result into the app I'm using (like email).

Why is it hanging? What can I do to make the workflow finish? Keep up the great work! Excited to see where you take this Workflow!

yohasebe commented 1 year ago

Hi, thank you for your report. What version of Alfred are you using, Alfred 5 (or Alfred 4)?

In Alfred 5, the "Please wait" message should be automatically hidden. If not, I will take a look and see what I can do to fix it.

pmcgovern commented 1 year ago

I'm using 5.06 of Alfred. I'm using Brave as my default browser FWIW.

yohasebe commented 1 year ago

I have released version 1.6.2 with an additional 0.5 second wait time before the code to hide message takes effect. Would you try this version and see how it goes?

pmcgovern commented 1 year ago

Hi, thank for the fast turn around on the revision, I appreciate it. I gave it a try, and hit the same issue. But, in the process, I found that using Pandoc appears to be making the Workflow hang. When I uncheck the setting, it entirely runs (I still see the "Please Wait" message, but if finishes). I installed pandoc using the Mac installer on their site. It was just a few clicks, and I confirmed I have it on the computer.

Of course, now that I've unchecked pandoc, your workflow now has HTML embedded in the results. I'll do some digging and see if the newly installed pandoc is functioning properly.

pmcgovern commented 1 year ago

Tried a few samples with pandoc using the terminal, and it worked as expected.

yohasebe commented 1 year ago

This workflow requires Pandoc to be installed using Homebrew. Would you uninstall the currently installed Pandoc and (after installation of homebrew) reinstall it using the brew install pandoc command?

I have updated the workflow to version 1.6.3, which fixes a few minor issues.

The process of Pandoc installation and updating the workflow itself will be just a matter of few clicks once this workflow is included in Alfred Gallary sometime soon (I hope).

pmcgovern commented 1 year ago

Hi, I removed the previous version of Pandoc (used with the installer). I have installed Pandoc using homebrew:

brew doctor Your system is ready to brew. I confirmed pandoc is working with some of the samples. I have updated the Alfred Open Ai workflow to 1.6.3.

WIth the output HTML using Pandoc "checked" in the Workflow configurations, I am seeing the same issue.

I run the workflow in Alfred. "Please Wait" in large text comes up. In 5-ish seconds in the background the result from OpenAI is shown in the browser (tmpfile.html), but the the "Please Wait' never disappears. I hit 'escape' to remove.

I'm running the latest version of Ventura. Latest version of Alfred.

I just noticed that even though it hangs with the please wait message... the answer does get transferred to my clipboard:


USER: Don’t worry be happy. Where did that phrase come from?

ASSISTANT: The phrase "Don't worry, be happy" is actually the title of a song by Bobby McFerrin, released in 1988. The song became very popular and the phrase has since been used as a slogan for promoting positive thinking and a carefree attitude.


Interestingly, if I turn off the pandoc checkbox "WIth the output HTML using Pandoc "unchecked" The "Please Wait" does go away. I DO get content copied to the clipboard and it does NOT include HTML.... which is what I wanted. :)

USER: When was Hey Jude Released in Brazil?

ASSISTANT: Hey Jude by The Beatles was released in Brazil on September 6, 1968.


Question: A slightly different topic... but can I have the resulting text (from OpenAI), automatically pasted into the application that had the text highlighted? It would take away a step or two.

Meaning, if I'm in Apple Notes and I highlight the text "Write a poem about spaghetti", and run the workflow. Can it automatically paste the result over the highlighted text?

Thanks again for all your work on this. Very cool!

yohasebe commented 1 year ago

I just updated my workflow to version 1.6.4 and the "Please Wait" message has been tweaked again. If you are still having problems, there is a new option in the settings to not display the "Please Wait" message.

As for automatically pasting the results to the frontmost app, it is possible, but I would prefer not to add that option to the workflow. However, you can modify the workflow if you wish: Open the workflow in Preferences in Alfred and follow the instructions in the attached image.

SCR-20230306-liwu-2
pmcgovern commented 1 year ago

Wow! Great. 1.6.4 works perfectly, and I enjoy the "please wait" switch in this version (which I turned off).

I appreciate that you created a diagram for the 'auto paste' in the frontmost app. I made the tweaks suggested in the diagram and it worked the first try.

Thank you Yoichiro! I appreciate the fast replies and updated workflow. Excited that I can now use the latest OpenAI language model in all my Mac apps.

yohasebe commented 1 year ago

Glad to hear that! Enjoy!