AI Boom
In this article, I want to highlight specific indicators of the current AI boom that is unfolding before us.
Introduction
Before I go to the main things, let’s beat around the bush a little bit and remind you of some prominent recent events. For the last several months, ChatGPT, GPT4, Copilot (and Copilot X), Bard, and Midjourney were released. These are very prominent generative AI products which have already changed our lives. For example, Copilot is already a very important tool for a vast amount of programmers from all around the world. In the 2023 StackOverflow Developer Survey, a new special section emerged: AI. You can view a ranking of the significance of Copilot and ChatGPT for developers with different areas of expertise from that survey. Currently, generative AI is finding new applications in very different areas of human activity (for example in education, see here). Some of them are fairly controversial, see here
GitHub Stars as Indicator of Current AI Boom
Now let’s take a look at GitHub, specifically at new repos on GitHub that are becoming popular at an enormous pace. I think that the pace and scale at which those new repos are emerging are really fantastic.
Let’s consider one of popular repos that based on AI and new generative models. For example, AntonOsika / gpt-engineer. This project can generate for you the whole application through its description. Consider this project in more detail. The project is literally a script that only reads your description in natural language from a text file main_prompt
, runs the GPT model via OpenAI API with the content of main_prompt
, and after that, it returns code generated by the OpenAI GPT model. That’s all! The project that at the moment of writing this article has a bit more than 30’000 stars is just a simple wrapper of OpenAI API! For full understanding, I want to add code snippets that contain the main logic of this project:
This is the main class that communicates with OpenAI API:
from __future__ import annotations
import logging
import openai
logger = logging.getLogger(__name__)
class AI:
def __init__(self, model="gpt-4", temperature=0.1):
self.temperature = temperature
try:
openai.Model.retrieve(model)
self.model = model
except openai.InvalidRequestError:
print(
f"Model {model} not available for provided API key. Reverting "
"to gpt-3.5-turbo. Sign up for the GPT-4 wait list here: "
"https://openai.com/waitlist/gpt-4-api"
)
self.model = "gpt-3.5-turbo"
def start(self, system, user):
messages = [
{"role": "system", "content": system},
{"role": "user", "content": user},
]
return self.next(messages)
def next(self, messages: list[dict[str, str]], prompt=None):
if prompt:
messages += [{"role": "user", "content": prompt}]
logger.debug(f"Creating a new chat completion: {messages}")
response = openai.ChatCompletion.create(
messages=messages,
stream=True,
model=self.model,
temperature=self.temperature,
)
chat = []
for chunk in response:
delta = chunk["choices"][0]["delta"]
msg = delta.get("content", "")
print(msg, end="")
chat.append(msg)
print()
messages += [{"role": "assistant", "content": "".join(chat)}]
logger.debug(f"Chat completion finished: {messages}")
return messages
The program has several steps to execute:
simple_gen
: generate code just through the description in main_prompt,clarify
: adjustment of your prompt:main_prompt
+ the following prompt
Is anything else unclear? If yes, only answer in the form:
{remaining unclear areas} remaining questions.
{Next question}
If everything is sufficiently clear, only answer “no”.,
gen_clarified_code
(generate code through prompt afterclarify
step)gen_entrypoint
andexecute_entrypoint
(auxiliary steps to generate and execute commands that are needed to install dependencies and run code generated by previous steps)
Here is the code snippet for the simple_gen
step:
def simple_gen(ai: AI, dbs: DBs):
"""Run the AI on the main prompt and save the results"""
messages = ai.start(
setup_sys_prompt(dbs),
dbs.input["main_prompt"],
)
to_files(messages[-1]["content"], dbs.workspace)
return messages
That’s all! Currently, one can gain immense popularity on GitHub by creating a straightforward wrapper or proxy