ChatGPT shortcut with prompt from selection?

The new transform and replace with GPT is amazing!! Unfortunately, I'm terrible at using it, and I was hoping for some guidance.

What's I'm looking for now is an all-in-one select and replace (e.g. selection: "Summarise and simplify this in one paragraph: [articles text]", which would be replaced with the summary). I'm confused by the fact there is a pre-determined prompt already required in the action.

Also, wider than this, is there documentation related to this amazing action? I love that you put this in the software, just wish I knew all about the features to be able to fully use it.

2 Likes

I just tried this and it seems to be working for me. I made a keyboard shortcut assigned to action Transform & Replace Selection with ChatGPT:
image

Then in the action configuration, I left "ChatGPT system prompt" at its default, and changed "ChatGPT User Prompt" to your required task Summarise and simplify the following text in one paragraph :

Then I pasted an article into Microsoft Word, selected it all, and hit my shortcut. A few moments later it got replaced with a summary, as seen in this example video:

Does that match with what you're hoping to achieve? There's an alternative method available which involves making a custom Transform & Replace Selection With Java Script action with some custom JavaScript; it's detailed on Andreas' recent blog post here. However I can't see that you'd need that for your example, if I'm understanding it correctly.

Many thanks for your reply - it's not what I'm looking for. I want a general shortcut (the selected text would also include the prompt, so that I can pass the task + its object together). This is the same as you would with the normal ChatGPT.

This is because I won't always want to summarise. I want a general shortcut that quickly ingests the prompt as well as the object in one selection and gives back the answer.

OK that's easy enough. Just empty the "ChatGPT User Prompt" in BTT's config:

image

Example:

3 Likes

Correct, if you leave the user prompt empty it will just use the selected text as user prompt. (If user prompt is provided the selected text will be prefixed with that)

In these examples you are showing do you copy the query to the clipboard before invoking the shortcut to ChatGPT or are you just selecting the text?

Just selecting the text then running the action. The BTT ChatGPT action is "Transform and Replace Selection with ChatGPT" - BTT copies the text you selected and passes it to ChatGPT (along with the ChatGPT System Prompt and ChatGPT User Prompt, if configured in the action), and replaces the selected text with whatever ChatGPT returns.

Yesterday I raised a feature request for an update to the action which could handle other cases, like processing text from the clipboard and/or putting the response into the clipboard rather than pasting it instantly as it does now. But for now it always pastes the response.

Note that all that the "Transform & Replace Selection with ChatGPT" action actually does to 'replace the text' is send Cmd-V to paste it, so if you wanted it to not delete your existing text you could achieve that by deselecting the text before BTT returns, so that the text is pasted after it rather than replacing it, like in this example:

(This only works because it takes ChatGPT a few moments to send a response - if it came back quicker you'd likely not have time to deselect the text before it got replaced.)

It's weird I can't get the selection part working on my side.

For instance if I try a simple "Tell me the advantages of BetterTouchTool" with selecting it and running the shortcut I get "How may I assist you?"

If I do a Cmd-C before then I get a valid response.

+1 on the feature request.

Strange. That sounds to me like the BTT action is failing to do the Cmd-C itself. So the first time it fails because there's nothing valid on the clipboard, but then if you run it again after doing a manual Cmd-C it sees the thing you manually copied to clipboard (which it can't overwrite because its own attempt to do Cmd-C is not working.)

Are you using an unusual keyboard layout, or have remapped Cmd-C or anything like that? I've seen Andreas mention that to people in the past when BTT actions like this weren't working. As I understand it, BTT just literally sends to macOS 'Cmd-C' and 'Cmd-V' so if those are changed in some way, it can't work.

I don't have anything else mapped to Cmd-C otherwise it wouldn't work for me in the normal way.

I do have a clipboard manager but I shut it down to see if that was the issue but it doesn't seem to be.

It's not too much of an overhead I just need to remember to run keyboard copy before as there doesn't seem to be that action in BTT that I could run before.

are you maybe using some special keyboard layout? (this could cause BTT‘s cmd+c to fail)

many thanks @TheBloke and @Andreas_Hegenberg !!

Figured out why it's not working seems to due to an external app HyperKey which I am using to map "Caps Lock" to "^ + ⌥ + ⌘".

I know there is hyper key functionality in BTT but there isn't a way to exclude ⇧ from it.

My trigger in BTT for the ChatGPT shortcut is "^ + ⌥ + ⌘ + A" so from my keyboard I am invoking "Caps Lock + A" which seems to work but the copy part fails.

If I actually press the keys individually i.e "^ + ⌥ + ⌘ + A" then the copy part of the action works as expected.

ah that makes sense. If you press the keys individually BTT will be able to temporarily "release" them before sending the cmd+c shortcut. However if this is done by some other app, BTT won't be able to do this.

I think it would work if you define the hyperkey with some lower level tool like Karabiner Elements, in that case the hyper key should really behave like real modifier keys.

Yup I use Karabiner Elements for my hyper assignment - including providing two separate hyper keys, with and without shift - and this works fine with all of BTTs actions.

r0b I'm pretty sure it was you I showed how to set up Karabiner Elements for the two-hyperkey setup? I showed it to someone anyway. Works perfectly

With BTT it works even better. In macos set up caps lock = right ⌃. Now you have a real modifier (instead of caps lock), which you can combine with shift. Since BTT can distinguish between left and right modifiers, this offers the same possibilities as hyperkey, but more reliable.

yes it was me good memory but I was having issue with it not functioning correctly with all of my media keys.

I've gone back and retried now and I've got it all working correctly with Karabiner.

With regards to using right ^ as a modifier I already have that mapped as a shortcut.

Oh yeah, I forgot that bit. Glad it's working properly now!