Unleashing the Power of GPT-3: A Guide to Creating Intelligent Applications with “GPT Engineer”

Ravindra Elicherla
Generative AI
Published in
3 min readJun 21, 2023

--

After a long time, I felt this was a mind-blowing application of Generative AI. GPT Engineer is made to be easy to adapt, extend, and make your agent learn how you want your code to look. It generates an entire codebase based on a prompt. I created a few applications and was overall happy with the code that’s been generated. It is close to 99% working code. Find the steps below to get there.

  1. Create virtual environment
conda create -n gptengineer python
conda activate gptengineer

2. Install GPT Engineer

git clone https://github.com/AntonOsika/gpt-engineer.git
CD to the directory
cd gpt-engineer

and
Code . (to open VS code)

4. Your folder structure would look something like this.

in projects/example, and you will find the main_prompt file. If you open it, you will find a Python script. But we will do something different.

Copy and paste contents from projects/examples and rename them as World clock.

We will build a world clock app. This will show the current time of 4 cities across the world. Write the below content in main_prompt.

Create world timer app. This should contain current time of Mumbai, London, Slovakia and New York. The time should be shown in digital clock format. Use Python and Streamlit to create this app.

after saving the above, execute the below command in terminal

python -m gpt_engineer.main worldclock/example

Overall, it did well, including installation. The instructions I gave were converted below:

1. `requirements.txt` — to list all the dependencies required for the project.

2. `app.py` — the entry point of the application.

This is the generated code. There are two files that GPT Engineer generated

  1. app.py
import streamlit as st
from datetime import datetime
import pytz

# Define the timezones
mumbai_tz = pytz.timezone('Asia/Kolkata')
london_tz = pytz.timezone('Europe/London')
slovakia_tz = pytz.timezone('Europe/Bratislava')
newyork_tz = pytz.timezone('America/New_York')

# Define the current time in each timezone
mumbai_time = datetime.now(mumbai_tz)
london_time = datetime.now(london_tz)
slovakia_time = datetime.now(slovakia_tz)
newyork_time = datetime.now(newyork_tz)

# Define the format for the digital clock
time_format = '%I:%M:%S %p'

# Create the Streamlit app
st.title('World Timer App')
st.write('Current Time in Mumbai:', mumbai_time.strftime(time_format))
st.write('Current Time in London:', london_time.strftime(time_format))
st.write('Current Time in Slovakia:', slovakia_time.strftime(time_format))
st.write('Current Time in New York:', newyork_time.strftime(time_format))

2. requirements.txt

streamlit
pytz

It also generated what it is doing

In this file, we first import the necessary libraries - Streamlit, datetime, and pytz. We then define the timezones for each city and get the current time in each timezone using the `datetime.now()` function. We also define the format for the digital clock using the `%I:%M:%S %p` format string.

Finally, we create the Streamlit app and display the current time in each city using the `st.write()` function.

To run the app, we can use the following command in the terminal:

```
streamlit run app.py
```

This will start the Streamlit server and open the app in a web browser. We should be able to see the current time in each city in a digital clock format.

It automatically ran the code and created a browser app.

This story is published on Generative AI. Connect with us on LinkedIn to get the latest AI stories and insights right in your feed. Let’s shape the future of AI together!

--

--

Geek, Painter, Fitness enthusiast, Book worm, Options expert and Simple human