In this lesson, we are going to talk about some basic, uh, concepts around Streamlit.
So the first thing we need to highlight is that when a we are working with level two applications,
we are going to be using code editors, not Jupyter notebooks.
So if you remember in the A in the previous phase when we were building level one applications, we
were using Jupyter notebooks.
Jupyter notebooks are very useful tools for us because they allow us to write code and also explanatory
text in a in a very easy way.
So they are very good, you know, for explaining a new, new, new things to, to students.
But when we start progressing towards more professional applications, we are going to use more the
code editors and less the Jupyter notebooks.
So in this block of a level two applications, we are going to use a code editor a in our case we use
Visual Studio Code.
This is a free editor, free code editor from Microsoft.
And this is the one we recommend you because a a a a.
First is the most used, uh, overall in the in the, in the real world.
So it is very probable that if you are applying for a job in, in, in a company, they are using Visual
Studio Code.
And the second reason why we recommend Visual Studio Code is that Visual Studio Code has now some advantages.
Uh, in a compared with other editors.
Uh, especially in the area of artificial intelligence assistance.
So if you remember, we have been talking about ChatGPT before and the value it is going to have for
you in this stage, in this stage, in this learning stage.
Uh, as an code assistant and general assistant, if you want, we use GPT four on a daily basis.
But there are other artificial intelligence tools that software engineers use while working on a daily
basis, and one of the most popular ones is GitHub, a co-pilot.
So GitHub Copilot in some cases is like an alternative to ChatGPT for.
So some people use ChatGPT for, some people use GitHub Copilot.
But the more professional you are and the more a, uh, hardcore, um, software engineer you are,
usually the more you are going to use GitHub copilot, unless you are going to use ChatGPT for.
So just because of that, we recommend Visual Studio Code, okay.
Because you are going to see that in your job interviews.
It's going to be better for you to have experience with Visual Studio Code.
And because it is extensible.
So it can use other tools like a GitHub copilot.
So remember, we don't have any kind of sponsor or sponsorship deal or whatever with any brand.
We only recommend you the tools and the brands we think are the best for you in terms of quality and
in terms of cost.
Okay.
So in this case our recommendation is going to be Visual Studio Code.
Visual Studio Code is free.
You can download it on the internet.
You have any doubt or problems.
Just go to ChatGPT four and ask there, uh, whatever.
Second important thing about the Streamlit apps we are going to build in this stage.
The structure of these apps is extremely simple.
They only have three files.
They have one file where you, uh, store the main logic of the application, and you will see that
this main file is going to be very similar to the the notebooks you have been writing in the, in the
level one applications.
Uh, in this case, uh, instead of having a notebook, we are going to have a, uh, file.
It's going to be a Python file.
And the name of the Python file is going to be main dot pi.
Pi pi Pi is the ending we use for the Python files.
Okay.
So you open your Visual Studio Code and you create a new file called main dot pi.
You will not have to do this for the exercises.
For the exercises, you just open your Visual Studio code and open the the exercises files we provide
you.
So you will see in each of the apps you have a main.py, a file, a requirements.txt file, and a dot
m file.
Well, in case the.
In this case, the dot m file is not going to be in each of the exercises, the dot m file should be
in the root folder, and you will have to create your own dot m file with your own credentials.
We have provided a sample of the dot m file in the GitHub repository, but as you remember, this is
just a sample a only with the name of the of the credentials, but not with the credentials itself,
but just for you to have a sense of the the format that you will have to use.
So about the structure of the project.
He's going to have a Streamlit application is going to have three files the Dotenv, the Main.py and
the requirements dot txt.
The last one, the requirements.txt, is where we are going to enter the name of the packages that it
will need to download in order to make the level two application work.
Okay, so instead of a installing the modules, first we include the modules in the requirements.txt
file.
And when you execute the Streamlit application these modules are automatically loaded.
Okay.
So in this file requirements.txt is where we can be more or less careful.
If we are less careful as we are whenever we work with a demo is something that we are not going to
dedicate a lot of time, we just write the name of the package.
So if we want to, uh, if we want to, uh, load the long chain OpenAI package, we will say long chain
OpenAI.
But here in the requirements.txt, you can be more careful, more specific, and include exactly the
version of the package you want.
Okay, so this is what we do in the professional applications.
We are very careful about the version of each package we load in our application, because we don't
want to use different, uh, versions of our packages because this may break your application.
Okay.
But in the case of our exercises, these are just very simple demos.
We are just going to use the name of each package as you will see.
So remember in this exercises the structure of the level two application is going to have two files.
Because the dot m file is supposed to be in the root folder.
Okay a but you will need to have a dot m file for most of these level two applications, because you
will need the OpenAI K in the in most of the cases.
And this OpenAI K is your OpenAI K.
And you should store this OpenAI K in a dot m file that you create.
So remember basic structure that open file requirements.txt and the main.py which is the the file with
the main logic of the application.
Don't worry.
We are going to see this in practice in the next lessons.
But this just a quick introduction about the basic structure of a Streamlit application.
Second thing about the Streamlit operations.
In the attached document, we are going to provide the URL where you can find the quick introduction
that extremely provides.
And this is the best way, uh, for you to have your initial experience with Streamlit there.
You will learn that extremely.
It is very simple, very basic, very easy and quick to to learn.
And you will see that the main things we are going to use in our applications are just 4 or 5 things
we are going to use some titles we are going to use some sidebars, we are going to use some forms and
some buttons and that's it.
So you will see good examples in a very, very easy and quick tutorial in Streamlit.
In the URL we provide.
You will see there as well that you can run your Streamlit application locally in your computer and
also in the cloud.
In the Streamlit Cloud, the Streamlit cloud is free and is very convenient because it's where you can
share your Streamlit application with others, so you can provide the URL of the Streamlit application
in the cloud, and any other person you know from wherever they are.
They can access this Streamlit app from the internet.
Right.
So this is this is very good.
So you will see that there is a way to execute an extremely application from your computer.
And there is a different way to execute a Streamlit application when it is in the cloud.
We will tell you a little bit more about that later, but you are going to see this in the Streamlit
tutorial and we give you this link in purpose instead of explaining all the details, uh, ourselves.
Why?
Because this is the way and, uh, artificial intelligence engineer is going to work in the real world.
So the same, uh, way that we recommended you to work with GPT four.
And in many cases, we are going to tell you, you have any doubt or any problem, just go to chat GPT
four and ask.
We are recommending you in this moment to go to the Streamlit documentation page and take a look at
their own tutorial.
You will see it's very basic, very easy to understand, but you will also realize the way we artificial
intelligence engineers work every day.
So whenever you every day, every day, we are faced with new tools, uh, with new ways to solve problems,
with new lessons that we need to learn, new frameworks, etc..
And one of the things we do on a daily basis is know new frameworks, new new devices, go to their
documentation page and understand how they work.
So this is something you are going to do on a daily basis.
So it's a very good occasion for you to start, uh, trying uh, this process with extremely.
A some very quick notes about terminal operations with Streamlit application.
So if you execute your Streamlit application from your computer and the the main instructions to do
so will be from the terminal.
Remember we have been talking about the terminal in a previous lesson in this case a to run a Streamlit
application, you only need 3 or 4 uh instructions in the terminal.
First you are going to create a virtual environment.
This is optional but highly recommended.
Then you are going to install the packages that are in the requirements.txt file.
And you will see that this is very easy.
You go to the folder where with where the Streamlit application is and you just write pip install a
requirements.txt in your terminal and that's it.
Well you will see the, the, the, the instructions in the attached document is pip install hyphen
r requirements.txt.
Exactly.
And finally you will execute the application by writing a Streamlit run.
Main.py.
That's it.
So super simple as always your operations in terminal.
Finally, a quick note about loading the Streamlit app in the cloud so extremely it provides a free
hosting service for you.
These hosting services is good but is not excellent.
Why do we say that?
Because this a cloud hosting is like temporary.
So for example, when you uh, when you visit, uh, some of the apps we provide in this section.
You will see that we are going to provide a link so you can check these applications online.
And in some cases you will see that when you try to access the application in the Streamlit cloud,
you are going to see some kind of a screen telling you that the app is sleeping.
Why is that?
Because Streamlit has a very nasty way to, uh uh, drop your apps when, uh, they have a low number
of users.
And if they don't have a lot of activity, which is in most cases when you are working with demos,
uh, your user is going to find this screen saying, oh, you know, this app is sleeping.
If you want to wake up this app, click here.
So it's not very professional, but it's the way they have, uh, to save, you know, uh, space and
computing power etc..
So the service is free.
So it's it's okay.
Right.
So in order to publish your app on Streamlit Cloud, after you have built a Streamlit app, a to show
it off to the world, you can use the Streamlit Community Cloud to deploy, manage and share your application
for free.
And you will see it works in three simple steps.
First, you put your app in a public GitHub repository.
Second, you sign into the Streamlit Community Cloud.
And finally, you just click deploy an app and then paste in your GitHub URL.
Okay, so very simple.
You just load your application from your computer to your GitHub repository.
You just sign in into the Streamlit Community Cloud.
You integrate your GitHub account with the Streamlit account.
And then you can select whatever project, uh, to deploy into the Streamlit cloud from your GitHub
repository.
Very easy.
In case of doubt, you you will have very clear, uh, step by step instructions in the Streamlit tutorial.
And also remember there you have ChatGPT for to help you with whatever doubt you may have in the process.
So in this lesson, we have been talking briefly about Streamlit and the initial concepts around Streamlit.
In the next lesson, we are going to provide you the links to the live applications, the Live the Life
level two applications on Streamlit.
We are also going to provide you the GitHub links to these level two applications code.
And finally we will go one by one.
2%.
The code and the demo for each of these level two applications.