Overview
In this lab, you will use Flowise AI which is built on langchain to create some applications. This lab intends to be a gentle, guided introduction to the possibilities presented by AI. After completing this lab, you will have enough familiarity with the tools used and basic concepts to continue exploring on your own.
I plan to upload videos of these demos on the playfullySerious YouTube channel. If interested, you can subscribe so you will get notified when they are up. They can help you practice later on.
Pre requisites
To complete this lab, you will need the following:
- OpenAI API key
- Go to https://platform.openai.com/ and using any personal email ID you have to set up an account. I use my gmail to do this. The next steps will need your mobile number to get OTP. This account will give you free access to the API for a limited time and quantity of usage. These are much more than needed for this session and next few weeks of exploration. So enjoy.
- GitHub account
- Go to github.com, using gmail account create a free account
Set up Flowise for this Experiment:
This can be achieved in several ways. I have given two ways here. There are more steps described in the github account of Flowise.
Both these ways are easy and require little effort or geek quotient. I say, try both as they give you access to Flowise in different formats.
Using Replit or Codesandbox
- This is similar to local install of flowise on your laptop except for the first step. Go to codesandbox.io OR replit.com and create your free account, login. I use my google account.
- If you are in codesandbox, create a new sandbox and select node.js template. Similarly, if you are in replit, create a new repl and select node.js
- This will create a node.js environment on a virtual machine for you. Simply put, instead of installing node.js on your laptop you are using a remote machine.
- In sandbox, click to open a new terminal. In repl click on shell tab.
- Execute this command to install flowise: npm install -g flowise
- Flowise takes a less than 5 minutes to run. In case your process is taking too long, just stop and re-run the install command.
- It is possible that in repl you see warning messages that you are running out of resources and you should consider upgrading :-). Free account is good to run this tutorial. Rest is up to you.
- After flowise is installed, execute this command to launch it: npx flowise start
- This should launch Flowise in a new tab within the browser window. Click on pop out button to see flowise in a new window and follow the Labs below.
What you have done is make installed Flowise on a remote machine instead of your own laptop.
Using Railway
(recently Railway sent a msg that they are stopping free tier accounts.)
- Log into your GitHub account. Then go to the flowise github link https://github.com/FlowiseAI/Flowise
- Click on the Fork button. This will create a copy of this repository and all the files in your GutHub account
- Scroll down in the Flowise GitHub page till you see a bright color “Deploy on Railway” button. Click that. Accept to the basic conditions they impose like you will not misuse the repo etc. Then when asked to give access to your GitHub, you can select the Flowise repo you created in the Fork step. Then accept the deployment.
- The deployment usually runs for ~ 2 minutes.
- Once finished you will see an app link to click and launch Flowise on Railway.
What you have done is make Flowise available as a API using Railway hosting platform. Anything you build on this instance will be available online and later you can even share the URL to others to try out.
Local installation of Flowise
- Go to nodejs.org and download an install file for your OS.
- After downloading nodejs, install it
- Open CMD (Windows) / Terminal (iOS)
- Create a folder called flowise in any drive in your laptop
- Navigate to that folder and type these commands. You can see these mentioned in the Flowise GitHub page also.
- first try: npm –version
- this will confirm if your nodejs installation was successful
- After this it is just two more simple commands to go:
- this will install flowise on your laptop: npm install -g flowise
- this will launch flowise on your laptop: npx flowise start
- Now you should see a line that say it is listening on 3000. Open this http://localhost:3000/ using any browser to use Flowise
Lab 1: In Flowise: LLM Chain
Click on Marketplace,
select the template: Simple LLM Chain.
At the right top corner, select “Use template”.
Click on Save (right top corner) and give this Chatflow a name
Roll your mouse scroll and see zoom in / out effect. In the Open AI widget, paste your API key.
In the prompt template widget, first type: What is this company known for {company}
Save the chatflow and click on the chat icon on the right side of the window, just below the settings icon. Type in “nike” and enter. You should see a small delay and a few lines about Nike. Try other companies you want to.
Now try these prompt templates one by one:
- What is the headoffice address of this {company}
- What is this company known for {company}
- What is the headoffice address of this {company}, also what is this company known for?
- What is the headoffice address of this {company}, also what is this company known for? what is the latest stock price of this company?
- What is the products of this {company}, who is the CEO, who are some competitors?
Lab 2: In Flowise: Web Browser
After saving the previous chatflow, go to marketplace and select WebBrowser, select Use Template, Save and give this a name
Observe three widgets about Open AI. Paste the API key in all three.
Save. and click on the Chat button on the right corner.
Type in these questions first to get a feel for what works and then you can improvise. This chatbot can answer questions based on a web page supplied.
- what are the courses offered by IIM Lucknow?https://www.iiml.ac.in/
- list the 20 concepts from https://medium.com/gitconnected/20-python-concepts-i-wish-i-knew-way-earlier-573cd189c183
- ok, which products are in demand according to Tarun? https://www.thehindubusinessline.com/money-and-banking/the-outlook-is-uncertain-but-use-of-digital-will-keep-increasing-tarun-chugh/article34749175.ece
- summarize playfullyserious.com
- what are the offerings fromhttps://ninjacart.in/
- you can try supplying a linkedin profile and ask to summarize
Lab 3: In Flowise: Conversational QA Bot
After saving the previous chatflow, go to marketplace and select Conversational Retrieval QA Chain, select Use Template, Save and give this a name
Observe two widgets about Open AI. Paste the API key in all three.
There is a widget called Pinecone Upsert Document. Next few steps will replace that.
Click on the + icon on the left top, search for vector in the box and select In-memory vector store. Now this widget should be appearing on the canvas. Using simple mouse click and drags make the same connections for this widget to replace Pinecone widget. Then delete Pinecone widget.
You will need a .txt file now to create the knowledgebase for this chatbot. One simple way is to go to chatGPT and ask it to generate text and copy paste it in a .txt file. Upload that file in the Text file widget.
Save the chatflow. Click on the ‘Chat’ icon to launch the Q/A chat process. If you get errors initially, just save again and relaunch. It does need some time to ingest the text file. Start with “What is this file about”.
If you want to take this experiment a notch higher, click on the + icon and get PDF file widget to the canvas. Observe the Text file widget, make the same connections for this widget also. Now upload any PDF files to this widget. Save. Launch Chat again. Ask “what is this file about” and then try other questions.
Interesting experiment is to upload small e-books or download LinkedIn profiles as PDF and upload. You can upload multiple PDF files too.
Hope Flowise labs were insightful and fun too!
Lab 4: Lobe image classifier
Go to lobe.ai and download the installer and install it in your laptop. Launch it.
Create a new project, at the left top enter a name to this project where it now reads “Untitled”.
Click import and select camara. The app is now ready to take your pictures and assign a label for them. Modify the “label” to say “On call”, pose like you are on call with your mobile phone. Sway your head a bit so the images capture variety of poses while you are “On call”. Now click “Done”.
Again, click import and camera. This time modify “label” to “NotOnCall”. Click on the circular button to get a burst of images when you are not on call. Then click “Done”.
Observe the model is being “Trained”. Wait for it to complete.
Click on “Use” and try to use your “OnCall” pose or “NotOnCall” pose and give it feedback. Soon you will see performance is good and then you can stop.
This is an excellent ‘getting started’ post. I am sure that some of our students will get hooked on this ‘addiction’
Thanks Prof.
We are truly living in exciting times.
mfpu19