How to Create an AI App to Generate Crontab Rules Using OpenAI and Streamlit

Create and Deploy Your Own AI App

Shritam Kumar Mund
Nerd For Tech
4 min readMay 23, 2021

--

If you want to build a deep learning app, how difficult can it be?

Well, It all depends on the tools you use to build the model and application, right?

Bringing a Machine Learning model outside of a notebook environment and turning it into a beautiful data product used to be a lot of work. Luckily, there’s a lot of tooling being developed. And one of them is Streamlit. Streamlit is an open-source Python library for building custom web apps.

In this tutorial, I will show you, how I created an app to generate crontab rules from raw texts. Let’s watch a quick demo below.

Click here to view the app. Note that this app cost’s me for each request. So, it might not be available after few days for your commands. Anyway, I’m going to teach you how can you make your own app like this. So, let’s get started.

What is OpenAI GPT3 Model?

Co-founded by the likes of Elon Musk and Peter Theil amongst many others, OpenAI, was once a non-profit organization. It has made huge strides in the past few years by bridging the gap between AI and general human intelligence and is commercial today. Generative Pre-trained Transformer 3 (GPT-3) is an autoregressive language model that uses deep learning to produce human-like text.

Start with installing OpenAI. This will install openai and give us access to some useful functions we will use later in this tutorial.

Now let’s install Streamlit.

Import relevant libraries,

You can find your OpenAI API key at https://beta.openai.com.

Build the Crontab Genrator Model

As we all know, to build an AI model we have to follow the ancient tradition of gathering the data. So, I took all the examples provided by crontab.guru to train my GPT3 model.

And then started train my model on OpenAI Playground.

Cool! We are done with training our model. Let’s evaluate our model

Wow! Our model can correctly generate the Crontab for given text input.

The OpenAI Python library provides convenient access to the OpenAI API from applications written in the Python language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses.

Deploy the GPT3 Model

Yay! Now we can start deploying the model that we have just trained. The script below is all we need to create a Streamlit app to generate Crontab rules from raw texts.

Details about the code above:

  • st.set_page_config(): Set the page title, shown in the browser tab. This must be the first Streamlit command used in your app, and must only be set once.
  • st.title() : Set the header title of the page.
  • st.form and st.form_submit_button : st.form can be placed anywhere in a Streamlit app to take input from the user in a form. A st.form_submit_buttonis a special button to take action once it got submitted.

Run the app. A new tab will open in your default browser.

Deploy the app on Cloud Platform:

Lastly, let’s deploy all our code into Heroku.

Heroku is a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud.

Feel free to fork and play with the code I used to create this app in this repository.

Conclusion

Congratulations! You have just learned how to create an app to generate crontab rules by just giving a few words using OpenAI and Streamlit. With tools like OpenAI and Streamlit, you can achieve a big learning curve to deploy a web application with deep learning.

I hope this article will create a motivation for you to create your own deep learning application.

Thank you for reading!

Follow me on Medium for the latest updates. 😃

Reference

  1. https://www.twilio.com/blog/ultimate-guide-openai-gpt-3-language-model
  2. https://blog.streamlit.io/introducing-submit-button-and-forms/

--

--

Shritam Kumar Mund
Nerd For Tech

Data Engineer | Python Programmer | Instructor | Tech Enthusiast - https://shritam.net/