Completes the next turn in a conversation between a user and an OpenAI ChatGPT assistant.
=CHATGPT("Greet me in the language of your choice")
Unlike the GPT function, CHATGPT is meant to represent an ongoing and lengthening conversation between a user and an assistant (powered by ChatGPT). The two primary inputs to CHATGPT are a cell range representing the sequence of user messages, and the cell range representing the sequence of previous assistant messages. These two sequences of messages will be intertwined into an alternating sequence to represent a back and forth conversation. ChatGPT will consume the full history of the conversation and use that context to form the response.
Since each call to CHATGPT is independent, any chat history you wish to be provided as historical context must be included in the next CHATGPT call in the sequence – even previous messages returned by ChatGPT (assuming you want the next response to be aware of these previous messages).
Note: If you only need a single response to a single prompt, you should use the GPT function instead as it is a simpler interface. CHATGPT is most useful when representing a continuous back-and-forth conversation between a user and ChatGPT.
=CHATGPT(user_message_range, assistant_message_range, gpt_role, chat_model, temperature, max_tokens, cache)
The function parameters are as follows:
Caution: The GPT4 model uses 25 times more SheetGPT usage credits than the default GPT3.5 model for only marginally better results in a few narrow use-cases. It is also much slower.
A single cell reference, a cell range, or a string value representing a sequence of user message(s).
A single cell reference, a cell range, or a string value representing a sequence of assistant message(s).
Assistant messages can either be previous replies from ChatGPT that are being input for context, or training examples of how an assistant should respond in the next response.
String description of how the ChatGPT assistant should act when responding. E.g., "Act as a terse and efficient personal assistant".
String representing the OpenAI chat model to use.
Choose from "gpt-4" or "gpt-3.5-turbo" (default).
Number between 0 and 1 representing how much variance to introduce when ChatGPT responds. 0 is very little variance and 1 is the most variance.
Number representing the max number of tokens to return as the ChatGPT response. A max of 4096 is the limit for both the input and output, so plan accordingly if setting this value.
Whether or not to cache the response. Setting to false will incur a re-execution on every cell refresh. Default is true.
=CHATGPT("Greet me in the language of your choice",,"Act as an 80-year old man born and raised in the east end of London", "gpt-4")
Using non-default models (such as GPT4) may consume your SheetGPT usage credits at a much higher rate than the default model. Please make sure you understand what you are doing before using a different model.
Performance & caching
The completion that is returned is cached by SheetGPT to ensure that cell refreshes and other Sheet actions do not cause an unnecessary burn on your tokens.
CHATGPT request with the same arguments in a Sheet will return the cached value, indefinitely. This is well beyond the typical 6-hour cache limit of most Sheet plugins and is our attempt to make SheetGPT the most cost-effective way to utilize GPT functionality.
If you ever need to avoid hitting the cache and force the generation of a new response, you can set the cache argument to false to force re-generation: