Template
OpenAi Convo - 1
ChatGPT in AppSheet
The purpose of this app is to demonstrate how you can integrate the text completion endpoints from OpenAi, combining AppSheet+Sheets+Drive+Scripts to bring them all together to create an ongoing context system in your app.
- This will allow you to have a continued conversation with OpenAi
(If you wanted a keyword to use to find for more information, this is called "Contextual Modeling" or "Contextual Understanding")
-----------------------------------------------------------------------------------------------------------------------------------------------
Build Videos
-----------------------------------------------------------------------------------------------------------------------------------------------
Part 1) Building the AppSheet foundation
- https://youtu.be/Vvj4bw7R7HY
Part 2) Generating the script with ChatGPT and integrating into an AppSheet bot
- https://youtu.be/QXh1yCVFv68
Part 3) Basic prompt engineering
- https://youtu.be/zK6i9Uu8iLM
Part 4) Generating a thread label with OpenAi, and updating the record with the AppSheet API
- https://youtu.be/oiqfR7V2Goc
Loading...
Also see:
tablet mode & fullscreen mode
How we built this app
Two tables:
- Threads
- Messages
Threads serves as the (parent) of the two, giving us a space to consolidate all the messages for that conversation in one place.
- It's on this level that we create our "Thread_History" VC, which contains the running list of each interaction for the thread.
- This history is then fed back to the system each time you submit a new prompt
- And by this method, the Ai is able to keep a history of what's going on
Messages serves as the (child) of the two, prividing the space to submit your prompt and get a response from the Ai.
- It's important to create a "Message_Reformatting" - call it what you will - that combines the Prompt and Message in one space.
- It's THIS value, the combination of things, that you bring into your [Thread_History]
-----------------------------------------------------------------------------------------------------------------------------------------------
The Script
The magic is all accomplished through the script, which takes the prompt and sends it to the OpenAi text completion endpoint and returns the response; this script is called through an Automation bot when a new message record is created.
-----------------------------------
To generate the script, you can use the following prompt:
Google Apps Script function to take a 'prompt' 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).