With the popularity of ChatGPT, you might find that it is often down due to server overload. If you’re like me and you’re starting to depend on the answers ChatGPT provides, when things go down like this it can bring my progress to a screeching halt.
There is a solution: build your own version of ChatGPT! (^_^)
FYI: This is an initial post, I’ll be expanding and adding to it as the days pass.
------------------------------------------------------------------------------------------------------------------
HOW TO BUILD A ChatGPT-LIKE SYSTEM IN APPSHEET
------------------------------------------------------------------------------------------------------------------
-
Create data source
-
Threads
- Start Date (dateTime)
- Label (text)
- ID (text/key)
-
Messages
- Prompt (longtext)
- Response (longtext)
- Number (number)
- Reformatting (longtext)
- Total Tokens (number)
- ID (text/key)
-
-
Initialize app, setup columns, customize views
-
Create ongoing history
- Message Reformatting (in message)
- Thread history (in thread)
-
Create Script using ChatGPT
-
Google Apps Script function to take a ‘prompt’ and ‘apiKey’ parameter and fetch OpenAI completions using the API endpoint https://api.openai.com/v1/completions, model text-davinci-003, maximum 500 tokens, returning the completion text (result.choices[0].text) and token usage (data.usage.total_tokens) in an array format (converting the token usage to a string).
-
Script returns an array
- Your Response
- The total tokens (as a string)
-
Script must be saved in an actual script file to work
-
-
Integrate and test continued conversation
-
Task 1) Get Response
-
Call your script: passing it your API key and the prompt
- You’ll want to provide a little instructions around your prompt, telling the Ai what you want it to do -
Returns: Array(LongText)
-
-
Task 2) Record Response
- Run a data action: set row values
- Response: Index([Get Response].[Output], 1)
- Total Tokens: NUMBER(Index([Get Response].[Output], 2))
- Run a data action: set row values
-
Part 1) Building the AppSheet foundation
Part 2) Generating the script with ChatGPT
Part 3) Basic prompt engineering
Part 4) Generating a thread label