ChatGPT in AppSheet | How to create a continued conversation with OpenAi in AppSheet

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
------------------------------------------------------------------------------------------------------------------

  1. Create data source
    1. Threads
      1. Start Date (dateTime)
      2. Label (text)
      3. ID (text/key)

    2. Messages
      1. Prompt (longtext)
      2. Response (longtext)
      3. Number (number)
      4. Reformatting (longtext)
      5. Total Tokens (number)
      6. ID (text/key)

  2. Initialize app, setup columns, customize views

  3. Create ongoing history
    1. Message Reformatting (in message)
    2. Thread history (in thread)

  4. Create Script using ChatGPT
    1. 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).

    2. Script returns an array
      1. Your Response
      2. The total tokens (as a string)

    3. Script must be saved in an actual script file to work

  5. 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))

------------------------------------------------------------------------------------------------------------------

Part 1) Building the AppSheet foundation

Part 2) Generating the script with ChatGPT

Part 3) Basic prompt engineering

Part 4) Generating a thread label

 

 

 

16 3 3,834
3 REPLIES 3

Just put the finishing touches on the first installment of this evolution series app:

To use:

  1. Copy the app
  2. Make your script
    1. Copy the script file, making a new one, into the root directory for your app
                         or
    2. Generate your own script using the prompt paragraph from above
  3. Switch the script in the bot to your script file
  4. Get an OpenAi API key
  5. Put your key inside the field in the Welcome page
  6. Get answers from OpenAi - with continued context (^_^)

Great idea. I'm gonna try out how this works out.

Thanks ! This is neat !

Top Labels in this Space