Since the release of ChatGPT API on March 1st, I see the possibility that it can be a replacement for ChatGPT web for everyday use. So here I am, presenting to you the ChatGPT Conversation Action:
Conversational chat in a draft, just like what ChatGPT web does
Define the system role message to clarify the usage of the conversation for better results. This is made possible through the role property in the new API docs.
Update or delete the history message in the drafts to continuously improve the result you’ll get. While ChatGPT web cannot update or delete the history very efficiently.
The simplest way to use it is to create a new draft and type whatever you would like to ask. Then, call the action, and the result will be appended to the end of the draft.
You can also add <!-- block system --> at the top of the draft to tell ChatGPT what you want it to be. There are some curated prompts for your inspiration in this repo: Awesome ChatGPT Prompts
Note that the messages ChatGPT returns will be wrapped in <!-- block assistant -->. The action will recognize them as assistant role messages and send them to the ChatGPT API as part of the conversation. So, don’t make the conversation too long; otherwise, the token will be consumed very quickly.
You can change the default behavior of using the whole draft as the context in the conversation by setting the template tag keep-context to false. This will make the action only send the system role message and the last user role message to ChatGPT API.
Here’s a screen record of how ChatGPT understands the context:
Enjoy!
Update notice 2023-03-11
I’ve created a new template tag for the API called api-base-url. It serves as the default base URL for the API, which is set to https://api.openai.com/v1/. However, it can be altered to another URL if necessary. Please note this change if you intend to use a custom API URL.
I’ve created another action called System Message Template . It simply creates a new draft with <!-- block system --> block so that you don’t need to copy-paste it every time.
Update notice 2023-04-08
Template tag api-base-url was moved to credentials, meaning you should configure it when initializing this action. It’s called “OpenAI API Base URL (optional)”, as the name says, you can omit this option.
It is my pleasure to contribute something useful to the community. Thank you for continuously updating and supporting this great tool.
By the way, I have noticed that the “undo” function does not work properly with this action. After a new message is added, I expect the “undo” function to remove the entire message, but it only removes the words I typed before the message. Do you have any ideas on how to improve this? I use the draft.append function to edit the content.
Undo is a function of the editor. If you want changes you make to participate in the undo stack, do not use functions on the draft object to make modifications. Use the related methods on the editor object to manipulate the text, and those changes will participate in the undo system.
Thanks! I’ve updated the action to support undoing/redoing the message appended, by using editor.setTextInRange(draft.content.length, 1, '\n' + textToAppend) instead of draft.append.
Fantastic Job! Thank you so much!
Question for the group. I am going down the rabbit hole of prompts. I read the handbook The Art of ChatGPT Prompting: A Guide to Crafting Clear and Effective Prompts and wanted to know how others were using ChatGPT. I am labeling my conversations and then leaving them open in order to provide history of queries. Is anyone else doing this? The ChatConersation Action might be a way to seutp a Workspace for my list of experts.
I have input my api key but when I run the action on a draft it throws a red bar with an exclamation mark inside of a triangle displaying the name of the action. I also tried manually typing in the api key but receiving the same result. API key seems to work in other locations. Any troubleshooting one could recommend? Thanks
Re: queries (it’s all about the queries), “The Art of…” is definitely the gold standard, but, FWIW, I’ll also throw in this interesting resource, a bit more elementary, and more geared toward the new Bing chatbot. I personally can’t get enough of this stuff, so thought I’d share.
I’m loving this Action.
I created a workspace, based on the auto-assigned tag, so it’s quicker to find them.
Definitely one I’ll be using.
Thanks.
Hi Jose, this definitely is a bug in the code, seems like a case I haven’t considered. Can you give me a minimal example of the draft to reproduce this error?
Hi Jose, would you please update the plugin and try again? I reproduced this error by running the action in an empty draft. Now it will show an alert telling you to enter a prompt.
But if your error is not due to an empty prompt, please send me the text causing the issue.
Also, two things to notice:
I’ve created a new template tag for the API called api-base-url. It serves as the default base URL for the API, which is set to https://api.openai.com/v1/. However, it can be altered to another URL if necessary. Please note this change if you intend to use a custom API URL.
I’ve created another action called System Message Template, it simply creates a new draft with <!-- block system --> block so that you don’t need to copy-paste it everytime.
The API key is stored in Draft’s Credentials. You should let ChatGPT Conversation forget about what it stored. Here’s the instruction on how to forget credentials in the official docs: Credentials | Drafts User Guide