In my previous entry I showed you step-by-step instruction of how to develop a simple code for general text-based chat app. If you haven’t seen it yet, give it a try: Create Your first Chat App with PaLM 2. In this short entry I want to show you how you can test/run/showcase such application using Google Colaboratory
Quick introduction to colab
Google Colaboratory, commonly referred to as “Colab,” is a free cloud service hosted by Google to encourage Machine Learning and Artificial Intelligence research. It provides a versatile environment that combines executable code, rich text, and graphics to help users create, collaborate on, and share documents. Colab is based on the Jupyter notebook environment and supports Python 3 interpreters. It offers free access to computing resources including GPUs and TPUs which can be particularly beneficial for resource-intensive tasks. This platform is widely used for educational purposes, data analysis, and prototyping, as it allows users to write and execute code, save and share their analyses, and access powerful computing resources, all through their browsers without the need for any setup.
Sounds perfect for our use case, doesn’t it?
Building your own notebook
I have uploaded my notebook on my github: bison_chat-app.ipynb. You can simply upload it to your google drive and use it as-is, or use it as reference when building your own notebook! There is also a full source code of the colab notebook below in this article!
To import my notebook you can simply specify github as a source code and copy the github url
Click on the notebook/path and that’s it! Once opened you should see an option to Copy to Drive which will create your own local copy on your google drive.
As as quick reminder – notebook is a document in colab that can have both code and text blocks.
I tried to add all the instructions as clear as possible to explain 4 steps we’ve got. Of course you can run them (besides pre-installing required packages) even in a simple step if you prefer, but in this way it might be a bit easier to understand.
Let’s see the notebook!
"""bison_chat_app.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/github/ontaptom/storagefreak/blob/main/materials/bison-chat-app/bison_chat_app.ipynb # Run Simple PaLM2 Chat Application in Your colab! ## Step 1. Install required packages. Please note that after executing first step you will be asked to "RESTART RUNTIME" (dedicated button appear). Hit the button, it should restart colab runtime in few seconds and you can continue. """ ! pip install google-cloud-aiplatform """## Step 2. Setup authentication to your google cloud environment. You restarted runtime after first step completed yet? OK - great, let's go with step 2 - In this colab we'll use our own permission to execute code. For that, run the next command, it will ask you to confirm you give permissions to this notebook to use your google cloud credentials when intearcting with GCP APIs. """ from google.colab import auth as google_auth google_auth.authenticate_user() """## Step 3. Let's specify the google cloud project Run the below command and once prompted, give a project name you wish to use for your google cloud chat. If you are not sure what I'm asking about check out this article: